UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 2.39 kB
import{g as k,a as O}from"./metadata-D72DunRR.js";import{O as R}from"./connection-BxF6Rdiu.js";const D={"streamable-http":"HTTP",http:"HTTP",sse:"SSE",stdio:"STDIO",websocket:"Websocket"};function H(e){return e?D[e]??e.toUpperCase():null}let V="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",E=(e=21)=>{let n="",s=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)n+=V[s[e]&63];return n};function $(e){return`${e}_${E()}`}function L(e){const n=k(e._meta),s=e.id==="deco/github-mcp"?"mcp-github":e.server?.name;return n?.appName||s||null}function W(e){if(!e?.url)return"Unknown";try{return new URL(e.url).hostname}catch{return e.url}}function j(e){const n=e?.identifier||e?.name;return n?n.replace(/^@[^/]+\//,"").replace(/[-_]/g," ").replace(/\b\w/g,r=>r.toUpperCase()):"Unknown"}function q(e,n,s,r){const t=e.server,o=k(e._meta),m=new Date().toISOString(),S=o?.friendlyName||o?.friendly_name||e.title||t?.title||t?.name||"Unnamed MCP Server",v=t?.description||null,N=t?.icons?.[0]?.src||O(t?.repository)||null,h=R.safeParse(o?.oauth_config),P=h.success?h.data:null,T=o?.configuration_state,C=o?.configuration_scopes,I=t?.repository?{url:t.repository.url,source:t.repository.source,subfolder:t.repository.subfolder}:null,p=t?.packages??[],d=t?.remotes??[],x=r?.packageIndex??0,w=r?.remoteIndex??0,_=p.length>0&&(r?.packageIndex!==void 0||d.length===0),a=_?p[x]:null,i=_?null:d[w];let l,u,b=null;if(a){const c=a.identifier||a.name;l="STDIO",u="";const f={};if(a.environmentVariables)for(const y of a.environmentVariables)y.name&&(f[y.name]="");b={command:"npx",args:c?["-y",c]:[],...Object.keys(f).length>0&&{envVars:f}}}else if(i){const c=H(i.type);l=c==="SSE"||c==="Websocket"?c:"HTTP",u=i.url||""}else l="HTTP",u="";const U=d.length>1,A=p.length>1;let g="";a&&A?g=` (${j(a)})`:i&&U&&(g=` (${W(i)})`);const M=S+g;return{id:$("conn"),title:M,description:v,icon:N,app_name:L(e),app_id:o?.id||e.id||null,connection_type:l,connection_url:u,connection_token:null,connection_headers:b,oauth_config:P,configuration_state:T??null,configuration_scopes:C??null,metadata:{source:"store",registry_item_id:e.id,verified:o?.verified??!1,scopeName:o?.scopeName??null,toolsCount:o?.tools?.length??0,publishedAt:o?.publishedAt??null,repository:I},created_at:m,updated_at:m,created_by:s,organization_id:n,tools:null,bindings:null,status:"inactive"}}export{L as a,q as e,$ as g};