onlymcp 0.25.1 → 0.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -1,85 +1,86 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as Tr,confirm as Pr,intro as Lt,isCancel as Et,log as f,multiselect as Cs,outro as oe,spinner as Ke}from"@clack/prompts";import{Command as $s}from"commander";import As from"open";import Ts from"qrcode";import{homedir as _r}from"node:os";import{createWriteStream as Ps,existsSync as R,mkdirSync as Is}from"node:fs";import{pipeline as _s}from"node:stream/promises";import{Readable as Ns}from"node:stream";import{dirname as Es,join as Ir}from"node:path";import{hostname as Xr}from"node:os";import{execFile as Br}from"node:child_process";import{hostname as Kr}from"node:os";import{readFile as Vr}from"node:fs/promises";import{promisify as Jr}from"node:util";import{randomUUID as zt}from"node:crypto";import{link as Or,mkdir as Lr,readFile as Mr,rename as Dr,rm as Ur,writeFile as Ft}from"node:fs/promises";import{basename as jr,dirname as Ht,join as zr}from"node:path";import{existsSync as Rr}from"node:fs";import{homedir as Dt}from"node:os";import{join as B}from"node:path";function we(){return process.env.ONLYMCP_HOME??B(Dt(),".claude","onlymcp")}function Mt(){return process.env.ONLYMCP_HOME??Dt()}function Ut(){return B(we(),"device-id")}function jt(){return B(we(),"cache")}function ve(){return B(we(),"stub-ignore")}function Se(){let e=[];process.env.CLAUDE_PLUGIN_ROOT&&e.push(process.env.CLAUDE_PLUGIN_ROOT);for(let t of(process.env.ONLYMCP_STUB_DIRS??"").split(":"))t&&e.push(t);for(let t of[B(Mt(),".claude"),B(Mt(),".codex")])Rr(t)&&!e.includes(t)&&e.push(t);return e.length>0?e:[B(we(),"plugin")]}var Fr=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,Gt;function Wt(){return Gt??=Gr(),Gt}async function Ve(e){try{let t=(await Mr(e,"utf8")).trim().toLowerCase();return Fr.test(t)?t:null}catch{return null}}async function Gr(){let e=Ut(),t=await Ve(e);if(t)return t;try{return await Lr(Ht(e),{recursive:!0}),await Wr(e)}catch{return null}}var Hr=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function Wr(e){let t=zt(),n=zr(Ht(e),`.${jr(e)}.${process.pid}.${zt()}.tmp`);try{await Ft(n,`${t}
3
- `,{flag:"wx",mode:384});try{return await Or(n,e),t}catch(i){let o=i.code;if(o!=="EEXIST"&&!Hr.has(o??""))throw i;if(o!=="EEXIST")try{return await Ft(e,`${t}
4
- `,{flag:"wx",mode:384}),t}catch(s){if(s.code!=="EEXIST")throw s}}let r=await Ve(e);return r||(await Dr(n,e),await Ve(e)??t)}finally{await Ur(n,{force:!0}).catch(()=>{})}}var Q="0.25.1";var Yr=Jr(Br),qr=`onlymcp-cli/${Q} (${process.platform} ${process.arch}; node ${process.versions.node})`,Bt=200;async function Kt(e,t){let n;try{return await Promise.race([e,new Promise(r=>{n=setTimeout(()=>r(null),t),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function Zr(){try{if(process.platform==="linux"){let e=Vr("/sys/class/dmi/id/product_version","utf8"),n=(await Kt(e,Bt))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let e=Yr("sysctl",["-n","hw.model"]);return(await Kt(e,Bt))?.stdout.trim()||null}}catch{}return null}async function Je(){let e="unknown";try{e=Kr()||"unknown"}catch{}let t=await Zr();return(t&&t!==e?`${e} (${t})`:e).slice(0,60)}var Vt=null;async function le(){Vt??=await Je();let e=await Wt();return{"user-agent":qr,"x-onlymcp-device":Vt,...e?{"x-onlymcp-device-id":e}:{}}}var b=class extends Error{constructor(n,r={},i=0){super(n);this.code=n;this.params=r;this.status=i;this.name="ApiError"}code;params;status},L=class{constructor(t,n){this.baseUrl=t;this.token=n}baseUrl;token;async call(t,n={}){let r=this.token();if(!r)throw new b("errors.NOT_LOGGED_IN");let i=await fetch(`${this.baseUrl}${t}`,{...n,headers:{...await le(),...n.headers??{},authorization:`Bearer ${r}`,"content-type":"application/json"}});if(i.status===204)return;let o=await i.json().catch(()=>({}));if(!i.ok)throw new b(o.code??"errors.UNKNOWN",o.params??{},i.status);return o}getMe(){return this.call("/api/me")}reportRun(t,n){return this.call("/api/devices/current/run",{method:"POST",body:JSON.stringify({kind:t,files:n}),signal:AbortSignal.timeout(5e3)})}signOut(){return this.call("/api/auth/sign-out",{method:"POST",body:"{}",signal:AbortSignal.timeout(5e3)})}listSkills(){return this.call("/api/skills")}getSkill(t,n){return this.call(`/api/skills/${encodeURIComponent(t)}${this.teamQuery(n)}`)}putSkill(t,n,r={}){return this.call(`/api/skills/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({body:n,...r})})}skillFileUrl(t,n){let r=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(t)}/files/${r}`}getSkillFile(t,n){return this.call(this.skillFileUrl(t,n))}putSkillFile(t,n,r,i="utf8"){return this.call(this.skillFileUrl(t,n),{method:"PUT",body:JSON.stringify({content:r,encoding:i})})}listAgents(){return this.call("/api/agents")}putAgent(t,n){return this.call(`/api/agents/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})}getAgent(t,{use:n=!1,team:r}={}){let i=[n?"use=1":null,r===void 0?null:`team=${encodeURIComponent(r)}`].filter(Boolean);return this.call(`/api/agents/${encodeURIComponent(t)}${i.length?`?${i.join("&")}`:""}`)}readMemory(t,n){return this.call(`${this.memoryUrl(t)}${this.teamQuery(n)}`)}writeMemory(t,n,r,i){return this.call(this.memoryUrl(t),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:r,...i===void 0?{}:{ifMatch:i}})})}memoryUrl(t){return`/api/memory/${t.split("/").map(encodeURIComponent).join("/")}`}teamQuery(t,n="?"){return t===void 0?"":`${n}team=${encodeURIComponent(t)}`}listMemory(){return this.call("/api/memory")}searchContent(t,n={}){let r=new URLSearchParams({q:t});n.types?.length&&r.set("types",n.types.join(",")),n.limit&&r.set("limit",String(n.limit));for(let i of["type","project","tag"])n[i]!==void 0&&r.set(i,n[i]);return this.call(`/api/search?${r.toString()}`)}graphNodeByRid(t,n){return this.call(`/api/graph/rid/${t}/${encodeURIComponent(n)}`)}graphAround(t,n,r={}){let i=new URLSearchParams({scope:"all",focus:t,depth:String(n),walk:"links"});return r.types?.length&&i.set("types",r.types.join(",")),r.folder!==void 0&&i.set("folder",r.folder),r.project!==void 0&&i.set("project",r.project),this.call(`/api/graph?${i.toString()}`)}memoryTree(t="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(t)}`)}moveMemory(t,n,r=!0,i=Xr()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:t,to:n,updateLinks:r,deviceLabel:i})})}async exportArchive(t={}){let n=this.token();if(!n)throw new b("errors.NOT_LOGGED_IN");let r=new URLSearchParams;t.scope&&r.set("scope",t.scope),t.types?.length&&r.set("types",t.types.join(","));let i=r.size>0?`?${r.toString()}`:"",o=await fetch(`${this.baseUrl}/api/export${i}`,{headers:{...await le(),authorization:`Bearer ${n}`}});if(!o.ok){let s=await o.json().catch(()=>({}));throw new b(s.code??"errors.UNKNOWN",s.params??{},o.status)}return o}deleteMemory(t){return this.call(this.memoryUrl(t),{method:"DELETE"})}deleteSkill(t){return this.call(`/api/skills/${encodeURIComponent(t)}`,{method:"DELETE"})}deleteSkillFile(t,n){return this.call(this.skillFileUrl(t,n),{method:"DELETE"})}deleteAgent(t){return this.call(`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE"})}listConnections(){return this.call("/api/mcp-connections")}listTeams(){return this.call("/api/teams")}shareWithTeam(t,n){return this.call(`/api/teams/${encodeURIComponent(t)}/share`,{method:"POST",body:JSON.stringify(n)})}returnFromTeam(t,n){return this.call(`/api/teams/${encodeURIComponent(t)}/unshare`,{method:"POST",body:JSON.stringify(n)})}createConnection(t){return this.call("/api/mcp-connections",{method:"POST",body:JSON.stringify(t)})}updateConnection(t,n){return this.call(`/api/mcp-connections/${t}`,{method:"PATCH",body:JSON.stringify(n)})}deleteConnection(t){return this.call(`/api/mcp-connections/${t}`,{method:"DELETE"})}listCapabilities(t){return this.call(`/api/mcp-connections/${t}/capabilities`)}toggleCapability(t,n,r){return this.call(`/api/mcp-connections/${t}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:r})})}};import{Entry as Qr}from"@napi-rs/keyring";function ei(e,t){let n=()=>new Qr(e,t);return{save(r){n().setPassword(r)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var O=ei("onlymcp","session-token");var ti={sleep:e=>new Promise(t=>setTimeout(t,e))};async function Jt(e,t,n,r=ti){let i=n;for(;;){await r.sleep(i*1e3);let s=await(await fetch(`${e}/api/auth/device/token`,{method:"POST",headers:{...await le(),"content-type":"application/json"},body:JSON.stringify({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t,client_id:"onlymcp-cli"})})).json().catch(()=>({}));if(s.access_token)return s.access_token;switch(s.error){case"authorization_pending":break;case"slow_down":i+=5;break;case"access_denied":throw new b("errors.DEVICE_ACCESS_DENIED");case"expired_token":throw new b("errors.DEVICE_CODE_EXPIRED");default:throw new b("errors.DEVICE_LOGIN_FAILED",{error:s.error})}}}import Ce from"cacache";var ni=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),ee=class{constructor(t=jt()){this.dir=t}dir;async get(t){try{let n=await Ce.get(this.dir,t),r=n.metadata;return!r||r.expiresAt<=Date.now()?(await Ce.rm.entry(this.dir,t),null):n.data.toString("utf8")}catch{return null}}async set(t,n,r=ni){await Ce.put(this.dir,t,n,{metadata:{expiresAt:Date.now()+r*1e3}})}async clear(){await Ce.rm.all(this.dir)}};import{appendFileSync as ji,existsSync as Ee,mkdirSync as on,readFileSync as an,writeFileSync as zi}from"node:fs";import{dirname as ln,join as Fi}from"node:path";function Yt(e){return{language:"bash",text:e}}function H(e,t){return{language:"json",text:JSON.stringify(e,null,2),path:t}}var ri={id:"claude-code",name:"Claude Code",category:"coding",brand:"claudecode",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://code.claude.com/docs/en/mcp-quickstart",verifiedOn:"2026-09-25",caveats:["clients.caveat.claudeCodeConnectorSynced"],install:{configPath:"~/.claude.json",format:"json",stubDir:null},remote:e=>[Yt(`claude mcp add --transport http --scope user onlymcp ${e.endpoint} --header "Authorization: Bearer ${e.token}"`)]},ii={id:"claude-app",name:"Claude",category:"chat",brand:"claude",methods:["remote-oauth"],docsUrl:"https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp",verifiedOn:"2026-09-25",caveats:["clients.caveat.claudeHeaderBeta"],install:null,oauthRedirectHosts:["claude.ai","claude.com"],remote:()=>null},oi={id:"chatgpt",name:"ChatGPT",category:"chat",brand:"openai",methods:["remote-oauth"],docsUrl:"https://help.openai.com/en/articles/12584461-developer-mode-and-mcp-apps-in-chatgpt",verifiedOn:"2026-09-25",caveats:["clients.caveat.chatgptDeveloperMode"],install:null,oauthRedirectHosts:["chatgpt.com"],remote:()=>null},si={id:"codex",name:"Codex",category:"coding",brand:"openai",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://learn.chatgpt.com/docs/extend/mcp?surface=cli",verifiedOn:"2026-09-25",caveats:["clients.caveat.codexTokenEnv"],install:{configPath:"~/.codex/config.toml",format:"toml",stubDir:"~/.codex/skills"},remote:e=>[Yt([`export ONLYMCP_TOKEN=${e.token}`,`codex mcp add onlymcp --url ${e.endpoint} --bearer-token-env-var ONLYMCP_TOKEN`].join(`
5
- `))]},ai={id:"antigravity",aliases:["gemini-cli"],name:"Antigravity",category:"coding",brand:"antigravity",methods:["remote-oauth","remote-header","stdio"],docsUrl:"https://antigravity.google/docs/mcp",verifiedOn:"2026-10-29",caveats:[],install:{configPath:"~/.gemini/config/mcp_config.json",format:"json",stubDir:null},oauthRedirectHosts:["antigravity.google"],remote:e=>[H({mcpServers:{onlymcp:{serverUrl:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.gemini/config/mcp_config.json")]},li={id:"gemini-app",name:"Gemini",category:"chat",brand:"googlegemini",methods:["remote-oauth"],docsUrl:"https://support.google.com/gemini/answer/17209137",verifiedOn:"2026-10-10",caveats:["clients.caveat.geminiAppSpark"],install:null,remote:()=>null},ci={id:"grok",name:"Grok",category:"chat",brand:"grok",methods:["remote-oauth"],docsUrl:"https://docs.x.ai/grok/connectors",verifiedOn:"2026-10-17",caveats:["clients.caveat.grokConnectors","clients.caveat.grokBusinessAdmin"],install:null,oauthRedirectHosts:["grok.com"],remote:()=>null},pi={id:"copilot-vscode",name:"GitHub Copilot (VS Code)",category:"ide",brand:"githubcopilot",oauthClientNames:["GitHub Copilot"],methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://code.visualstudio.com/docs/agents/reference/mcp-configuration",verifiedOn:"2026-10-29",caveats:["clients.caveat.copilotPolicy"],install:null,deepLink:"vscode",remote:e=>[H({servers:{onlymcp:{type:"http",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},".vscode/mcp.json")]},di={id:"cursor",name:"Cursor",category:"ide",brand:"cursor",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://cursor.com/docs/mcp",verifiedOn:"2026-09-25",caveats:[],install:null,deepLink:"cursor",remote:e=>[H({mcpServers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cursor/mcp.json")]},mi={id:"windsurf",name:"Devin Desktop (Windsurf)",category:"ide",brand:null,methods:["remote-header","stdio"],docsUrl:"https://docs.devin.ai/desktop/cascade/mcp",verifiedOn:"2026-10-29",caveats:["clients.caveat.windsurfAllowlist"],install:null,remote:e=>[H({mcpServers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.config/devin/mcp_config.json")]},ui={id:"cline",name:"Cline",category:"ide",brand:"cline",methods:["remote-header","stdio"],docsUrl:"https://docs.cline.bot/mcp/mcp-overview",verifiedOn:"2026-10-29",caveats:[],install:null,remote:e=>[H({mcpServers:{onlymcp:{type:"streamableHttp",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cline/data/settings/cline_mcp_settings.json")]},gi={id:"zed",name:"Zed",category:"ide",brand:"zedindustries",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://zed.dev/docs/ai/mcp",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[H({context_servers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"settings.json")]},fi={id:"opencode",name:"opencode",category:"coding",brand:"opencode",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://opencode.ai/docs/mcp-servers/",verifiedOn:"2026-10-29",caveats:[],install:null,remote:e=>[H({mcp:{onlymcp:{type:"remote",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"opencode.json")]},hi={id:"gitlab-duo",name:"GitLab Duo",category:"ide",brand:"gitlab",methods:["remote-oauth"],docsUrl:"https://docs.gitlab.com/user/gitlab_duo/model_context_protocol/mcp_clients",verifiedOn:"2026-10-29",caveats:["clients.caveat.gitlabDuoUserFile"],install:null,remote:e=>[H({mcpServers:{onlymcp:{type:"http",url:e.endpoint}}},"~/.gitlab/duo/mcp.json")]},$e=[ii,oi,li,ci,ri,si,ai,fi,pi,di,mi,ui,gi,hi];function Ye(e){return $e.find(t=>t.id===e||t.aliases?.includes(e))}var yi=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function $(e){return yi.test(e)&&!e.split("/").includes("..")}var bi=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,ki=8,xi=200;function W(e){if(e.length===0||e.length>xi||e==="SKILL.md")return!1;let t=e.split("/");return t.length>ki?!1:t.every(n=>bi.test(n)&&n!==".."&&n!==".")}function wi(e){return e.includes("\\")||/^[A-Za-z]:/.test(e)?!0:e.split("/").some(t=>t===""||t==="."||t==="..")}var vi=[/^\.env(\..+)?$/i,/^\.credentials\.json$/i,/^id_(rsa|dsa|ecdsa|ed25519)(\.pub)?$/i,/\.(pem|key|p12|pfx|jks|keystore)$/i,/^\.(npmrc|netrc|pgpass|htpasswd)$/i,/^\.git-credentials$/i];function Te(e){return vi.some(t=>t.test(e))}var Si=new Set([".git","node_modules","__pycache__",".venv","venv",".pytest_cache",".mypy_cache","dist","build",".next",".cache"]);function qe(e){return Si.has(e)}var Ci=[{rule:"anthropic",re:/\bsk-ant-[A-Za-z0-9_-]{20,}/},{rule:"openai",re:/\bsk-(?!ant-)[A-Za-z0-9_-]{20,}/},{rule:"github",re:/\bgh[pousr]_[A-Za-z0-9]{36,}/},{rule:"aws",re:/\bAKIA[0-9A-Z]{16}\b/},{rule:"slack",re:/\bxox[baprs]-[A-Za-z0-9-]{10,}/},{rule:"google",re:/\bAIza[0-9A-Za-z_-]{35}\b/},{rule:"jwt",re:/\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\./},{rule:"private-key",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/},{rule:"url-credentials",re:/\b[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s:/@]{6,}@/i},{rule:"assignment",re:/\b(api[_-]?key|secret|passwd|password|token|credential)\b\s*[:=]\s*['"][^'"\s]{16,}['"]/i}];function $i(e,t){let n=e.indexOf(t);return`${e.slice(Math.max(0,n-24),n)}\u2026${t.slice(0,4)}\u2026 (${t.length} characters)`}function Xt(e){let t=[],n=e.split(`
6
- `);for(let r=0;r<n.length;r+=1){let i=n[r];for(let{rule:o,re:s}of Ci){let p=s.exec(i);if(p){t.push({rule:o,line:r+1,excerpt:$i(i,p[0])});break}}}return t}function V(e){if(!e.startsWith(`---
2
+ import{cancel as Er,confirm as Rr,intro as Ut,isCancel as Mt,log as y,multiselect as Ps,outro as de,spinner as Ye}from"@clack/prompts";import{Command as Is}from"commander";import _s from"open";import Ns from"qrcode";import{homedir as Lr}from"node:os";import{createWriteStream as Es,existsSync as D,mkdirSync as Rs}from"node:fs";import{pipeline as Os}from"node:stream/promises";import{Readable as Ls}from"node:stream";import{dirname as Ms,join as Or}from"node:path";import{hostname as ri}from"node:os";import{execFile as qr}from"node:child_process";import{hostname as Zr}from"node:os";import{readFile as Xr}from"node:fs/promises";import{promisify as Qr}from"node:util";import{randomUUID as Wt}from"node:crypto";import{link as Ur,mkdir as zr,readFile as Fr,rename as Gr,rm as Hr,writeFile as Bt}from"node:fs/promises";import{basename as Wr,dirname as Vt,join as Br}from"node:path";import{existsSync as jr}from"node:fs";import{homedir as Ft}from"node:os";import{join as Z}from"node:path";function Se(){return process.env.ONLYMCP_HOME??Z(Ft(),".claude","onlymcp")}function zt(){return process.env.ONLYMCP_HOME??Ft()}function Gt(){return Z(Se(),"device-id")}function Ht(){return Z(Se(),"cache")}function Ce(){return Z(Se(),"stub-ignore")}function $e(){let e=[];process.env.CLAUDE_PLUGIN_ROOT&&e.push(process.env.CLAUDE_PLUGIN_ROOT);for(let t of(process.env.ONLYMCP_STUB_DIRS??"").split(":"))t&&e.push(t);for(let t of[Z(zt(),".claude"),Z(zt(),".codex")])jr(t)&&!e.includes(t)&&e.push(t);return e.length>0?e:[Z(Se(),"plugin")]}var Kr=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,Kt;function Jt(){return Kt??=Vr(),Kt}async function qe(e){try{let t=(await Fr(e,"utf8")).trim().toLowerCase();return Kr.test(t)?t:null}catch{return null}}async function Vr(){let e=Gt(),t=await qe(e);if(t)return t;try{return await zr(Vt(e),{recursive:!0}),await Yr(e)}catch{return null}}var Jr=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function Yr(e){let t=Wt(),n=Br(Vt(e),`.${Wr(e)}.${process.pid}.${Wt()}.tmp`);try{await Bt(n,`${t}
3
+ `,{flag:"wx",mode:384});try{return await Ur(n,e),t}catch(i){let o=i.code;if(o!=="EEXIST"&&!Jr.has(o??""))throw i;if(o!=="EEXIST")try{return await Bt(e,`${t}
4
+ `,{flag:"wx",mode:384}),t}catch(s){if(s.code!=="EEXIST")throw s}}let r=await qe(e);return r||(await Gr(n,e),await qe(e)??t)}finally{await Hr(n,{force:!0}).catch(()=>{})}}var ie="0.25.3";var ei=Qr(qr),ti=`onlymcp-cli/${ie} (${process.platform} ${process.arch}; node ${process.versions.node})`,Yt=200;async function qt(e,t){let n;try{return await Promise.race([e,new Promise(r=>{n=setTimeout(()=>r(null),t),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function ni(){try{if(process.platform==="linux"){let e=Xr("/sys/class/dmi/id/product_version","utf8"),n=(await qt(e,Yt))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let e=ei("sysctl",["-n","hw.model"]);return(await qt(e,Yt))?.stdout.trim()||null}}catch{}return null}async function Ze(){let e="unknown";try{e=Zr()||"unknown"}catch{}let t=await ni();return(t&&t!==e?`${e} (${t})`:e).slice(0,60)}var Zt=null;async function pe(){Zt??=await Ze();let e=await Jt();return{"user-agent":ti,"x-onlymcp-device":Zt,...e?{"x-onlymcp-device-id":e}:{}}}var b=class extends Error{constructor(n,r={},i=0){super(n);this.code=n;this.params=r;this.status=i;this.name="ApiError"}code;params;status},z=class{constructor(t,n){this.baseUrl=t;this.token=n}baseUrl;token;async call(t,n={}){let r=this.token();if(!r)throw new b("errors.NOT_LOGGED_IN");let i=await fetch(`${this.baseUrl}${t}`,{...n,headers:{...await pe(),...n.headers??{},authorization:`Bearer ${r}`,"content-type":"application/json"}});if(i.status===204)return;let o=await i.json().catch(()=>({}));if(!i.ok)throw new b(o.code??"errors.UNKNOWN",o.params??{},i.status);return o}getMe(){return this.call("/api/me")}reportRun(t,n){return this.call("/api/devices/current/run",{method:"POST",body:JSON.stringify({kind:t,files:n}),signal:AbortSignal.timeout(5e3)})}signOut(){return this.call("/api/auth/sign-out",{method:"POST",body:"{}",signal:AbortSignal.timeout(5e3)})}listSkills(){return this.call("/api/skills")}getSkill(t,n){return this.call(`/api/skills/${encodeURIComponent(t)}${this.teamQuery(n)}`)}putSkill(t,n,r={}){return this.call(`/api/skills/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({body:n,...r})})}skillFileUrl(t,n){let r=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(t)}/files/${r}`}getSkillFile(t,n){return this.call(this.skillFileUrl(t,n))}putSkillFile(t,n,r,i="utf8"){return this.call(this.skillFileUrl(t,n),{method:"PUT",body:JSON.stringify({content:r,encoding:i})})}listAgents(){return this.call("/api/agents")}putAgent(t,n){return this.call(`/api/agents/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})}getAgent(t,{use:n=!1,team:r}={}){let i=[n?"use=1":null,r===void 0?null:`team=${encodeURIComponent(r)}`].filter(Boolean);return this.call(`/api/agents/${encodeURIComponent(t)}${i.length?`?${i.join("&")}`:""}`)}readMemory(t,n){return this.call(`${this.memoryUrl(t)}${this.teamQuery(n)}`)}writeMemory(t,n,r,i){return this.call(this.memoryUrl(t),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:r,...i===void 0?{}:{ifMatch:i}})})}memoryUrl(t){return`/api/memory/${t.split("/").map(encodeURIComponent).join("/")}`}teamQuery(t,n="?"){return t===void 0?"":`${n}team=${encodeURIComponent(t)}`}listMemory(){return this.call("/api/memory")}searchContent(t,n={}){let r=new URLSearchParams({q:t});n.types?.length&&r.set("types",n.types.join(",")),n.limit&&r.set("limit",String(n.limit));for(let i of["type","project","tag"])n[i]!==void 0&&r.set(i,n[i]);return this.call(`/api/search?${r.toString()}`)}graphNodeByRid(t,n){return this.call(`/api/graph/rid/${t}/${encodeURIComponent(n)}`)}graphAround(t,n,r={}){let i=new URLSearchParams({scope:"all",focus:t,depth:String(n),walk:"links"});return r.types?.length&&i.set("types",r.types.join(",")),r.folder!==void 0&&i.set("folder",r.folder),r.project!==void 0&&i.set("project",r.project),this.call(`/api/graph?${i.toString()}`)}memoryTree(t="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(t)}`)}moveMemory(t,n,r=!0,i=ri()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:t,to:n,updateLinks:r,deviceLabel:i})})}async exportArchive(t={}){let n=this.token();if(!n)throw new b("errors.NOT_LOGGED_IN");let r=new URLSearchParams;t.scope&&r.set("scope",t.scope),t.types?.length&&r.set("types",t.types.join(","));let i=r.size>0?`?${r.toString()}`:"",o=await fetch(`${this.baseUrl}/api/export${i}`,{headers:{...await pe(),authorization:`Bearer ${n}`}});if(!o.ok){let s=await o.json().catch(()=>({}));throw new b(s.code??"errors.UNKNOWN",s.params??{},o.status)}return o}deleteMemory(t){return this.call(this.memoryUrl(t),{method:"DELETE"})}deleteSkill(t){return this.call(`/api/skills/${encodeURIComponent(t)}`,{method:"DELETE"})}deleteSkillFile(t,n){return this.call(this.skillFileUrl(t,n),{method:"DELETE"})}deleteAgent(t){return this.call(`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE"})}listConnections(){return this.call("/api/mcp-connections")}listTeams(){return this.call("/api/teams")}shareWithTeam(t,n){return this.call(`/api/teams/${encodeURIComponent(t)}/share`,{method:"POST",body:JSON.stringify(n)})}returnFromTeam(t,n){return this.call(`/api/teams/${encodeURIComponent(t)}/unshare`,{method:"POST",body:JSON.stringify(n)})}createConnection(t){return this.call("/api/mcp-connections",{method:"POST",body:JSON.stringify(t)})}updateConnection(t,n){return this.call(`/api/mcp-connections/${t}`,{method:"PATCH",body:JSON.stringify(n)})}deleteConnection(t){return this.call(`/api/mcp-connections/${t}`,{method:"DELETE"})}listCapabilities(t){return this.call(`/api/mcp-connections/${t}/capabilities`)}toggleCapability(t,n,r){return this.call(`/api/mcp-connections/${t}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:r})})}};import{Entry as ii}from"@napi-rs/keyring";function oi(e,t){let n=()=>new ii(e,t);return{save(r){n().setPassword(r)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var j=oi("onlymcp","session-token");var si={sleep:e=>new Promise(t=>setTimeout(t,e))};async function Xt(e,t,n,r=si){let i=n;for(;;){await r.sleep(i*1e3);let s=await(await fetch(`${e}/api/auth/device/token`,{method:"POST",headers:{...await pe(),"content-type":"application/json"},body:JSON.stringify({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t,client_id:"onlymcp-cli"})})).json().catch(()=>({}));if(s.access_token)return s.access_token;switch(s.error){case"authorization_pending":break;case"slow_down":i+=5;break;case"access_denied":throw new b("errors.DEVICE_ACCESS_DENIED");case"expired_token":throw new b("errors.DEVICE_CODE_EXPIRED");default:throw new b("errors.DEVICE_LOGIN_FAILED",{error:s.error})}}}import Ae from"cacache";var ai=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),oe=class{constructor(t=Ht()){this.dir=t}dir;async get(t){try{let n=await Ae.get(this.dir,t),r=n.metadata;return!r||r.expiresAt<=Date.now()?(await Ae.rm.entry(this.dir,t),null):n.data.toString("utf8")}catch{return null}}async set(t,n,r=ai){await Ae.put(this.dir,t,n,{metadata:{expiresAt:Date.now()+r*1e3}})}async clear(){await Ae.rm.all(this.dir)}};import{appendFileSync as Hi,existsSync as Le,mkdirSync as cn,readFileSync as pn,writeFileSync as Wi}from"node:fs";import{dirname as mn,join as Bi}from"node:path";function Qt(e){return{language:"bash",text:e}}function Y(e,t){return{language:"json",text:JSON.stringify(e,null,2),path:t}}var li={id:"claude-code",name:"Claude Code",category:"coding",brand:"claudecode",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://code.claude.com/docs/en/mcp-quickstart",verifiedOn:"2026-09-25",caveats:["clients.caveat.claudeCodeConnectorSynced"],install:{configPath:"~/.claude.json",format:"json",stubDir:null},remote:e=>[Qt(`claude mcp add --transport http --scope user onlymcp ${e.endpoint} --header "Authorization: Bearer ${e.token}"`)]},ci={id:"claude-app",name:"Claude",category:"chat",brand:"claude",methods:["remote-oauth"],docsUrl:"https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp",verifiedOn:"2026-09-25",caveats:["clients.caveat.claudeHeaderBeta"],install:null,oauthRedirectHosts:["claude.ai","claude.com"],remote:()=>null},di={id:"chatgpt",name:"ChatGPT",category:"chat",brand:"openai",methods:["remote-oauth"],docsUrl:"https://help.openai.com/en/articles/12584461-developer-mode-and-mcp-apps-in-chatgpt",verifiedOn:"2026-09-25",caveats:["clients.caveat.chatgptDeveloperMode"],install:null,oauthRedirectHosts:["chatgpt.com"],remote:()=>null},pi={id:"codex",name:"Codex",category:"coding",brand:"openai",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://learn.chatgpt.com/docs/extend/mcp?surface=cli",verifiedOn:"2026-09-25",caveats:["clients.caveat.codexTokenEnv"],install:{configPath:"~/.codex/config.toml",format:"toml",stubDir:"~/.codex/skills"},remote:e=>[Qt([`export ONLYMCP_TOKEN=${e.token}`,`codex mcp add onlymcp --url ${e.endpoint} --bearer-token-env-var ONLYMCP_TOKEN`].join(`
5
+ `))]},mi={id:"antigravity",aliases:["gemini-cli"],name:"Antigravity",category:"coding",brand:"antigravity",methods:["remote-oauth","remote-header","stdio"],docsUrl:"https://antigravity.google/docs/mcp",verifiedOn:"2026-10-29",caveats:[],install:{configPath:"~/.gemini/config/mcp_config.json",format:"json",stubDir:null},oauthRedirectHosts:["antigravity.google"],remote:e=>[Y({mcpServers:{onlymcp:{serverUrl:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.gemini/config/mcp_config.json")]},ui={id:"gemini-app",name:"Gemini",category:"chat",brand:"googlegemini",methods:["remote-oauth"],docsUrl:"https://support.google.com/gemini/answer/17209137",verifiedOn:"2026-10-10",caveats:["clients.caveat.geminiAppSpark"],install:null,remote:()=>null},gi={id:"grok",name:"Grok",category:"chat",brand:"grok",methods:["remote-oauth"],docsUrl:"https://docs.x.ai/grok/connectors",verifiedOn:"2026-10-17",caveats:["clients.caveat.grokConnectors","clients.caveat.grokBusinessAdmin"],install:null,oauthRedirectHosts:["grok.com"],remote:()=>null},fi={id:"copilot-vscode",name:"GitHub Copilot (VS Code)",category:"ide",brand:"githubcopilot",oauthClientNames:["GitHub Copilot"],methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://code.visualstudio.com/docs/agents/reference/mcp-configuration",verifiedOn:"2026-10-29",caveats:["clients.caveat.copilotPolicy"],install:null,deepLink:"vscode",remote:e=>[Y({servers:{onlymcp:{type:"http",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},".vscode/mcp.json")]},hi={id:"cursor",name:"Cursor",category:"ide",brand:"cursor",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://cursor.com/docs/mcp",verifiedOn:"2026-09-25",caveats:[],install:null,deepLink:"cursor",remote:e=>[Y({mcpServers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cursor/mcp.json")]},yi={id:"windsurf",name:"Devin Desktop (Windsurf)",category:"ide",brand:null,methods:["remote-header","stdio"],docsUrl:"https://docs.devin.ai/desktop/cascade/mcp",verifiedOn:"2026-10-29",caveats:["clients.caveat.windsurfAllowlist"],install:null,remote:e=>[Y({mcpServers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.config/devin/mcp_config.json")]},bi={id:"cline",name:"Cline",category:"ide",brand:"cline",methods:["remote-header","stdio"],docsUrl:"https://docs.cline.bot/mcp/mcp-overview",verifiedOn:"2026-10-29",caveats:[],install:null,remote:e=>[Y({mcpServers:{onlymcp:{type:"streamableHttp",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cline/data/settings/cline_mcp_settings.json")]},ki={id:"zed",name:"Zed",category:"ide",brand:"zedindustries",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://zed.dev/docs/ai/mcp",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[Y({context_servers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"settings.json")]},xi={id:"opencode",name:"opencode",category:"coding",brand:"opencode",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://opencode.ai/docs/mcp-servers/",verifiedOn:"2026-10-29",caveats:[],install:null,remote:e=>[Y({mcp:{onlymcp:{type:"remote",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"opencode.json")]},wi={id:"gitlab-duo",name:"GitLab Duo",category:"ide",brand:"gitlab",methods:["remote-oauth"],docsUrl:"https://docs.gitlab.com/user/gitlab_duo/model_context_protocol/mcp_clients",verifiedOn:"2026-10-29",caveats:["clients.caveat.gitlabDuoUserFile"],install:null,remote:e=>[Y({mcpServers:{onlymcp:{type:"http",url:e.endpoint}}},"~/.gitlab/duo/mcp.json")]},Te=[ci,di,ui,gi,li,pi,mi,xi,fi,hi,yi,bi,ki,wi];function Xe(e){return Te.find(t=>t.id===e||t.aliases?.includes(e))}var vi=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function A(e){return vi.test(e)&&!e.split("/").includes("..")}var Si=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Ci=8,$i=200;function q(e){if(e.length===0||e.length>$i||e==="SKILL.md")return!1;let t=e.split("/");return t.length>Ci?!1:t.every(n=>Si.test(n)&&n!==".."&&n!==".")}function Ai(e){return e.includes("\\")||/^[A-Za-z]:/.test(e)?!0:e.split("/").some(t=>t===""||t==="."||t==="..")}var Ti=[/^\.env(\..+)?$/i,/^\.credentials\.json$/i,/^id_(rsa|dsa|ecdsa|ed25519)(\.pub)?$/i,/\.(pem|key|p12|pfx|jks|keystore)$/i,/^\.(npmrc|netrc|pgpass|htpasswd)$/i,/^\.git-credentials$/i];function Ie(e){return Ti.some(t=>t.test(e))}var Pi=new Set([".git","node_modules","__pycache__",".venv","venv",".pytest_cache",".mypy_cache","dist","build",".next",".cache"]);function Qe(e){return Pi.has(e)}var Ii=[{rule:"anthropic",re:/\bsk-ant-[A-Za-z0-9_-]{20,}/},{rule:"openai",re:/\bsk-(?!ant-)[A-Za-z0-9_-]{20,}/},{rule:"github",re:/\bgh[pousr]_[A-Za-z0-9]{36,}/},{rule:"aws",re:/\bAKIA[0-9A-Z]{16}\b/},{rule:"slack",re:/\bxox[baprs]-[A-Za-z0-9-]{10,}/},{rule:"google",re:/\bAIza[0-9A-Za-z_-]{35}\b/},{rule:"jwt",re:/\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\./},{rule:"private-key",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/},{rule:"url-credentials",re:/\b[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s:/@]{6,}@/i},{rule:"assignment",re:/\b(api[_-]?key|secret|passwd|password|token|credential)\b\s*[:=]\s*['"][^'"\s]{16,}['"]/i}];function _i(e,t){let n=e.indexOf(t);return`${e.slice(Math.max(0,n-24),n)}\u2026${t.slice(0,4)}\u2026 (${t.length} characters)`}function nn(e){let t=[],n=e.split(`
6
+ `);for(let r=0;r<n.length;r+=1){let i=n[r];for(let{rule:o,re:s}of Ii){let d=s.exec(i);if(d){t.push({rule:o,line:r+1,excerpt:_i(i,d[0])});break}}}return t}function Q(e){if(!e.startsWith(`---
7
7
  `))return null;let t=e.indexOf(`
8
- ---`,3);return t<0?null:e.slice(4,t)}function M(e,t){if(!/^[a-zA-Z0-9_-]+$/.test(t))return;let n=new RegExp(`^${t}:[ \\t]*(.*)$`,"m").exec(e);if(!n)return;let i=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return i.length>0?i:void 0}function te(e){let t=V(e);if(t===null)return null;let n=M(t,"description");if(!n)return null;let r=M(t,"tools"),i=r?r.replace(/^\[(.*)\]$/,"$1").split(",").map(s=>s.trim()).filter(s=>s.length>0):[],o=M(t,"model");return o?{description:n,model:o,tools:i}:{description:n,tools:i}}function Ze(e){let t=V(e);return(t===null?void 0:M(t,"description"))??""}function K(e){let t=V(e);return t===null?!1:M(t,"x-onlymcp-stub")==="true"}function ce(e){if(!e.startsWith(`---
8
+ ---`,3);return t<0?null:e.slice(4,t)}function F(e,t){if(!/^[a-zA-Z0-9_-]+$/.test(t))return;let n=new RegExp(`^${t}:[ \\t]*(.*)$`,"m").exec(e);if(!n)return;let i=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return i.length>0?i:void 0}function se(e){let t=Q(e);if(t===null)return null;let n=F(t,"description");if(!n)return null;let r=F(t,"tools"),i=r?r.replace(/^\[(.*)\]$/,"$1").split(",").map(s=>s.trim()).filter(s=>s.length>0):[],o=F(t,"model");return o?{description:n,model:o,tools:i}:{description:n,tools:i}}function et(e){let t=Q(e);return(t===null?void 0:F(t,"description"))??""}function X(e){let t=Q(e);return t===null?!1:F(t,"x-onlymcp-stub")==="true"}function me(e){if(!e.startsWith(`---
9
9
  `))return e;let t=e.indexOf(`
10
10
  ---`,3);if(t<0)return e;let n=e.indexOf(`
11
- `,t+4);return n<0?"":e.slice(n+1)}var qt=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ai=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,Zt=/^[a-z0-9][a-z0-9._-]*$/i;function Qt(e){let t=e.indexOf("skills");return t>=4&&e[t-4]==="cache"&&t+1<e.length-1?{prefix:e.slice(0,t+2).join("/"),name:`${e[t-2]}:${e[t+1]}`,plugin:e[t-2],path:e.slice(t+2).join("/")}:null}function Ti(e){let t=Qt(e);return t||(e.length<2?null:{prefix:e[0],name:e[0],plugin:null,path:e.slice(1).join("/")})}var Ae=(e,t)=>e.localeCompare(t),Pi=e=>e.toLowerCase().endsWith(".md");function Xe(e,t={}){let n=t.maxBytes??2097152,r=new Set(t.release??[]),i=l=>!t.kinds||t.kinds.includes(l),o=!t.kinds||t.kinds.length!==1,s=o?null:t.kinds[0],p=[],a=[],c=(l,m,g)=>{p.push({at:l,path:m,reason:g})},d=(l,m)=>{if(l.text===void 0)return!0;let g=Xt(l.text);for(let x of g)a.push({at:m,row:{path:l.path,...x}});return g.length===0||r.has(l.path)},u=[],h=new Set;e.forEach((l,m)=>{let g=w=>{h.add(l.path),c(m,l.path,w)};if(wi(l.path))return g("invalid-path");let x=l.path.split("/");if(Te(x[x.length-1]))return g("denied-name");if(l.bytes>n)return g("too-large");u.push({e:l,i:m,parts:x})});let T=l=>o&&l.parts[0]==="memory"&&l.parts.length>1,y=new Map,k=new Set,v=(l,m)=>{let g=y.get(m.prefix);g?g.members.push(l):y.set(m.prefix,{prefix:m.prefix,name:m.name,plugin:m.plugin,at:l.i,members:[l]}),k.add(l)};if(i("skills"))if(s==="skills")for(let l of u){let m=Ti(l.parts);m?v(l,m):c(l.i,l.e.path,"not-in-a-skill-folder")}else{let l=[];for(let g of u){if(T(g)||g.parts[g.parts.length-1]!=="SKILL.md")continue;let x=Qt(g.parts);if(x&&x.path==="SKILL.md")l.push({prefix:x.prefix,name:x.name,plugin:x.plugin,depth:g.parts.length,i:g.i});else if(g.parts.length>=2){let w=g.parts.slice(0,-1).join("/");l.push({prefix:w,name:g.parts[g.parts.length-2],plugin:null,depth:g.parts.length,i:g.i})}}l.sort((g,x)=>g.depth-x.depth||g.i-x.i);let m=[];for(let g of l)m.some(x=>g.prefix===x.prefix||g.prefix.startsWith(`${x.prefix}/`))||m.push({prefix:g.prefix,name:g.name,plugin:g.plugin,path:""});for(let g of u){if(T(g))continue;let x=m.find(w=>g.e.path.startsWith(`${w.prefix}/`));x&&v(g,x)}}let _=[];for(let l of y.values()){if(!Ai.test(l.name)){c(l.at,l.prefix,"invalid-name");continue}let m=l.members.find(w=>w.e.path===`${l.prefix}/SKILL.md`);if(!m){h.has(`${l.prefix}/SKILL.md`)||c(l.at,l.prefix,"no-skill-md");continue}if(m.e.text===void 0){c(m.i,m.e.path,"binary");continue}if(K(m.e.text)){c(m.i,m.e.path,"stub");continue}let g=d(m.e,m.i),x=[];for(let w of l.members){if(w===m)continue;let X=w.e.path.slice(l.prefix.length+1);if(!W(X)){c(w.i,w.e.path,"invalid-path");continue}if(w.e.text!==void 0&&Pi(X)&&K(w.e.text)){c(w.i,w.e.path,"stub");continue}d(w.e,w.i)&&x.push(w.e.text===void 0?{path:X,sourcePath:w.e.path,bytes:w.e.bytes}:{path:X,sourcePath:w.e.path,bytes:w.e.bytes,text:w.e.text})}g&&(x.sort((w,X)=>Ae(w.path,X.path)),_.push({name:l.name,sourcePath:m.e.path,bytes:m.e.bytes,text:m.e.text,description:Ze(m.e.text),collection:l.plugin?Zt.test(l.plugin)?{key:l.plugin,kind:"plugin",label:l.plugin}:null:t.collection&&Zt.test(t.collection)?{key:t.collection,kind:"directory",label:t.collection}:null,files:x}))}let N=[],xe=u.filter(l=>!k.has(l)),G=[],se=(l,m,g,x)=>{d(l.e,l.i)&&N.push({name:m,sourcePath:l.e.path,bytes:l.e.bytes,description:g.description,...g.model?{model:g.model}:{},tools:g.tools,body:ce(x)})};for(let l of xe){if(s==="agents"){if(l.parts.length>1)c(l.i,l.e.path,"not-at-top-level");else if(!l.e.path.endsWith(".md"))c(l.i,l.e.path,"not-markdown");else if(!qt.test(l.e.path.slice(0,-3)))c(l.i,l.e.path,"invalid-name");else if(l.e.text===void 0)c(l.i,l.e.path,"binary");else if(K(l.e.text))c(l.i,l.e.path,"stub");else{let g=te(l.e.text);g?se(l,l.e.path.slice(0,-3),g,l.e.text):c(l.i,l.e.path,"no-description")}continue}let m=l.parts.length>=2&&l.parts[l.parts.length-2]==="agents"&&l.e.path.endsWith(".md");if(o&&i("agents")&&!T(l)&&m&&l.e.text!==void 0&&!K(l.e.text)){let g=te(l.e.text);if(g){let x=l.parts[l.parts.length-1].slice(0,-3);qt.test(x)?se(l,x,g,l.e.text):c(l.i,l.e.path,"invalid-name");continue}}G.push(l)}let ae=[];if(i("memory"))for(let l of G){let m=T(l)?l.parts.slice(1).join("/"):l.e.path;$(m)?l.e.text===void 0?c(l.i,l.e.path,"binary"):K(l.e.text)?c(l.i,l.e.path,"stub"):d(l.e,l.i)&&ae.push({path:m,sourcePath:l.e.path,bytes:l.e.bytes,text:l.e.text}):c(l.i,l.e.path,"invalid-path")}return ae.sort((l,m)=>Ae(l.path,m.path)),_.sort((l,m)=>Ae(l.name,m.name)),N.sort((l,m)=>Ae(l.name,m.name)),p.sort((l,m)=>l.at-m.at),a.sort((l,m)=>l.at-m.at),{memory:ae,skills:_,agents:N,skipped:p.map(({path:l,reason:m})=>({path:l,reason:m})),flagged:a.map(({row:l})=>l)}}var Ii={memory:"memory",skill:"skills",agent:"agents"},_i={memory:"memory",skills:"skill",agents:"agent"};function pe(e){let t=e.teamId===null?"":`?team=${encodeURIComponent(e.teamId)}`;return`onlymcp://${Ii[e.kind]}/${e.name}${t}`}var Ni=/^onlymcp:\/\/(memory|skills|agents)\/([^?]+)(?:\?team=([^&]+))?$/;function Qe(e){let t=Ni.exec(e);if(!t)return null;let n=null;if(t[3]!==void 0)try{n=decodeURIComponent(t[3])}catch{return null}return{kind:_i[t[1]],name:t[2],teamId:n}}var Pe=[{uriTemplate:"onlymcp://memory/{+path}{?team}",name:"Memory file",description:"One memory file by path; ?team=<id> for a team file.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://skills/{name}{?team}",name:"Skill",description:"The SKILL.md of one skill.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://agents/{name}{?team}",name:"Agent",description:"The definition file of one agent.",mimeType:"text/markdown"}],Ie=(e,t)=>`${e}__${t}`;function et(e){let t=/^(skill|agent)__(.+)$/.exec(e);return t?{kind:t[1],name:t[2]}:null}function de(e,t,n,r){let i=0;if(n!==void 0){let p=e.findIndex(a=>t(a)===n);if(p===-1)return null;i=p+1}let o=e.slice(i,i+r),s=i+r<e.length;return{page:o,next:s&&o.length>0?t(o[o.length-1]):void 0}}function tt(e,t){return e===null||e===""?t:e.endsWith(`
11
+ `,t+4);return n<0?"":e.slice(n+1)}var en=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ni=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,tn=/^[a-z0-9][a-z0-9._-]*$/i;function rn(e){let t=e.indexOf("skills");return t>=4&&e[t-4]==="cache"&&t+1<e.length-1?{prefix:e.slice(0,t+2).join("/"),name:`${e[t-2]}:${e[t+1]}`,plugin:e[t-2],path:e.slice(t+2).join("/")}:null}function Ei(e){let t=rn(e);return t||(e.length<2?null:{prefix:e[0],name:e[0],plugin:null,path:e.slice(1).join("/")})}var Pe=(e,t)=>e.localeCompare(t),Ri=e=>e.toLowerCase().endsWith(".md");function tt(e,t={}){let n=t.maxBytes??2097152,r=new Set(t.release??[]),i=l=>!t.kinds||t.kinds.includes(l),o=!t.kinds||t.kinds.length!==1,s=o?null:t.kinds[0],d=[],a=[],c=(l,u,h)=>{d.push({at:l,path:u,reason:h})},p=(l,u)=>{if(l.text===void 0)return!0;let h=nn(l.text);for(let x of h)a.push({at:u,row:{path:l.path,...x}});return h.length===0||r.has(l.path)},g=[],f=new Set;e.forEach((l,u)=>{let h=w=>{f.add(l.path),c(u,l.path,w)};if(Ai(l.path))return h("invalid-path");let x=l.path.split("/");if(Ie(x[x.length-1]))return h("denied-name");if(l.bytes>n)return h("too-large");g.push({e:l,i:u,parts:x})});let C=l=>o&&l.parts[0]==="memory"&&l.parts.length>1,P=new Map,O=new Set,E=(l,u)=>{let h=P.get(u.prefix);h?h.members.push(l):P.set(u.prefix,{prefix:u.prefix,name:u.name,plugin:u.plugin,at:l.i,members:[l]}),O.add(l)};if(i("skills"))if(s==="skills")for(let l of g){let u=Ei(l.parts);u?E(l,u):c(l.i,l.e.path,"not-in-a-skill-folder")}else{let l=[];for(let h of g){if(C(h)||h.parts[h.parts.length-1]!=="SKILL.md")continue;let x=rn(h.parts);if(x&&x.path==="SKILL.md")l.push({prefix:x.prefix,name:x.name,plugin:x.plugin,depth:h.parts.length,i:h.i});else if(h.parts.length>=2){let w=h.parts.slice(0,-1).join("/");l.push({prefix:w,name:h.parts[h.parts.length-2],plugin:null,depth:h.parts.length,i:h.i})}}l.sort((h,x)=>h.depth-x.depth||h.i-x.i);let u=[];for(let h of l)u.some(x=>h.prefix===x.prefix||h.prefix.startsWith(`${x.prefix}/`))||u.push({prefix:h.prefix,name:h.name,plugin:h.plugin,path:""});for(let h of g){if(C(h))continue;let x=u.find(w=>h.e.path.startsWith(`${w.prefix}/`));x&&E(h,x)}}let G=[];for(let l of P.values()){if(!Ni.test(l.name)){c(l.at,l.prefix,"invalid-name");continue}let u=l.members.find(w=>w.e.path===`${l.prefix}/SKILL.md`);if(!u){f.has(`${l.prefix}/SKILL.md`)||c(l.at,l.prefix,"no-skill-md");continue}if(u.e.text===void 0){c(u.i,u.e.path,"binary");continue}if(X(u.e.text)){c(u.i,u.e.path,"stub");continue}let h=p(u.e,u.i),x=[];for(let w of l.members){if(w===u)continue;let V=w.e.path.slice(l.prefix.length+1);if(!q(V)){c(w.i,w.e.path,"invalid-path");continue}if(w.e.text!==void 0&&Ri(V)&&X(w.e.text)){c(w.i,w.e.path,"stub");continue}p(w.e,w.i)&&x.push(w.e.text===void 0?{path:V,sourcePath:w.e.path,bytes:w.e.bytes}:{path:V,sourcePath:w.e.path,bytes:w.e.bytes,text:w.e.text})}h&&(x.sort((w,V)=>Pe(w.path,V.path)),G.push({name:l.name,sourcePath:u.e.path,bytes:u.e.bytes,text:u.e.text,description:et(u.e.text),collection:l.plugin?tn.test(l.plugin)?{key:l.plugin,kind:"plugin",label:l.plugin}:null:t.collection&&tn.test(t.collection)?{key:t.collection,kind:"directory",label:t.collection}:null,files:x}))}let m=[],k=g.filter(l=>!O.has(l)),v=[],I=(l,u,h,x)=>{p(l.e,l.i)&&m.push({name:u,sourcePath:l.e.path,bytes:l.e.bytes,description:h.description,...h.model?{model:h.model}:{},tools:h.tools,body:me(x)})};for(let l of k){if(s==="agents"){if(l.parts.length>1)c(l.i,l.e.path,"not-at-top-level");else if(!l.e.path.endsWith(".md"))c(l.i,l.e.path,"not-markdown");else if(!en.test(l.e.path.slice(0,-3)))c(l.i,l.e.path,"invalid-name");else if(l.e.text===void 0)c(l.i,l.e.path,"binary");else if(X(l.e.text))c(l.i,l.e.path,"stub");else{let h=se(l.e.text);h?I(l,l.e.path.slice(0,-3),h,l.e.text):c(l.i,l.e.path,"no-description")}continue}let u=l.parts.length>=2&&l.parts[l.parts.length-2]==="agents"&&l.e.path.endsWith(".md");if(o&&i("agents")&&!C(l)&&u&&l.e.text!==void 0&&!X(l.e.text)){let h=se(l.e.text);if(h){let x=l.parts[l.parts.length-1].slice(0,-3);en.test(x)?I(l,x,h,l.e.text):c(l.i,l.e.path,"invalid-name");continue}}v.push(l)}let L=[];if(i("memory"))for(let l of v){let u=C(l)?l.parts.slice(1).join("/"):l.e.path;A(u)?l.e.text===void 0?c(l.i,l.e.path,"binary"):X(l.e.text)?c(l.i,l.e.path,"stub"):p(l.e,l.i)&&L.push({path:u,sourcePath:l.e.path,bytes:l.e.bytes,text:l.e.text}):c(l.i,l.e.path,"invalid-path")}return L.sort((l,u)=>Pe(l.path,u.path)),G.sort((l,u)=>Pe(l.name,u.name)),m.sort((l,u)=>Pe(l.name,u.name)),d.sort((l,u)=>l.at-u.at),a.sort((l,u)=>l.at-u.at),{memory:L,skills:G,agents:m,skipped:d.map(({path:l,reason:u})=>({path:l,reason:u})),flagged:a.map(({row:l})=>l)}}var Oi={memory:"memory",skill:"skills",agent:"agents"},Li={memory:"memory",skills:"skill",agents:"agent"};function ue(e){let t=e.teamId===null?"":`?team=${encodeURIComponent(e.teamId)}`;return`onlymcp://${Oi[e.kind]}/${e.name}${t}`}var Mi=/^onlymcp:\/\/(memory|skills|agents)\/([^?]+)(?:\?team=([^&]+))?$/;function nt(e){let t=Mi.exec(e);if(!t)return null;let n=null;if(t[3]!==void 0)try{n=decodeURIComponent(t[3])}catch{return null}return{kind:Li[t[1]],name:t[2],teamId:n}}var _e=[{uriTemplate:"onlymcp://memory/{+path}{?team}",name:"Memory file",description:"One memory file by path; ?team=<id> for a team file.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://skills/{name}{?team}",name:"Skill",description:"The SKILL.md of one skill.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://agents/{name}{?team}",name:"Agent",description:"The definition file of one agent.",mimeType:"text/markdown"}],Ne=(e,t)=>`${e}__${t}`;function rt(e){let t=/^(skill|agent)__(.+)$/.exec(e);return t?{kind:t[1],name:t[2]}:null}function ge(e,t,n,r){let i=0;if(n!==void 0){let d=e.findIndex(a=>t(a)===n);if(d===-1)return null;i=d+1}let o=e.slice(i,i+r),s=i+r<e.length;return{page:o,next:s&&o.length>0?t(o[o.length-1]):void 0}}function it(e,t){return e===null||e===""?t:e.endsWith(`
12
12
  `)?e+t:`${e}
13
- ${t}`}function nt(e,t,n){let r=e===""?[]:e.split(`
13
+ ${t}`}function ot(e,t,n){let r=e===""?[]:e.split(`
14
14
  `);r.length>0&&e.endsWith(`
15
15
  `)&&r.pop();let i=r.length,o=Math.min(t+n-1,i);return{text:t>i?"":r.slice(t-1,o).join(`
16
- `),totalLines:i,from:t,to:o}}var rt=(e,t)=>`No lines from ${e}: the file has ${t} ${t===1?"line":"lines"}.`;var tn=["links_to","uses_skill","uses_tool","provides"],Ei=e=>tn.includes(e);function ot(e){return e.folder!==void 0||e.project!==void 0?!1:!e.types||e.types.includes("memory")}function st(e){return e?` \u2192 superseded by ${e}`:""}var _e=40,at=5,Ne=8,nn=["memory","folder","project","type","tag","skill","collection","agent","connection","tool"],Ri={connection:"mcp"},Oi=e=>Ri[e]??e;function me(e){let t;return e.kind==="memory"&&typeof e.props.path=="string"?t=e.props.path:e.kind==="connection"&&typeof e.props.slug=="string"?t=e.props.slug:t=e.name??e.key,`${Oi(e.kind)} ${t}`}var Li={links_to:{out:"links to",in:"linked from"},about:{out:"about",in:"also about it:"},has_type:{out:"has",in:"also of this type:"},tagged:{out:"has",in:"also tagged:"},contains:{out:"contains",in:"in"},in_collection:{out:"in collection",in:"in it:"},uses_skill:{out:"uses",in:"used by"},uses_tool:{out:"uses",in:"used by"},provides:{out:"provides",in:"provided by"}},Mi={links_to:0,uses_skill:1,uses_tool:1,provides:2,in_collection:2,contains:3},en=e=>Mi[e]??4;function Di(e,t){return Li[e]?.[t]??`${e}${t==="in"?" (in)":""}`}var Ui={out:"\u2192",in:"\u2190"};function lt(e){let t=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(t.length===0)return null;let n=t.map(r=>r==="mcp"?"connection":r);return n.every(r=>nn.includes(r))?n:null}var it=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function ct(e){let{path:t,focus:n,depth:r,kept:i}=e,o=new Map(e.nodes.map(y=>[y.id,y])),s=new Map,p=(y,k)=>{let v=s.get(y)??[];v.push(k),s.set(y,v)};for(let y of e.edges)p(y.from,{other:y.to,type:y.type,direction:"out"}),p(y.to,{other:y.from,type:y.type,direction:"in"});let a=y=>{if(y===n)return 0;let k=o.get(y);if(!k)return 1/0;if(k.depth!==void 0)return k.depth;let v=(s.get(y)??[]).map(_=>_.other===n?0:o.get(_.other)?.depth??1/0);return Math.min(1/0,...v)+1},c=new Map;for(let y of e.nodes){let k=a(y.id);if(y.id===n||!Number.isFinite(k)||k<1||k>r||i&&!i.has(y.id))continue;let v=c.get(k)??[];v.push(y.id),c.set(k,v)}let d=new Map;for(let y of new Map((e.missing??[]).map(k=>[`${k.from}\0${k.target}`,k])).values()){let k=a(y.from)+1;if(!Number.isFinite(k)||k>r)continue;let v=o.get(y.from),_=k>1&&v?` (via ${me(v)})`:"",N=d.get(k)??[];N.push(` \u2192 links to (missing) ${y.target}${_}`),d.set(k,N)}let u=[],h=0;for(let y=1;y<=r;y+=1){let k=c.get(y)??[];if(k.length===0&&!d.has(y))continue;h+=k.length;let v=k.map(_=>{let N=o.get(_),xe=(s.get(_)??[]).filter(m=>a(m.other)===y-1&&(y===1||Ei(m.type))).sort((m,g)=>+(g.other===n)-+(m.other===n)||en(m.type)-en(g.type)||m.type.localeCompare(g.type)),G=xe[0],se=G?xe.filter(m=>m.other===G.other).sort((m,g)=>+(m.direction==="out")-+(g.direction==="out")):[],ae=se.length===0?"\xB7 ":`${se.map(m=>{let g=m.direction==="out"?"in":"out";return`${Ui[g]} ${Di(m.type,g)}`}).join(" / ")} `,l=y>1&&G&&o.has(G.other)?` (via ${me(o.get(G.other))})`:"";return` ${ae}${me(N)}${l}`}).concat(d.get(y)??[]).sort();h+=d.get(y)?.length??0,u.push(`depth ${y}:`),u.push(...v.slice(0,_e)),v.length>_e&&u.push(` (+${v.length-_e} more)`)}if(h===0)return i?`Nothing around ${t} within ${it(r,"hop")} matches the filter.`:`${t} is connected to nothing yet.`;let T=e.truncated?" (cut at the graph limit)":"";return[`${t}: ${it(h,"node")} within ${it(r,"hop")}${T}`,...u].join(`
17
- `)}function pt(e,t=[]){let n=o=>o.startsWith("\u2190")?2:o.startsWith("(missing)")?1:0,r=[...new Set([...e.filter(o=>o.type==="links_to"||o.type==="uses_skill"||o.type==="uses_tool").map(o=>`${o.direction==="in"?"\u2190 ":""}${me(o.node)}`),...t.map(o=>`(missing) ${o}`)])].sort((o,s)=>n(o)-n(s)||o.localeCompare(s));if(r.length===0)return null;let i=r.length>Ne?` (+${r.length-Ne} more)`:"";return` \u21B3 ${r.slice(0,Ne).join(", ")}${i}`}function dt(e,t){let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new TypeError(`serverInfo: "${e}" is not an http(s) origin`);let r=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:t,websiteUrl:r,icons:[{src:`${r}/brand/connector-512.png`,mimeType:"image/png"},{src:`${r}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}var I=e=>({title:e,annotations:{title:e,readOnlyHint:!0,openWorldHint:!1}}),P=(e,t)=>({title:e,annotations:{title:e,readOnlyHint:!1,destructiveHint:t.destructive,idempotentHint:t.idempotent,openWorldHint:t.openWorld??!1}}),mt={list_memory:I("List memory files"),memory_read:I("Read a memory file"),memory_write:P("Write a memory file",{destructive:!0,idempotent:!0}),memory_append:P("Append to a memory file",{destructive:!1,idempotent:!1}),memory_delete:P("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:I("Search memory"),memory_tree:I("Show the memory tree"),memory_move:P("Move a memory file",{destructive:!1,idempotent:!1}),memory_links:I("Show memory links"),memory_graph:I("Walk the memory graph"),list_skills:I("List skills"),get_skill:I("Load a skill"),skill_write:P("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:P("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:I("List skill files"),get_skill_file:I("Read a skill file"),skill_file_write:P("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:P("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:I("List agents"),get_agent_definition:I("Load an agent definition"),agent_write:P("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:P("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:I("List connections"),connection_create:P("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:P("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:P("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:I("List a connection's tools"),connection_tool_toggle:P("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:I("Show a connection tool's schema"),connection_call:P("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0}),list_teams:I("List teams"),team_share:P("Share with a team",{destructive:!1,idempotent:!0}),team_return:P("Return from a team",{destructive:!1,idempotent:!0})};var Gi="onlymcp",gt="npx",ft=["-y","-p",Gi,"onlymcp-mcp"],cn='With the claude.ai connector synced into Claude Code, or the OnlyMCP plugin installed, you need nothing else. This local process is only for skill files on disk: it replaces the remote "onlymcp" entry in ~/.claude.json, and next to the connector or the plugin it would list every tool twice.';function ut(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Hi(e){return JSON.stringify({mcpServers:{onlymcp:e?{command:gt,args:ft,env:e}:{command:gt,args:ft}}},null,2)}function Wi(e){let t=["[mcp_servers.onlymcp]",`command = ${ut(gt)}`,`args = [${ft.map(ut).join(", ")}]`];for(let[n,r]of Object.entries(e??{}))t.push(`env = { ${n} = ${ut(r)} }`);return`${t.join(`
16
+ `),totalLines:i,from:t,to:o}}var st=(e,t)=>`No lines from ${e}: the file has ${t} ${t===1?"line":"lines"}.`;var sn=["links_to","uses_skill","uses_tool","provides"],at=e=>sn.includes(e);function ct(e){return e.folder!==void 0||e.project!==void 0?!1:!e.types||e.types.includes("memory")}function dt(e){return e?` \u2192 superseded by ${e}`:""}var Ee=40,pt=5,Re=8,an=["memory","folder","project","type","tag","skill","collection","agent","connection","tool"],Di={connection:"mcp"},ji=e=>Di[e]??e;function fe(e){let t;return e.kind==="memory"&&typeof e.props.path=="string"?t=e.props.path:e.kind==="connection"&&typeof e.props.slug=="string"?t=e.props.slug:t=e.name??e.key,`${ji(e.kind)} ${t}`}var Ui={links_to:{out:"links to",in:"linked from"},about:{out:"about",in:"also about it:"},has_type:{out:"has",in:"also of this type:"},tagged:{out:"has",in:"also tagged:"},contains:{out:"contains",in:"in"},in_collection:{out:"in collection",in:"in it:"},uses_skill:{out:"uses",in:"used by"},uses_tool:{out:"uses",in:"used by"},provides:{out:"provides",in:"provided by"}},zi={links_to:0,uses_skill:1,uses_tool:1,provides:2,in_collection:2,contains:3},on=e=>zi[e]??4;function Fi(e,t){return Ui[e]?.[t]??`${e}${t==="in"?" (in)":""}`}var Gi={out:"\u2192",in:"\u2190"};function mt(e){let t=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(t.length===0)return null;let n=t.map(r=>r==="mcp"?"connection":r);return n.every(r=>an.includes(r))?n:null}var lt=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function ut(e){let{path:t,focus:n,depth:r,kept:i}=e,o=new Map(e.nodes.map(m=>[m.id,m])),s=new Map,d=(m,k)=>{let v=s.get(m)??[];v.push(k),s.set(m,v)};for(let m of e.edges)d(m.from,{other:m.to,type:m.type,direction:"out"}),d(m.to,{other:m.from,type:m.type,direction:"in"});let a=m=>m===n?0:o.get(m)?.depth??1/0,c=m=>(s.get(m)??[]).filter(k=>k.direction==="in"&&at(k.type)),p=new Set([n]);for(let m=1;m<=r;m+=1)for(let k of e.nodes)a(k.id)===m&&c(k.id).some(v=>p.has(v.other)&&a(v.other)===m-1)&&p.add(k.id);let g=m=>{let k=a(m);if(Number.isFinite(k)||!o.has(m))return k;let v=c(m).filter(I=>p.has(I.other)).map(I=>a(I.other));return Math.min(1/0,...v)+1},f=(m,k)=>(s.get(m)??[]).filter(v=>k===1?v.other===n:v.direction==="in"&&at(v.type)&&p.has(v.other)&&a(v.other)===k-1),C=new Map;for(let m of e.nodes){let k=g(m.id);if(m.id===n||!Number.isFinite(k)||k<1||k>r||i&&!i.has(m.id)||f(m.id,k).length===0)continue;let v=C.get(k)??[];v.push(m.id),C.set(k,v)}let P=new Map;for(let m of new Map((e.missing??[]).map(k=>[`${k.from}\0${k.target}`,k])).values()){if(!p.has(m.from))continue;let k=g(m.from)+1;if(!Number.isFinite(k)||k>r)continue;let v=o.get(m.from),I=k>1&&v?` (via ${fe(v)})`:"",L=P.get(k)??[];L.push({line:` \u2192 links to (missing) ${m.target}${I}`,weight:1}),P.set(k,L)}let O=[],E=0;for(let m=1;m<=r;m+=1){let k=C.get(m)??[];if(k.length===0&&!P.has(m))continue;E+=k.length;let v=k.map(I=>{let L=o.get(I),l=f(I,m).sort((R,J)=>+(J.other===n)-+(R.other===n)||on(R.type)-on(J.type)||R.type.localeCompare(J.type)),u=l[0],h=u?(m===1?l:s.get(I)??[]).filter(R=>R.other===u.other&&(m===1||at(R.type))).sort((R,J)=>+(R.direction==="out")-+(J.direction==="out")):[],x=h.length===0?"\xB7 ":`${h.map(R=>{let J=R.direction==="out"?"in":"out";return`${Gi[J]} ${Fi(R.type,J)}`}).join(" / ")} `,w=m>1&&u&&o.has(u.other)?` (via ${fe(o.get(u.other))})`:"",V=m===1?1:new Set(l.map(R=>R.other)).size;return{line:` ${x}${fe(L)}${w}`,weight:V}}).concat(P.get(m)??[]).sort((I,L)=>L.weight-I.weight||(I.line<L.line?-1:I.line>L.line?1:0)).map(I=>I.line);E+=P.get(m)?.length??0,O.push(`depth ${m}:`),O.push(...v.slice(0,Ee)),v.length>Ee&&O.push(` (+${v.length-Ee} more)`)}if(E===0)return i?`Nothing around ${t} within ${lt(r,"hop")} matches the filter.`:`${t} is connected to nothing yet.`;let G=e.truncated?" (cut at the graph limit)":"";return[`${t}: ${lt(E,"node")} within ${lt(r,"hop")}${G}`,...O].join(`
17
+ `)}function gt(e,t=[]){let n=o=>o.startsWith("\u2190")?2:o.startsWith("(missing)")?1:0,r=[...new Set([...e.filter(o=>o.type==="links_to"||o.type==="uses_skill"||o.type==="uses_tool").map(o=>`${o.direction==="in"?"\u2190 ":""}${fe(o.node)}`),...t.map(o=>`(missing) ${o}`)])].sort((o,s)=>n(o)-n(s)||o.localeCompare(s));if(r.length===0)return null;let i=r.length>Re?` (+${r.length-Re} more)`:"";return` \u21B3 ${r.slice(0,Re).join(", ")}${i}`}function Oe(e,t){let n=[...new Set(t)].sort();if(n.includes(e))return{folder:e,note:null};let r=n.filter(s=>s.endsWith(`/${e}`));if(r.length===0){let s=e.toLowerCase();r=n.filter(d=>d.toLowerCase()===s||d.toLowerCase().endsWith(`/${s}`))}if(r.length===1)return{folder:r[0],note:`(folder ${r[0]})`};let i=s=>s.slice(0,8).join(", ")+(s.length>8?` (+${s.length-8} more)`:"");if(r.length>1)return{error:`No folder ${e}. Did you mean: ${i(r)}?`};let o=n.filter(s=>!s.includes("/"));return{error:o.length===0?`No folder ${e}. This memory has no folders yet.`:`No folder ${e}. Top-level folders: ${i(o)}.`}}function ft(e,t){let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new TypeError(`serverInfo: "${e}" is not an http(s) origin`);let r=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:t,websiteUrl:r,icons:[{src:`${r}/brand/connector-512.png`,mimeType:"image/png"},{src:`${r}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}var N=e=>({title:e,annotations:{title:e,readOnlyHint:!0,openWorldHint:!1}}),_=(e,t)=>({title:e,annotations:{title:e,readOnlyHint:!1,destructiveHint:t.destructive,idempotentHint:t.idempotent,openWorldHint:t.openWorld??!1}}),ht={list_memory:N("List memory files"),memory_read:N("Read a memory file"),memory_write:_("Write a memory file",{destructive:!0,idempotent:!0}),memory_append:_("Append to a memory file",{destructive:!1,idempotent:!1}),memory_delete:_("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:N("Search memory"),memory_tree:N("Show the memory tree"),memory_move:_("Move a memory file",{destructive:!1,idempotent:!1}),memory_links:N("Show memory links"),memory_graph:N("Walk the memory graph"),list_skills:N("List skills"),get_skill:N("Load a skill"),skill_write:_("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:_("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:N("List skill files"),get_skill_file:N("Read a skill file"),skill_file_write:_("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:_("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:N("List agents"),get_agent_definition:N("Load an agent definition"),agent_write:_("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:_("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:N("List connections"),connection_create:_("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:_("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:_("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:N("List a connection's tools"),connection_tool_toggle:_("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:N("Show a connection tool's schema"),connection_call:_("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0}),list_teams:N("List teams"),team_share:_("Share with a team",{destructive:!1,idempotent:!0}),team_return:_("Return from a team",{destructive:!1,idempotent:!0})};var Ki="onlymcp",bt="npx",kt=["-y","-p",Ki,"onlymcp-mcp"],un='With the claude.ai connector synced into Claude Code, or the OnlyMCP plugin installed, you need nothing else. This local process is only for skill files on disk: it replaces the remote "onlymcp" entry in ~/.claude.json, and next to the connector or the plugin it would list every tool twice.';function yt(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Vi(e){return JSON.stringify({mcpServers:{onlymcp:e?{command:bt,args:kt,env:e}:{command:bt,args:kt}}},null,2)}function Ji(e){let t=["[mcp_servers.onlymcp]",`command = ${yt(bt)}`,`args = [${kt.map(yt).join(", ")}]`];for(let[n,r]of Object.entries(e??{}))t.push(`env = { ${n} = ${yt(r)} }`);return`${t.join(`
18
18
  `)}
19
- `}var Bi={claude:"claude-code",gemini:"antigravity"};function pn(){return $e.filter(e=>e.install!==null)}var Ki=new Set(pn().map(e=>e.id));function Vi(e){let t=Bi[e]??Ye(e)?.id;return t&&Ki.has(t)?t:void 0}function sn(e,t){return e.startsWith("~/")?Fi(t,e.slice(2)):e}function Ji(e){return pn().map(t=>{let n=sn(t.install.configPath,e),r=t.install.stubDir?sn(t.install.stubDir,e):null,i=r?ln(r):null,o=t.install.format==="toml"?Wi(i?{ONLYMCP_STUB_DIRS:i}:void 0):Hi();return{id:t.id,name:t.name,configPath:n,format:t.install.format,stubDir:r,stubRoot:i,snippet:o}})}function Yi(e,t,n){let r={};if(Ee(e)){let o=an(e,"utf8").trim();if(o)try{r=JSON.parse(o)}catch{throw new Error(`${e} contains invalid JSON. Nothing written.`)}}let i=r.mcpServers??{};r.mcpServers={...i,[t]:n},zi(e,`${JSON.stringify(r,null,2)}
20
- `,"utf8")}function qi(e,t){return Ee(e)&&an(e,"utf8").includes("[mcp_servers.onlymcp]")?"already-present":(ji(e,`
21
- ${t}`),"written")}function dn(e,t){let n=Ji(e);if(t.all){if(t.client)return{kind:"conflicting-options"};let o=n.filter(p=>Ee(p.configPath)),s=n.filter(p=>!Ee(p.configPath));return o.length===0?{kind:"none-present-for-all",targets:n}:{kind:"all",present:o,skipped:s}}if(!t.client)return{kind:"missing-client",targets:n};let r=Vi(t.client),i=r?n.find(o=>o.id===r):void 0;return i?{kind:"single",target:i}:{kind:"unknown-client",targets:n}}function mn(e){on(ln(e.configPath),{recursive:!0});let t=e.format==="toml"?qi(e.configPath,e.snippet):(()=>{let n=JSON.parse(e.snippet),r=Object.entries(n.mcpServers)[0];if(!r)throw new Error(`${e.name}: empty mcpServers snippet.`);return Yi(e.configPath,r[0],r[1]),"written"})();return e.stubDir&&on(e.stubDir,{recursive:!0}),t}import{access as eo,mkdir as yt,readFile as to,rm as un,writeFile as Oe}from"node:fs/promises";import{dirname as no,join as ue}from"node:path";import{readFile as Zi}from"node:fs/promises";var ht=()=>!1;function Xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qi(e){let t=e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(Xi).join(".*")}$`));return n=>t.some(r=>r.test(n))}async function Re(e=ve()){try{return Qi(await Zi(e,"utf8"))}catch(t){if(t.code==="ENOENT")return ht;throw t}}var ro=/^[a-z0-9]+(-[a-z0-9]+)*$/,io=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,bt="x-onlymcp-stub";function Le(e){return e.replace(/:/g,"-")}function Me(e){return(e??"").replace(/[\r\n]+/g," ").trim()}async function kt(e,t){let n;try{n=await to(e,"utf8")}catch{return!0}let r=V(n);if(r===null||M(r,bt)!=="true")return!1;let i=M(r,"x-onlymcp-name");return i===void 0||i===t}async function gn(e,t){return await eo(e).then(()=>!0,()=>!1)&&await kt(e,t)}async function De(e,t,n={}){let r=n.ignore??ht,[{skills:i},{agents:o}]=await Promise.all([e.listSkills(),e.listAgents()]),s=0,p=0,a=[],c=[],d=0;for(let h of i){if(!io.test(h.name))continue;let T=ue(t,"skills",Le(h.name)),y=ue(T,"SKILL.md");if(r(h.name)||r(Le(h.name))){c.push(h.name),await gn(y,h.name)&&(await un(T,{recursive:!0,force:!0}),d+=1);continue}if(!await kt(y,h.name)){a.push(`skills/${Le(h.name)}`);continue}await yt(T,{recursive:!0}),await Oe(y,`---
22
- name: ${Le(h.name)}
23
- description: ${Me(h.description)||"Synchronisiert ueber OnlyMCP. Inhalt wird bei Bedarf geladen."}
24
- ${bt}: true
25
- x-onlymcp-name: ${h.name}
19
+ `}var Yi={claude:"claude-code",gemini:"antigravity"};function gn(){return Te.filter(e=>e.install!==null)}var qi=new Set(gn().map(e=>e.id));function Zi(e){let t=Yi[e]??Xe(e)?.id;return t&&qi.has(t)?t:void 0}function dn(e,t){return e.startsWith("~/")?Bi(t,e.slice(2)):e}function Xi(e){return gn().map(t=>{let n=dn(t.install.configPath,e),r=t.install.stubDir?dn(t.install.stubDir,e):null,i=r?mn(r):null,o=t.install.format==="toml"?Ji(i?{ONLYMCP_STUB_DIRS:i}:void 0):Vi();return{id:t.id,name:t.name,configPath:n,format:t.install.format,stubDir:r,stubRoot:i,snippet:o}})}function Qi(e,t,n){let r={};if(Le(e)){let o=pn(e,"utf8").trim();if(o)try{r=JSON.parse(o)}catch{throw new Error(`${e} contains invalid JSON. Nothing written.`)}}let i=r.mcpServers??{};r.mcpServers={...i,[t]:n},Wi(e,`${JSON.stringify(r,null,2)}
20
+ `,"utf8")}function eo(e,t){return Le(e)&&pn(e,"utf8").includes("[mcp_servers.onlymcp]")?"already-present":(Hi(e,`
21
+ ${t}`),"written")}function fn(e,t){let n=Xi(e);if(t.all){if(t.client)return{kind:"conflicting-options"};let o=n.filter(d=>Le(d.configPath)),s=n.filter(d=>!Le(d.configPath));return o.length===0?{kind:"none-present-for-all",targets:n}:{kind:"all",present:o,skipped:s}}if(!t.client)return{kind:"missing-client",targets:n};let r=Zi(t.client),i=r?n.find(o=>o.id===r):void 0;return i?{kind:"single",target:i}:{kind:"unknown-client",targets:n}}function hn(e){cn(mn(e.configPath),{recursive:!0});let t=e.format==="toml"?eo(e.configPath,e.snippet):(()=>{let n=JSON.parse(e.snippet),r=Object.entries(n.mcpServers)[0];if(!r)throw new Error(`${e.name}: empty mcpServers snippet.`);return Qi(e.configPath,r[0],r[1]),"written"})();return e.stubDir&&cn(e.stubDir,{recursive:!0}),t}import{access as io,mkdir as wt,readFile as oo,rm as yn,writeFile as De}from"node:fs/promises";import{dirname as so,join as he}from"node:path";import{readFile as to}from"node:fs/promises";var xt=()=>!1;function no(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ro(e){let t=e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(no).join(".*")}$`));return n=>t.some(r=>r.test(n))}async function Me(e=Ce()){try{return ro(await to(e,"utf8"))}catch(t){if(t.code==="ENOENT")return xt;throw t}}var ao=/^[a-z0-9]+(-[a-z0-9]+)*$/,lo=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,vt="x-onlymcp-stub";function je(e){return e.replace(/:/g,"-")}function Ue(e){return(e??"").replace(/[\r\n]+/g," ").trim()}async function St(e,t){let n;try{n=await oo(e,"utf8")}catch{return!0}let r=Q(n);if(r===null||F(r,vt)!=="true")return!1;let i=F(r,"x-onlymcp-name");return i===void 0||i===t}async function bn(e,t){return await io(e).then(()=>!0,()=>!1)&&await St(e,t)}async function ze(e,t,n={}){let r=n.ignore??xt,[{skills:i},{agents:o}]=await Promise.all([e.listSkills(),e.listAgents()]),s=0,d=0,a=[],c=[],p=0;for(let f of i){if(!lo.test(f.name))continue;let C=he(t,"skills",je(f.name)),P=he(C,"SKILL.md");if(r(f.name)||r(je(f.name))){c.push(f.name),await bn(P,f.name)&&(await yn(C,{recursive:!0,force:!0}),p+=1);continue}if(!await St(P,f.name)){a.push(`skills/${je(f.name)}`);continue}await wt(C,{recursive:!0}),await De(P,`---
22
+ name: ${je(f.name)}
23
+ description: ${Ue(f.description)||"Synchronisiert ueber OnlyMCP. Inhalt wird bei Bedarf geladen."}
24
+ ${vt}: true
25
+ x-onlymcp-name: ${f.name}
26
26
  ---
27
27
 
28
- Call \`get_skill({ name: "${h.name}" })\` on the OnlyMCP server and follow whatever comes back.
29
- `,"utf8"),p+=1;try{let k=await e.getSkill(h.name);for(let v of k.files??[]){if(!W(v.path))continue;let _=await e.getSkillFile(h.name,v.path),N=ue(T,...v.path.split("/"));await yt(no(N),{recursive:!0}),_.encoding==="base64"?await Oe(N,Buffer.from(_.content,"base64")):await Oe(N,_.content,"utf8"),s+=1}}catch{}}await yt(ue(t,"agents"),{recursive:!0});let u=0;for(let h of o){if(!ro.test(h.name))continue;let T=ue(t,"agents",`${h.name}.md`);if(r(h.name)){c.push(h.name),await gn(T,h.name)&&(await un(T),d+=1);continue}if(!await kt(T,h.name)){a.push(`agents/${h.name}.md`);continue}let y=Me(h.description),k=h.model?Me(h.model):"",v=h.tools.map(Me).join(", ");await Oe(T,`---
30
- name: ${h.name}
31
- description: ${y}
32
- ${k?`model: ${k}
33
- `:""}tools: ${v}
34
- ${bt}: true
35
- x-onlymcp-name: ${h.name}
28
+ Call \`get_skill({ name: "${f.name}" })\` on the OnlyMCP server and follow whatever comes back.
29
+ `,"utf8"),d+=1;try{let O=await e.getSkill(f.name);for(let E of O.files??[]){if(!q(E.path))continue;let G=await e.getSkillFile(f.name,E.path),m=he(C,...E.path.split("/"));await wt(so(m),{recursive:!0}),G.encoding==="base64"?await De(m,Buffer.from(G.content,"base64")):await De(m,G.content,"utf8"),s+=1}}catch{}}await wt(he(t,"agents"),{recursive:!0});let g=0;for(let f of o){if(!ao.test(f.name))continue;let C=he(t,"agents",`${f.name}.md`);if(r(f.name)){c.push(f.name),await bn(C,f.name)&&(await yn(C),p+=1);continue}if(!await St(C,f.name)){a.push(`agents/${f.name}.md`);continue}let P=Ue(f.description),O=f.model?Ue(f.model):"",E=f.tools.map(Ue).join(", ");await De(C,`---
30
+ name: ${f.name}
31
+ description: ${P}
32
+ ${O?`model: ${O}
33
+ `:""}tools: ${E}
34
+ ${vt}: true
35
+ x-onlymcp-name: ${f.name}
36
36
  ---
37
37
 
38
- Call \`get_agent_definition({ name: "${h.name}" })\` on the OnlyMCP server and follow whatever comes back.
39
- `,"utf8"),u+=1}return{skills:p,agents:u,files:s,kept:a,ignored:c,removed:d}}import{Server as Bo}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Ko}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as Vo,GetPromptRequestSchema as Jo,ListPromptsRequestSchema as Yo,ListResourceTemplatesRequestSchema as qo,ListResourcesRequestSchema as Zo,ListToolsRequestSchema as Xo,ReadResourceRequestSchema as Qo}from"@modelcontextprotocol/sdk/types.js";var oo="https://only-mcp.com";function fn(e=process.env.ONLYMCP_API_URL){if(e===void 0)return oo;let t;try{t=new URL(e).protocol}catch{}if(t!=="http:"&&t!=="https:"){let n=e.replace(/\/\/[^/@]*@/,"//***@");throw new Error(`ONLYMCP_API_URL is not a valid http(s) URL: ${JSON.stringify(n)}`)}return e}var hn=["OnlyMCP holds this user's skills, agents and memory in the cloud, identical","on every machine. The names below are names only, not content: call","get_skill(name) to load a skill before following it, and","get_agent_definition(name) for an agent. Call list_skills or list_agents for","anything not named here. Memory is live: memory_read(path) and","memory_write(path, content). All of it is writable, not just readable:","skill_write, agent_write and the matching *_delete tools; connection_create","adds another MCP server to this account.","Link with [[name]] or typed: [[skill:name]], [[agent:name]], [[mcp:slug]], [[memory:path]]."].join(" "),so=["Memory is a vault, not a scratch file: read MEMORY.md first, it is the index.","After finishing a task, write one solutions/sol-*.md for what was not obvious","and one entry in history/YYYY-MM-DD.md. Link related files with [[name]];","memory_links(path) says which of a file's links point nowhere yet."].join(" ");function yn(e,t,n,r){if(n.length===0)return"";let i=[];for(let p of n){let a=n.length-i.length-1,c=a>0?` (+${a} more, call ${t})`:"",d=`
38
+ Call \`get_agent_definition({ name: "${f.name}" })\` on the OnlyMCP server and follow whatever comes back.
39
+ `,"utf8"),g+=1}return{skills:d,agents:g,files:s,kept:a,ignored:c,removed:p}}import{Server as Yo}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as qo}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as Zo,GetPromptRequestSchema as Xo,ListPromptsRequestSchema as Qo,ListResourceTemplatesRequestSchema as es,ListResourcesRequestSchema as ts,ListToolsRequestSchema as ns,ReadResourceRequestSchema as rs}from"@modelcontextprotocol/sdk/types.js";var co="https://only-mcp.com";function kn(e=process.env.ONLYMCP_API_URL){if(e===void 0)return co;let t;try{t=new URL(e).protocol}catch{}if(t!=="http:"&&t!=="https:"){let n=e.replace(/\/\/[^/@]*@/,"//***@");throw new Error(`ONLYMCP_API_URL is not a valid http(s) URL: ${JSON.stringify(n)}`)}return e}var xn=["OnlyMCP holds this user's skills, agents and memory in the cloud, identical","on every machine. The names below are names only, not content: call","get_skill(name) to load a skill before following it, and","get_agent_definition(name) for an agent. Call list_skills or list_agents for","anything not named here. Memory is live: memory_read(path) and","memory_write(path, content). All of it is writable, not just readable:","skill_write, agent_write and the matching *_delete tools; connection_create","adds another MCP server to this account.","Link with [[name]] or typed: [[skill:name]], [[agent:name]], [[mcp:slug]], [[memory:path]]."].join(" "),po=["Memory is a vault, not a scratch file: read MEMORY.md first, it is the index.","After finishing a task, write one solutions/sol-*.md for what was not obvious","and one entry in history/YYYY-MM-DD.md. Link related files with [[name]];","memory_links(path) says which of a file's links point nowhere yet."].join(" ");function wn(e,t,n,r){if(n.length===0)return"";let i=[];for(let d of n){let a=n.length-i.length-1,c=a>0?` (+${a} more, call ${t})`:"",p=`
40
40
 
41
- ${e}: ${[...i,p].join(", ")}${c}`;if(r+d.length>1800)break;i.push(p)}if(i.length===0)return`
41
+ ${e}: ${[...i,d].join(", ")}${c}`;if(r+p.length>1800)break;i.push(d)}if(i.length===0)return`
42
42
 
43
43
  ${e}: call ${t}`;let o=n.length-i.length,s=o>0?` (+${o} more, call ${t})`:"";return`
44
44
 
45
- ${e}: ${i.join(", ")}${s}`}function xt(e,t,n={}){let r=n.brainvault===!1?hn:`${hn} ${so}`,i=t.length>0?26:0;return r+=yn("Skills","list_skills",e,r.length+i),r+=yn("Agents","list_agents",t,r.length),r}import{z as bn}from"zod";var ao=bn.object({name:bn.string().min(1).max(64)}),wt=e=>e.replace(/[\r\n]+/g," ").trim();function ge(e){let t=e.model?`model: ${wt(e.model)}
45
+ ${e}: ${i.join(", ")}${s}`}function Ct(e,t,n={}){let r=n.brainvault===!1?xn:`${xn} ${po}`,i=t.length>0?26:0;return r+=wn("Skills","list_skills",e,r.length+i),r+=wn("Agents","list_agents",t,r.length),r}import{z as vn}from"zod";var mo=vn.object({name:vn.string().min(1).max(64)}),$t=e=>e.replace(/[\r\n]+/g," ").trim();function ye(e){let t=e.model?`model: ${$t(e.model)}
46
46
  `:"";return`---
47
47
  name: ${e.name}
48
- description: ${wt(e.description??"")}
49
- ${t}tools: ${(e.tools??[]).map(wt).join(", ")}
48
+ description: ${$t(e.description??"")}
49
+ ${t}tools: ${(e.tools??[]).map($t).join(", ")}
50
50
  ---
51
- ${e.body}`}function kn(e,t){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:ao,async handler(n){let r=`agent:${n.name}`,i=await t.get(r);if(i!==null)return{content:[{type:"text",text:i}]};try{let o=await e.getAgent(n.name,{use:!0}),s=ge(o);return await t.set(r,s),{content:[{type:"text",text:s}]}}catch(o){return{content:[{type:"text",text:o instanceof b?o.code:"errors.UNKNOWN"}],isError:!0}}}}}var J=(e,t)=>Object.assign(new Error(t),{code:e}),vt=e=>Buffer.from(e,"utf8").toString("base64url");function St(e){return/^[A-Za-z0-9_-]+$/.test(e)?Buffer.from(e,"base64url").toString("utf8"):null}var fe=()=>J(-32602,"Invalid cursor."),ne=(e,t)=>e<t?-1:e>t?1:0,xn={memory:0,skill:1,agent:2};function lo(e,t){return xn[e.kind]-xn[t.kind]||ne(e.name,t.name)||(e.teamId===t.teamId?0:e.teamId===null?-1:t.teamId===null?1:ne(e.teamId,t.teamId))||ne(t.updatedAt,e.updatedAt)}async function wn(e,t,n=200){let r=t===void 0?void 0:St(t);if(r===null)throw fe();let[{files:i},{skills:o},{agents:s}]=await Promise.all([e.listMemory(),e.listSkills(),e.listAgents()]),p=[...i.filter(u=>u.archivedAt===null).map(u=>({kind:"memory",name:u.path,teamId:u.teamId,description:"",updatedAt:u.updatedAt})),...o.filter(u=>u.archivedAt===null).map(u=>({kind:"skill",name:u.name,teamId:u.teamId,description:u.description,updatedAt:u.updatedAt})),...s.filter(u=>u.archivedAt===null).map(u=>({kind:"agent",name:u.name,teamId:u.teamId,description:u.description,updatedAt:u.updatedAt}))].sort(lo),a=new Set,c=p.filter(u=>{let h=pe(u);return a.has(h)?!1:(a.add(h),!0)}),d=de(c,u=>pe(u),r,n);if(!d)throw fe();return{resources:d.page.map(u=>({uri:pe(u),name:u.name,...u.description?{description:u.description}:{},mimeType:"text/markdown"})),...d.next===void 0?{}:{nextCursor:vt(d.next)}}}function Ct(e){return J(-32603,e instanceof b?e.code:"errors.UNKNOWN")}async function vn(e,t){let n=Qe(t);if(!n)throw J(-32002,`Unknown resource: ${t}`);let r=n.teamId??void 0;try{let i=n.kind==="memory"?(await e.readMemory(n.name,r)).content:n.kind==="skill"?(await e.getSkill(n.name,r)).body:ge(await e.getAgent(n.name,{team:r}));return{contents:[{uri:t,mimeType:"text/markdown",text:i}]}}catch(i){throw i instanceof b&&i.status===404?J(-32002,`Unknown resource: ${t}`):Ct(i)}}function Sn(e){let t=new Map;for(let n of e)n.archivedAt===null&&t.set(n.name,[...t.get(n.name)??[],n]);return[...t.values()].map(n=>n.find(r=>r.isOwn)??[...n].sort((r,i)=>ne(i.updatedAt,r.updatedAt))[0]).sort((n,r)=>ne(n.name,r.name))}async function Cn(e,t,n=200){let r=t===void 0?void 0:St(t);if(r===null)throw fe();let[{skills:i},{agents:o}]=await Promise.all([e.listSkills(),e.listAgents()]),s=[...Sn(i).map(a=>({name:Ie("skill",a.name),description:a.description})),...Sn(o).map(a=>({name:Ie("agent",a.name),description:a.description}))],p=de(s,a=>a.name,r,n);if(!p)throw fe();return{prompts:p.page.map(a=>({name:a.name,...a.description?{description:a.description}:{}})),...p.next===void 0?{}:{nextCursor:vt(p.next)}}}async function $n(e,t){let n=et(t);if(!n)throw J(-32602,`Unknown prompt: ${t}`);let r=(i,o)=>({...i?{description:i}:{},messages:[{role:"user",content:{type:"text",text:o}}]});try{if(n.kind==="skill"){let o=await e.getSkill(n.name);return r(o.description,o.body)}let i=await e.getAgent(n.name,{use:!0});return r(i.description,ge(i))}catch(i){throw i instanceof b&&i.status===404?J(-32602,`Unknown prompt: ${t}`):Ct(i)}}import{z as Wo}from"zod";import{z as $t}from"zod";var co=$t.object({name:$t.string().min(1).max(64),path:$t.string().min(1).max(200)});function An(e){return{name:"get_skill_file",description:"Delivers a single companion file of a skill from the OnlyMCP cloud, e.g. references/palette.md. Usually not needed: `npx onlymcp sync` places these files next to the SKILL.md.",inputSchema:co,async handler(t){try{let n=await e.getSkillFile(t.name,t.path);return n.encoding==="base64"?{content:[{type:"text",text:`errors.BINARY_FILE ${n.path} (${n.size} bytes) - fetch it to disk with \`npx onlymcp sync\`.`}],isError:!0}:{content:[{type:"text",text:n.content}]}}catch(n){return{content:[{type:"text",text:n instanceof b?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Tn}from"zod";var po=Tn.object({name:Tn.string().min(1).max(64)});function Pn(e,t){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:po,async handler(n){let r=`skill:${n.name}`,i=await t.get(r);if(i!==null)return{content:[{type:"text",text:i}]};try{let o=await e.getSkill(n.name);return await t.set(r,o.body),{content:[{type:"text",text:o.body}]}}catch(o){return{content:[{type:"text",text:o instanceof b?o.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as mo}from"zod";var In=mo.object({}),Y=e=>e.scope==="team"?` (team: ${e.teamName??"unknown"})`:"";function _n(e){return{name:"list_skills",description:"List every skill name available to this user. Use when a skill you need is not named in the server instructions.",inputSchema:In,async handler(){try{let{skills:t}=await e.listSkills();return{content:[{type:"text",text:t.map(n=>`${n.name}${Y(n)}`).join(`
52
- `)}]}}catch(t){return{content:[{type:"text",text:t instanceof b?t.code:"errors.UNKNOWN"}],isError:!0}}}}}function Nn(e){return{name:"list_agents",description:"List every agent available to this user, with its description. Use when this client has no agent files of its own.",inputSchema:In,async handler(){try{let{agents:t}=await e.listAgents();return{content:[{type:"text",text:t.map(r=>`${r.name}${Y(r)}: ${r.description}`).join(`
53
- `)}]}}catch(t){return{content:[{type:"text",text:t instanceof b?t.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as uo}from"node:os";import{z as Ue}from"zod";var go=Ue.object({path:Ue.string().min(3).max(256),content:Ue.string().min(1).max(1e6),ifMatch:Ue.string().max(64).optional()}),En=e=>({content:[{type:"text",text:e instanceof b?e.code:"errors.UNKNOWN"}],isError:!0});function Rn(e){return{name:"memory_append",description:"Appends text to a memory file, after a newline when the file does not end with one. A missing file is created.",inputSchema:go,async handler(t){if(!$(t.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};for(let n=0;;n+=1){let r;try{r=await e.readMemory(t.path)}catch(i){if(!(i instanceof b&&i.code==="errors.MEMORY_NOT_FOUND"))return En(i);r=null}try{let i=await e.writeMemory(t.path,r===null?t.content:tt(r.content,t.content),uo(),r===null?void 0:t.ifMatch??r.updatedAt),o=t.content.length,s=i.routedTo?` (created in team ${i.routedTo.teamName})`:"";return{content:[{type:"text",text:`Appended ${o} ${o===1?"character":"characters"} to ${t.path}.${s}`}]}}catch(i){if(i instanceof b&&i.code==="errors.MEMORY_CHANGED"&&t.ifMatch===void 0&&n===0)continue;return En(i)}}}}}import{z as re}from"zod";var fo=re.object({path:re.string().min(3).max(256),from:re.string().optional(),lines:re.string().optional()}),On=2e3;function Ln(e){let t=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache. from (first line, counted from 1) and lines (how many, 1 to 2000) return a range and the total number of lines.",inputSchema:fo,async handler(n){if(!$(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};let r=n.from!==void 0||n.lines!==void 0,i=re.coerce.number().int().min(1).safeParse(n.from??"1"),o=re.coerce.number().int().min(1).max(On).safeParse(n.lines??String(On));if(r&&(!i.success||!o.success))return{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0};try{let s=t.get(n.path);s||(s=e.readMemory(n.path).then(d=>({content:d.content,updatedAt:d.updatedAt})),t.set(n.path,s),s.finally(()=>t.delete(n.path)));let p=await s;if(!r||!i.success||!o.success)return{content:[{type:"text",text:p.content}],_meta:{updatedAt:p.updatedAt}};let a=nt(p.content,i.data,o.data);return{content:[{type:"text",text:i.data>a.totalLines?rt(i.data,a.totalLines):a.text}],_meta:{updatedAt:p.updatedAt,totalLines:a.totalLines,from:a.from,to:a.to}}}catch(s){return{content:[{type:"text",text:s instanceof b?s.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as ho}from"node:os";import{z as je}from"zod";var yo=je.object({path:je.string().min(3).max(256),content:je.string().max(1e6),ifMatch:je.string().max(64).optional()});function Mn(e){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through). When a note replaces an older one, add superseded_by: <new name> to the old file's frontmatter: search then lists it after the current one.",inputSchema:yo,async handler(t){if(!$(t.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await e.writeMemory(t.path,t.content,ho(),t.ifMatch),r=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(r+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:r}]}}catch(n){if(n instanceof b&&n.code==="errors.MEMORY_CHANGED"){let{updatedAt:i,by:o}=n.params;return{content:[{type:"text",text:`${`The file changed since you read it (at ${i??"an unknown time"}, by ${o??"a device"}). Read it again, then write.`}
54
- ${n.code} ${JSON.stringify(n.params)}`}],isError:!0}}return{content:[{type:"text",text:n instanceof b?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as A}from"zod";var D=e=>({content:[{type:"text",text:e}]}),E=e=>({content:[{type:"text",text:e}],isError:!0});function he(e){return e instanceof b?e.code:"errors.UNKNOWN"}var ze=A.string().trim().min(1).max(128).optional(),bo=A.object({query:A.string().min(1).max(200),types:A.string().max(64).optional(),limit:A.number().int().min(1).max(50).optional(),type:ze.describe("Only memory files of this metadata.type, e.g. solution, project, feedback."),project:ze.describe("Only memory files about this project."),tag:ze.describe("Only memory files carrying this tag."),expand:A.enum(["links","none"]).optional().describe("links: name the direct links of the first five hits.")});async function ko(e,t){let n=new Map;for(let r of t.slice(0,at))try{let i=await e.graphNodeByRid(r.kind,r.id),o=pt(i.neighbours,i.missing??[]);o&&n.set(`${r.kind}:${r.id}`,o)}catch{}return n}function Un(e){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each; between equally good matches the more recently changed one ranks first, and a file marked superseded_by comes after the current ones (\u2192 superseded by <name>). type, project and tag narrow it to memory files whose frontmatter says so. expand=links names, under each of the first five, what it links to and what links to it (\u2190).",inputSchema:bo,async handler(t){try{let{hits:n}=await e.searchContent(t.query,{types:t.types?.split(",").map(o=>o.trim()).filter(o=>o!==""),limit:t.limit,...t.type===void 0?{}:{type:t.type},...t.project===void 0?{}:{project:t.project},...t.tag===void 0?{}:{tag:t.tag}});if(n.length===0)return D(`Nothing found for ${t.query}`);let r=new Map;if(n.some(o=>o.teamId!==null))try{for(let o of(await e.listTeams()).teams)r.set(o.id,o.name)}catch{}let i=t.expand==="links"?await ko(e,n):new Map;return D(n.map(o=>{let s=`${o.kind} ${o.path??o.name}${Y({scope:o.scope,teamName:o.teamId===null?null:r.get(o.teamId)??null})}${st(o.supersededBy)}
55
- ${o.snippet}`,p=i.get(`${o.kind}:${o.id}`);return p?`${s}
56
- ${p}`:s}).join(`
57
- `))}catch(n){return E(he(n))}}}}var xo=A.object({scope:A.string().max(96).optional(),folder:A.string().max(256).optional().describe("Only this folder and what is under it, e.g. solutions.")});function jn(e){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it, each with its frontmatter type in brackets ([solution]). folder narrows it to one folder and what is under it.",inputSchema:xo,async handler(t){try{let n=(t.folder??"").trim().replace(/^\/+|\/+$/g,"");if(n!==""&&!$(`${n}/x.md`))return E("errors.INVALID_PATH");let r=n===""?null:`${n}/`,{nodes:i}=await e.memoryTree(t.scope??"all"),o=r===null?i:i.filter(s=>s.path.startsWith(r)||s.kind==="folder"&&s.path===n);return o.length===0?D(r===null?"(empty)":`No folder ${n}`):D(o.map(s=>{let p=s.path.split("/").length-1,a=s.kind==="folder"?`${s.name}/`:s.name,c=s.kind==="file"&&s.type?` [${s.type}]`:"";return`${" ".repeat(p)}${a}${c}${Y(s)}`}).join(`
58
- `))}catch(n){return E(he(n))}}}}var wo=A.object({from:A.string().min(3).max(256),to:A.string().min(3).max(256),updateLinks:A.boolean().optional()});function Dn(e){return`${e} ${e===1?"file":"files"}`}function zn(e){return{name:"memory_move",description:"Moves or renames a memory file. Every [[link]] that would no longer find it follows along, by name or by path, unless turned off.",inputSchema:wo,async handler(t){if(!$(t.from)||!$(t.to))return E("errors.INVALID_PATH");let n=t.updateLinks??!0;try{let r=await e.moveMemory(t.from,t.to,n);return D(`${r.from} moved to ${r.to}`+(n?`, links updated in ${Dn(r.rewritten)}, ${Dn(r.skipped)} left unchanged`:""))}catch(r){return E(he(r))}}}}var vo=A.object({path:A.string().min(3).max(256)});function Fn(e){return{name:"memory_links",description:"A memory file's [[links]], split between the ones that point somewhere and the ones that point nowhere.",inputSchema:vo,async handler(t){if(!$(t.path))return E("errors.INVALID_PATH");try{let n=await e.readMemory(t.path),{resolved:r,unresolved:i}=n.links;return r.length===0&&i.length===0?D(`${t.path} does not link to anything.`):D([r.length>0?`Resolved: ${r.join(", ")}`:"",i.length>0?`Open (no file with this name yet): ${i.join(", ")}`:""].filter(o=>o!=="").join(`
59
- `))}catch(n){return E(he(n))}}}}var So=A.object({path:A.string().min(3).max(256).describe("Path of the memory file to start from."),depth:A.number().int().min(1).max(3).optional().describe("Hops to walk, 1 to 3. Default 1."),types:A.string().max(128).optional().describe("Comma-separated node kinds to list: memory, skill, agent, mcp, tool, folder, type, project, tag, collection."),folder:A.string().max(256).optional().describe("Only memory files and folders under this folder."),project:ze.describe("Only nodes about this project (and the project itself).")});function Gn(e){return{name:"memory_graph",description:"The graph around one memory file, up to three hops. Depth 1: the files, skills, agents and servers it links to or is linked from, its folder, type, project and tags, and links that land on nothing (\u2192 links to (missing) name). From depth 2 on only links are followed, never a shared folder, type, project or tag. Start with depth 1; use 2-3 to follow links further. Grouped by depth; each line names the edge and, from depth 2, the node it was reached through. types, folder and project narrow what is listed, not the walk.",inputSchema:So,async handler(t){if(!$(t.path))return E("errors.INVALID_PATH");let n=t.depth??1,r=t.types===void 0||t.types.trim()===""?void 0:lt(t.types);if(r===null)return E(`Invalid types: ${t.types}`);let i=(t.folder??"").trim().replace(/^\/+|\/+$/g,"");if(i!==""&&!$(`${i}/x.md`))return E("errors.INVALID_PATH");try{let o=await e.readMemory(t.path);if(!o.id)return E("This server is too old for memory_graph: it does not send a file id.");let s;try{s=(await e.graphNodeByRid("memory",o.id)).node.id}catch(u){if(u instanceof b&&u.code==="errors.NODE_NOT_FOUND")return D(`${o.path} is not in the graph yet (it is added on its next save).`);throw u}let p=await e.graphAround(s,n),a={...r?{types:r}:{},...i!==""?{folder:i}:{},...t.project!==void 0?{project:t.project}:{}},c=Object.keys(a).length>0?new Set((await e.graphAround(s,n,a)).nodes.map(u=>u.id)):null,d=ot(a)?p.missing??[]:[];return D(ct({path:o.path,focus:s,depth:n,nodes:p.nodes,edges:p.edges,truncated:p.truncated,kept:c,missing:d}))}catch(o){return E(he(o))}}}}import{z as S}from"zod";var Co=e=>({content:[{type:"text",text:e}]}),Hn=e=>({content:[{type:"text",text:e}],isError:!0});async function ie(e){try{return Co(await e())}catch(t){if(t instanceof b){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return Hn(`${t.code}${n}`)}return Hn("errors.UNKNOWN")}}var ye=S.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function Fe(e,t){let{connections:n}=await e.listConnections(),r=n.filter(i=>i.slug===t);return r.find(i=>i.scope==="personal")??r[0]??null}function At(e){let t=e.authType==="none"?"no auth":`${e.authType}, secret ...${e.secretHint??"?"}`;return`${e.slug} \u2014 ${e.name} (${e.scope}, ${e.enabled?e.status:"disabled"}, ${t})
51
+ ${e.body}`}function Sn(e,t){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:mo,async handler(n){let r=`agent:${n.name}`,i=await t.get(r);if(i!==null)return{content:[{type:"text",text:i}]};try{let o=await e.getAgent(n.name,{use:!0}),s=ye(o);return await t.set(r,s),{content:[{type:"text",text:s}]}}catch(o){return{content:[{type:"text",text:o instanceof b?o.code:"errors.UNKNOWN"}],isError:!0}}}}}var ee=(e,t)=>Object.assign(new Error(t),{code:e}),At=e=>Buffer.from(e,"utf8").toString("base64url");function Tt(e){return/^[A-Za-z0-9_-]+$/.test(e)?Buffer.from(e,"base64url").toString("utf8"):null}var be=()=>ee(-32602,"Invalid cursor."),ae=(e,t)=>e<t?-1:e>t?1:0,Cn={memory:0,skill:1,agent:2};function uo(e,t){return Cn[e.kind]-Cn[t.kind]||ae(e.name,t.name)||(e.teamId===t.teamId?0:e.teamId===null?-1:t.teamId===null?1:ae(e.teamId,t.teamId))||ae(t.updatedAt,e.updatedAt)}async function $n(e,t,n=200){let r=t===void 0?void 0:Tt(t);if(r===null)throw be();let[{files:i},{skills:o},{agents:s}]=await Promise.all([e.listMemory(),e.listSkills(),e.listAgents()]),d=[...i.filter(g=>g.archivedAt===null).map(g=>({kind:"memory",name:g.path,teamId:g.teamId,description:"",updatedAt:g.updatedAt})),...o.filter(g=>g.archivedAt===null).map(g=>({kind:"skill",name:g.name,teamId:g.teamId,description:g.description,updatedAt:g.updatedAt})),...s.filter(g=>g.archivedAt===null).map(g=>({kind:"agent",name:g.name,teamId:g.teamId,description:g.description,updatedAt:g.updatedAt}))].sort(uo),a=new Set,c=d.filter(g=>{let f=ue(g);return a.has(f)?!1:(a.add(f),!0)}),p=ge(c,g=>ue(g),r,n);if(!p)throw be();return{resources:p.page.map(g=>({uri:ue(g),name:g.name,...g.description?{description:g.description}:{},mimeType:"text/markdown"})),...p.next===void 0?{}:{nextCursor:At(p.next)}}}function Pt(e){return ee(-32603,e instanceof b?e.code:"errors.UNKNOWN")}async function An(e,t){let n=nt(t);if(!n)throw ee(-32002,`Unknown resource: ${t}`);let r=n.teamId??void 0;try{let i=n.kind==="memory"?(await e.readMemory(n.name,r)).content:n.kind==="skill"?(await e.getSkill(n.name,r)).body:ye(await e.getAgent(n.name,{team:r}));return{contents:[{uri:t,mimeType:"text/markdown",text:i}]}}catch(i){throw i instanceof b&&i.status===404?ee(-32002,`Unknown resource: ${t}`):Pt(i)}}function Tn(e){let t=new Map;for(let n of e)n.archivedAt===null&&t.set(n.name,[...t.get(n.name)??[],n]);return[...t.values()].map(n=>n.find(r=>r.isOwn)??[...n].sort((r,i)=>ae(i.updatedAt,r.updatedAt))[0]).sort((n,r)=>ae(n.name,r.name))}async function Pn(e,t,n=200){let r=t===void 0?void 0:Tt(t);if(r===null)throw be();let[{skills:i},{agents:o}]=await Promise.all([e.listSkills(),e.listAgents()]),s=[...Tn(i).map(a=>({name:Ne("skill",a.name),description:a.description})),...Tn(o).map(a=>({name:Ne("agent",a.name),description:a.description}))],d=ge(s,a=>a.name,r,n);if(!d)throw be();return{prompts:d.page.map(a=>({name:a.name,...a.description?{description:a.description}:{}})),...d.next===void 0?{}:{nextCursor:At(d.next)}}}async function In(e,t){let n=rt(t);if(!n)throw ee(-32602,`Unknown prompt: ${t}`);let r=(i,o)=>({...i?{description:i}:{},messages:[{role:"user",content:{type:"text",text:o}}]});try{if(n.kind==="skill"){let o=await e.getSkill(n.name);return r(o.description,o.body)}let i=await e.getAgent(n.name,{use:!0});return r(i.description,ye(i))}catch(i){throw i instanceof b&&i.status===404?ee(-32602,`Unknown prompt: ${t}`):Pt(i)}}import{z as Jo}from"zod";import{z as It}from"zod";var go=It.object({name:It.string().min(1).max(64),path:It.string().min(1).max(200)});function _n(e){return{name:"get_skill_file",description:"Delivers a single companion file of a skill from the OnlyMCP cloud, e.g. references/palette.md. Usually not needed: `npx onlymcp sync` places these files next to the SKILL.md.",inputSchema:go,async handler(t){try{let n=await e.getSkillFile(t.name,t.path);return n.encoding==="base64"?{content:[{type:"text",text:`errors.BINARY_FILE ${n.path} (${n.size} bytes) - fetch it to disk with \`npx onlymcp sync\`.`}],isError:!0}:{content:[{type:"text",text:n.content}]}}catch(n){return{content:[{type:"text",text:n instanceof b?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Nn}from"zod";var fo=Nn.object({name:Nn.string().min(1).max(64)});function En(e,t){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:fo,async handler(n){let r=`skill:${n.name}`,i=await t.get(r);if(i!==null)return{content:[{type:"text",text:i}]};try{let o=await e.getSkill(n.name);return await t.set(r,o.body),{content:[{type:"text",text:o.body}]}}catch(o){return{content:[{type:"text",text:o instanceof b?o.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as ho}from"zod";var Rn=ho.object({}),te=e=>e.scope==="team"?` (team: ${e.teamName??"unknown"})`:"";function On(e){return{name:"list_skills",description:"List every skill name available to this user. Use when a skill you need is not named in the server instructions.",inputSchema:Rn,async handler(){try{let{skills:t}=await e.listSkills();return{content:[{type:"text",text:t.map(n=>`${n.name}${te(n)}`).join(`
52
+ `)}]}}catch(t){return{content:[{type:"text",text:t instanceof b?t.code:"errors.UNKNOWN"}],isError:!0}}}}}function Ln(e){return{name:"list_agents",description:"List every agent available to this user, with its description. Use when this client has no agent files of its own.",inputSchema:Rn,async handler(){try{let{agents:t}=await e.listAgents();return{content:[{type:"text",text:t.map(r=>`${r.name}${te(r)}: ${r.description}`).join(`
53
+ `)}]}}catch(t){return{content:[{type:"text",text:t instanceof b?t.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as yo}from"node:os";import{z as Fe}from"zod";var bo=Fe.object({path:Fe.string().min(3).max(256),content:Fe.string().min(1).max(1e6),ifMatch:Fe.string().max(64).optional()}),Mn=e=>({content:[{type:"text",text:e instanceof b?e.code:"errors.UNKNOWN"}],isError:!0});function Dn(e){return{name:"memory_append",description:"Appends text to a memory file, after a newline when the file does not end with one. A missing file is created.",inputSchema:bo,async handler(t){if(!A(t.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};for(let n=0;;n+=1){let r;try{r=await e.readMemory(t.path)}catch(i){if(!(i instanceof b&&i.code==="errors.MEMORY_NOT_FOUND"))return Mn(i);r=null}try{let i=await e.writeMemory(t.path,r===null?t.content:it(r.content,t.content),yo(),r===null?void 0:t.ifMatch??r.updatedAt),o=t.content.length,s=i.routedTo?` (created in team ${i.routedTo.teamName})`:"";return{content:[{type:"text",text:`Appended ${o} ${o===1?"character":"characters"} to ${t.path}.${s}`}]}}catch(i){if(i instanceof b&&i.code==="errors.MEMORY_CHANGED"&&t.ifMatch===void 0&&n===0)continue;return Mn(i)}}}}}import{z as le}from"zod";var ko=le.object({path:le.string().min(3).max(256),from:le.string().optional(),lines:le.string().optional()}),jn=2e3;function Un(e){let t=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache. from (first line, counted from 1) and lines (how many, 1 to 2000) return a range and the total number of lines.",inputSchema:ko,async handler(n){if(!A(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};let r=n.from!==void 0||n.lines!==void 0,i=le.coerce.number().int().min(1).safeParse(n.from??"1"),o=le.coerce.number().int().min(1).max(jn).safeParse(n.lines??String(jn));if(r&&(!i.success||!o.success))return{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0};try{let s=t.get(n.path);s||(s=e.readMemory(n.path).then(p=>({content:p.content,updatedAt:p.updatedAt})),t.set(n.path,s),s.finally(()=>t.delete(n.path)));let d=await s;if(!r||!i.success||!o.success)return{content:[{type:"text",text:d.content}],_meta:{updatedAt:d.updatedAt}};let a=ot(d.content,i.data,o.data);return{content:[{type:"text",text:i.data>a.totalLines?st(i.data,a.totalLines):a.text}],_meta:{updatedAt:d.updatedAt,totalLines:a.totalLines,from:a.from,to:a.to}}}catch(s){return{content:[{type:"text",text:s instanceof b?s.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as xo}from"node:os";import{z as Ge}from"zod";var wo=Ge.object({path:Ge.string().min(3).max(256),content:Ge.string().max(1e6),ifMatch:Ge.string().max(64).optional()});function zn(e){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through). When a note replaces an older one, add superseded_by: <new name> to the old file's frontmatter: search then lists it after the current one.",inputSchema:wo,async handler(t){if(!A(t.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await e.writeMemory(t.path,t.content,xo(),t.ifMatch),r=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(r+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:r}]}}catch(n){if(n instanceof b&&n.code==="errors.MEMORY_CHANGED"){let{updatedAt:i,by:o}=n.params;return{content:[{type:"text",text:`${`The file changed since you read it (at ${i??"an unknown time"}, by ${o??"a device"}). Read it again, then write.`}
54
+ ${n.code} ${JSON.stringify(n.params)}`}],isError:!0}}return{content:[{type:"text",text:n instanceof b?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as T}from"zod";var U=e=>({content:[{type:"text",text:e}]}),M=e=>({content:[{type:"text",text:e}],isError:!0});function ke(e){return e instanceof b?e.code:"errors.UNKNOWN"}var He=T.string().trim().min(1).max(128).optional(),vo=T.object({query:T.string().min(1).max(200),types:T.string().max(64).optional(),limit:T.number().int().min(1).max(50).optional(),type:He.describe("Only memory files of this metadata.type, e.g. solution, project, feedback."),project:He.describe("Only memory files about this project."),tag:He.describe("Only memory files carrying this tag."),expand:T.enum(["links","none"]).optional().describe("links: name the direct links of the first five hits.")});async function So(e,t){let n=new Map;for(let r of t.slice(0,pt))try{let i=await e.graphNodeByRid(r.kind,r.id),o=gt(i.neighbours,i.missing??[]);o&&n.set(`${r.kind}:${r.id}`,o)}catch{}return n}function Gn(e){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each; between equally good matches the more recently changed one ranks first, and a file marked superseded_by comes after the current ones (\u2192 superseded by <name>). type, project and tag narrow it to memory files whose frontmatter says so. expand=links names, under each of the first five, what it links to and what links to it (\u2190).",inputSchema:vo,async handler(t){try{let{hits:n}=await e.searchContent(t.query,{types:t.types?.split(",").map(o=>o.trim()).filter(o=>o!==""),limit:t.limit,...t.type===void 0?{}:{type:t.type},...t.project===void 0?{}:{project:t.project},...t.tag===void 0?{}:{tag:t.tag}});if(n.length===0)return U(`Nothing found for ${t.query}`);let r=new Map;if(n.some(o=>o.teamId!==null))try{for(let o of(await e.listTeams()).teams)r.set(o.id,o.name)}catch{}let i=t.expand==="links"?await So(e,n):new Map;return U(n.map(o=>{let s=`${o.kind} ${o.path??o.name}${te({scope:o.scope,teamName:o.teamId===null?null:r.get(o.teamId)??null})}${dt(o.supersededBy)}
55
+ ${o.snippet}`,d=i.get(`${o.kind}:${o.id}`);return d?`${s}
56
+ ${d}`:s}).join(`
57
+ `))}catch(n){return M(ke(n))}}}}var Co=T.object({scope:T.string().max(96).optional(),folder:T.string().max(256).optional().describe("Only this folder and what is under it, its full path (Memories/solutions) or its last part (solutions) when only one folder ends in it.")});function Hn(e){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it, each with its frontmatter type in brackets ([solution]). folder narrows it to one folder and what is under it.",inputSchema:Co,async handler(t){try{let n=(t.folder??"").trim().replace(/^\/+|\/+$/g,"");if(n!==""&&!A(`${n}/x.md`))return M("errors.INVALID_PATH");let{nodes:r}=await e.memoryTree(t.scope??"all"),i=n===""?null:Oe(n,Vn(r));if(i&&"error"in i)return U(i.error);let o=i?i.folder:"",s=i?`${o}/`:null,d=s===null?r:r.filter(a=>a.path.startsWith(s)||a.kind==="folder"&&a.path===o);return d.length===0?U(s===null?"(empty)":`No folder ${o}`):U((i?.note?`${i.note}
58
+ `:"")+d.map(a=>{let c=a.path.split("/").length-1,p=a.kind==="folder"?`${a.name}/`:a.name,g=a.kind==="file"&&a.type?` [${a.type}]`:"";return`${" ".repeat(c)}${p}${g}${te(a)}`}).join(`
59
+ `))}catch(n){return M(ke(n))}}}}var $o=T.object({from:T.string().min(3).max(256),to:T.string().min(3).max(256),updateLinks:T.boolean().optional()});function Fn(e){return`${e} ${e===1?"file":"files"}`}function Wn(e){return{name:"memory_move",description:"Moves or renames a memory file. Every [[link]] that would no longer find it follows along, by name or by path, unless turned off.",inputSchema:$o,async handler(t){if(!A(t.from)||!A(t.to))return M("errors.INVALID_PATH");let n=t.updateLinks??!0;try{let r=await e.moveMemory(t.from,t.to,n);return U(`${r.from} moved to ${r.to}`+(n?`, links updated in ${Fn(r.rewritten)}, ${Fn(r.skipped)} left unchanged`:""))}catch(r){return M(ke(r))}}}}var Ao=T.object({path:T.string().min(3).max(256)});function Bn(e){return{name:"memory_links",description:"A memory file's [[links]], split between the ones that point somewhere and the ones that point nowhere.",inputSchema:Ao,async handler(t){if(!A(t.path))return M("errors.INVALID_PATH");try{let n=await e.readMemory(t.path),{resolved:r,unresolved:i}=n.links;return r.length===0&&i.length===0?U(`${t.path} does not link to anything.`):U([r.length>0?`Resolved: ${r.join(", ")}`:"",i.length>0?`Open (no file with this name yet): ${i.join(", ")}`:""].filter(o=>o!=="").join(`
60
+ `))}catch(n){return M(ke(n))}}}}var To=T.object({path:T.string().min(3).max(256).describe("Path of the memory file to start from."),depth:T.number().int().min(1).max(3).optional().describe("Hops to walk, 1 to 3. Default 1."),types:T.string().max(128).optional().describe("Comma-separated node kinds to list: memory, skill, agent, mcp, tool, folder, type, project, tag, collection."),folder:T.string().max(256).optional().describe("Only memory files and folders under this folder (full path, or its last part)."),project:He.describe("Only nodes about this project (and the project itself).")});function Kn(e){return{name:"memory_graph",description:"The graph around one memory file, up to three hops. Depth 1: the files, skills, agents and servers it links to or is linked from, its folder, type, project and tags, and links that land on nothing (\u2192 links to (missing) name). From depth 2 on only links out of a file reached by a link are followed: a backlink, folder, type, project or tag is listed at depth 1 and never walked through. Pick the depth yourself; 1 is the default and usually enough, 2-3 follow a chain of links further, the files most of the previous depth links to first. Grouped by depth; each line names the edge and, from depth 2, the node it was reached through. types, folder and project narrow what is listed, not the walk.",inputSchema:To,async handler(t){if(!A(t.path))return M("errors.INVALID_PATH");let n=t.depth??1,r=t.types===void 0||t.types.trim()===""?void 0:mt(t.types);if(r===null)return M(`Invalid types: ${t.types}`);let i=(t.folder??"").trim().replace(/^\/+|\/+$/g,"");if(i!==""&&!A(`${i}/x.md`))return M("errors.INVALID_PATH");try{let o=await e.readMemory(t.path);if(!o.id)return M("This server is too old for memory_graph: it does not send a file id.");let s;try{s=(await e.graphNodeByRid("memory",o.id)).node.id}catch(f){if(f instanceof b&&f.code==="errors.NODE_NOT_FOUND")return U(`${o.path} is not in the graph yet (it is added on its next save).`);throw f}let d=i===""?null:Oe(i,Vn((await e.memoryTree("all")).nodes));if(d&&"error"in d)return U(d.error);let a=await e.graphAround(s,n),c={...r?{types:r}:{},...d?{folder:d.folder}:{},...t.project!==void 0?{project:t.project}:{}},p=Object.keys(c).length>0?new Set((await e.graphAround(s,n,c)).nodes.map(f=>f.id)):null,g=ct(c)?a.missing??[]:[];return U(ut({path:o.path,focus:s,depth:n,nodes:a.nodes,edges:a.edges,truncated:a.truncated,kept:p,missing:g}))}catch(o){return M(ke(o))}}}}function Vn(e){let t=new Set;for(let n of e){n.kind==="folder"&&t.add(n.path);let r=n.path.split("/");for(let i=1;i<r.length;i+=1)t.add(r.slice(0,i).join("/"))}return[...t]}import{z as S}from"zod";var Po=e=>({content:[{type:"text",text:e}]}),Jn=e=>({content:[{type:"text",text:e}],isError:!0});async function ce(e){try{return Po(await e())}catch(t){if(t instanceof b){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return Jn(`${t.code}${n}`)}return Jn("errors.UNKNOWN")}}var xe=S.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function We(e,t){let{connections:n}=await e.listConnections(),r=n.filter(i=>i.slug===t);return r.find(i=>i.scope==="personal")??r[0]??null}function _t(e){let t=e.authType==="none"?"no auth":`${e.authType}, secret ...${e.secretHint??"?"}`;return`${e.slug} \u2014 ${e.name} (${e.scope}, ${e.enabled?e.status:"disabled"}, ${t})
60
61
  ${e.url}${e.statusError?`
61
- last error: ${e.statusError}`:""}`}var $o=S.object({});function Wn(e){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:$o,handler:()=>ie(async()=>{let{connections:t}=await e.listConnections();return t.length===0?"No MCP servers are connected yet. Add one with connection_create.":t.map(At).join(`
62
- `)})}}var Ao=S.object({name:S.string().min(1).max(80),slug:ye,url:S.string().url().max(2e3),transport:S.enum(["http","sse"]).default("http"),authType:S.enum(["none","bearer","header"]).default("none"),authHeaderName:S.string().max(80).optional(),secret:S.string().max(4e3).optional(),teamId:S.string().max(64).optional()});function Bn(e){return{name:"connection_create",description:"Connect a remote MCP server (http or sse only - a stdio server cannot be started on somebody else's behalf). It is probed straight away. Passing a secret here puts it into this conversation; leave it out and set it in the dashboard if that matters.",inputSchema:Ao,handler:t=>ie(async()=>{let{connection:n}=await e.createConnection(t);return`Connected.
63
- ${At(n)}
62
+ last error: ${e.statusError}`:""}`}var Io=S.object({});function Yn(e){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:Io,handler:()=>ce(async()=>{let{connections:t}=await e.listConnections();return t.length===0?"No MCP servers are connected yet. Add one with connection_create.":t.map(_t).join(`
63
+ `)})}}var _o=S.object({name:S.string().min(1).max(80),slug:xe,url:S.string().url().max(2e3),transport:S.enum(["http","sse"]).default("http"),authType:S.enum(["none","bearer","header"]).default("none"),authHeaderName:S.string().max(80).optional(),secret:S.string().max(4e3).optional(),teamId:S.string().max(64).optional()});function qn(e){return{name:"connection_create",description:"Connect a remote MCP server (http or sse only - a stdio server cannot be started on somebody else's behalf). It is probed straight away. Passing a secret here puts it into this conversation; leave it out and set it in the dashboard if that matters.",inputSchema:_o,handler:t=>ce(async()=>{let{connection:n}=await e.createConnection(t);return`Connected.
64
+ ${_t(n)}
64
65
 
65
- Its tools are now available as "${n.slug}__<tool>".`})}}var To=S.object({slug:ye,name:S.string().min(1).max(80).optional(),url:S.string().url().max(2e3).optional(),transport:S.enum(["http","sse"]).optional(),authType:S.enum(["none","bearer","header"]).optional(),authHeaderName:S.string().max(80).optional(),secret:S.string().max(4e3).optional(),enabled:S.boolean().optional()});function Kn(e){return{name:"connection_update",description:"Change a connected MCP server. Only the fields you pass are touched; url, transport, authType and secret trigger a fresh probe.",inputSchema:To,handler:t=>ie(async()=>{let n=await Fe(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{slug:r,...i}=t,{connection:o}=await e.updateConnection(n.id,i);return`Updated.
66
- ${At(o)}`})}}var Po=S.object({slug:ye});function Vn(e){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:Po,handler:t=>ie(async()=>{let n=await Fe(e,t.slug);return n?(await e.deleteConnection(n.id),`Disconnected ${t.slug}.`):`Connection not found: ${t.slug}`})}}var Io=S.object({slug:ye});function Jn(e){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:Io,handler:t=>ie(async()=>{let n=await Fe(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:r}=await e.listCapabilities(n.id);return r.length===0?`${t.slug} has nothing on record yet. Its status is "${n.status}".`:r.map(i=>`${i.enabled?"[on] ":"[off]"} ${i.kind} ${i.name}${i.exposedAs?` -> ${i.exposedAs}`:""}${i.description?` \u2014 ${i.description}`:""}`).join(`
67
- `)})}}var _o=S.object({slug:ye,tool:S.string().min(1).max(200),enabled:S.boolean()});function Yn(e){return{name:"connection_tool_toggle",description:"Switch one tool of a connected server on or off. A tool that is off costs no room in any client's tool list.",inputSchema:_o,handler:t=>ie(async()=>{let n=await Fe(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:r}=await e.listCapabilities(n.id),i=r.find(o=>o.kind==="tool"&&o.name===t.tool);return i?(await e.toggleCapability(n.id,i.id,t.enabled),`${t.slug}__${i.name} is now ${t.enabled?"on":"off"}.`):`${t.slug} offers no tool called ${t.tool}.`})}}import{z as C}from"zod";var No=e=>({content:[{type:"text",text:e}]}),be=e=>({content:[{type:"text",text:e}],isError:!0});async function U(e){try{return No(await e())}catch(t){if(t instanceof b){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return be(`${t.code}${n}`)}return be("errors.UNKNOWN")}}var q=C.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),Eo=C.object({name:q,body:C.string().max(2e5)});function qn(e){return{name:"skill_write",description:"Create a skill or replace the body of an existing one. The body is the whole SKILL.md, frontmatter included.",inputSchema:Eo,handler:t=>U(async()=>{let n=await e.putSkill(t.name,t.body);return`${n.name} ${n.updatedAt}`})}}var Ro=C.object({name:q});function Zn(e){return{name:"skill_delete",description:"Delete one skill and every file that belongs to it. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Ro,handler:t=>U(async()=>(await e.deleteSkill(t.name),`Deleted skill ${t.name}`))}}var Oo=C.object({skill:q});function Xn(e){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:Oo,handler:t=>U(async()=>{let{files:n}=await e.getSkill(t.skill);return n.length===0?`${t.skill} has no companion files.`:n.map(r=>`${r.path} (${r.size} bytes, ${r.encoding})`).join(`
68
- `)})}}var Lo=C.object({skill:q,path:C.string().min(1).max(256),content:C.string().max(3e6),encoding:C.enum(["utf8","base64"]).default("utf8")});function Qn(e){return{name:"skill_file_write",description:"Create or replace one companion file of a skill. Use encoding base64 for anything that is not text.",inputSchema:Lo,handler:t=>W(t.path)?U(async()=>{let n=await e.putSkillFile(t.skill,t.path,t.content,t.encoding);return`${t.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(be("errors.INVALID_PATH"))}}var Mo=C.object({skill:q,path:C.string().min(1).max(256)});function er(e){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:Mo,handler:t=>W(t.path)?U(async()=>(await e.deleteSkillFile(t.skill,t.path),`Deleted ${t.skill}/${t.path}`)):Promise.resolve(be("errors.INVALID_PATH"))}}var Do=C.object({name:q,description:C.string().min(1).max(1e3),body:C.string().max(2e5),model:C.string().max(64).optional(),tools:C.array(C.string().max(128)).max(200).optional()});function tr(e){return{name:"agent_write",description:"Create an agent or replace an existing one. Leave model out to keep the one it already has.",inputSchema:Do,handler:t=>U(async()=>{let n=await e.getAgent(t.name).catch(()=>null),r=await e.putAgent(t.name,{description:t.description,body:t.body,model:t.model??n?.model??void 0,tools:t.tools??n?.tools??[]});return`${r.name} ${r.updatedAt}`})}}var Uo=C.object({name:q});function nr(e){return{name:"agent_delete",description:"Delete one agent. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Uo,handler:t=>U(async()=>(await e.deleteAgent(t.name),`Deleted agent ${t.name}`))}}var jo=C.object({});function rr(e){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:jo,handler:()=>U(async()=>{let{files:t}=await e.listMemory();return t.length===0?"(none)":t.map(n=>n.path+Y(n)).sort().join(`
69
- `)})}}var zo=C.object({path:C.string().min(3).max(256)});function ir(e){return{name:"memory_delete",description:"Delete one memory file. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:zo,handler:t=>$(t.path)?U(async()=>(await e.deleteMemory(t.path),`Deleted ${t.path}`)):Promise.resolve(be("errors.INVALID_PATH"))}}import{z as j}from"zod";var Ge=e=>({content:[{type:"text",text:e}]}),ke=e=>({content:[{type:"text",text:e}],isError:!0});async function Tt(e){try{return await e()}catch(t){if(t instanceof b){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return ke(`${t.code}${n}`)}return ke("errors.UNKNOWN")}}var Fo=j.object({}),or=j.enum(["memory","skill","agent"]),Go=j.object({kind:or,name:j.string().min(1).max(300),team:j.string().min(1).max(200)}),Ho=j.object({kind:or,team:j.string().min(1).max(200),name:j.string().min(1).max(300).optional(),id:j.string().uuid().optional()});async function sr(e,t){let n=t.trim(),{teams:r}=await e.listTeams(),i=r.find(s=>s.id===n);if(i)return i;let o=r.filter(s=>s.name===n);if(o.length===1)return o[0];if(o.length>1){let s=o.map(p=>p.id).sort();return ke(`Several of your teams are named "${t}": ${s.join(", ")}. Pass the id as team.
70
- errors.TEAM_AMBIGUOUS ${JSON.stringify({team:t,ids:s})}`)}return ke(`You are not in that team.
71
- errors.NOT_A_MEMBER ${JSON.stringify({team:t})}`)}var ar=e=>"content"in e;function lr(e){return{name:"list_teams",description:"List the teams this account is in, one per line: the team id, its name and your role in it.",inputSchema:Fo,handler:t=>Tt(async()=>{let{teams:n}=await e.listTeams();if(n.length===0)return Ge("(none)");let r=(i,o)=>i<o?-1:i>o?1:0;return Ge([...n].sort((i,o)=>r(i.name,o.name)||r(i.id,o.id)).map(i=>`${i.id} ${i.name} ${i.role}`).join(`
72
- `))})}}function cr(e){return{name:"team_share",description:"Move one of your own memory files, skills or agents into a team, so its members can use it. You need the right to create that kind of content in the team, the team must not hold an item of that name already, and a frozen team takes nothing new.",inputSchema:Go,handler:t=>Tt(async()=>{let n=await sr(e,t.team);return ar(n)?n:(await e.shareWithTeam(n.id,{kind:t.kind,name:t.name}),Ge(`Shared ${t.kind} ${t.name} with the team ${n.name}.`))})}}function pr(e){return{name:"team_return",description:"Take an item out of a team and back under its owner. Name one of your own items, or pass the id of any item of the team if you may delete that kind of content there. The item keeps its owner, and the return is never refused on a quota.",inputSchema:Ho,handler:t=>t.name===void 0==(t.id===void 0)?Promise.resolve(ke("Invalid arguments: pass name or id, not both.")):Tt(async()=>{let n=await sr(e,t.team);return ar(n)?n:(await e.returnFromTeam(n.id,t.name!==void 0?{kind:t.kind,name:t.name}:{kind:t.kind,id:t.id}),Ge(`Returned ${t.kind} ${t.name??t.id} from the team ${n.name}.`))})}}function dr(e,t){return[Ln(e),Mn(e),Rn(e),rr(e),ir(e),Un(e),jn(e),zn(e),Fn(e),Gn(e),_n(e),Pn(e,t),qn(e),Zn(e),Xn(e),An(e),Qn(e),er(e),Nn(e),kn(e,t),tr(e),nr(e),Wn(e),Bn(e),Kn(e),Vn(e),Jn(e),Yn(e),lr(e),cr(e),pr(e)]}function mr(e){return e.map(t=>{let n=mt[t.name];if(!n)throw new Error(`No title and annotations in the registry table for the tool ${t.name}`);return{name:t.name,title:n.title,description:t.description,inputSchema:Wo.toJSONSchema(t.inputSchema),annotations:n.annotations}})}async function ur(){let e=fn(),t=new L(e,()=>O.read()),n=new ee,r=dr(t,n),i=await(async()=>{try{let[{skills:s},{agents:p},a]=await Promise.all([t.listSkills(),t.listAgents(),t.getMe().catch(()=>({brainvaultMode:!0}))]);return xt(s.map(c=>c.name),p.map(c=>c.name),{brainvault:a.brainvaultMode!==!1})}catch{return xt([],[])}})(),o=new Bo(dt(e,Q),{capabilities:{tools:{},resources:{},prompts:{}},instructions:i});o.setRequestHandler(Xo,async()=>({tools:mr(r)})),o.setRequestHandler(Zo,async s=>wn(t,s.params?.cursor)),o.setRequestHandler(qo,async()=>({resourceTemplates:[...Pe]})),o.setRequestHandler(Qo,async s=>vn(t,s.params.uri)),o.setRequestHandler(Yo,async s=>Cn(t,s.params?.cursor)),o.setRequestHandler(Jo,async s=>$n(t,s.params.name)),o.setRequestHandler(Vo,async s=>{let p=r.find(c=>c.name===s.params.name);if(!p)return{content:[{type:"text",text:"errors.UNKNOWN_TOOL"}],isError:!0};let a=p.inputSchema.safeParse(s.params.arguments??{});return a.success?p.handler(a.data):{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0}}),Re().then(s=>{for(let p of Se())De(t,p,{ignore:s}).catch(()=>{})}).catch(()=>{}),await o.connect(new Ko)}import{readdir as es,readFile as ts,realpath as gr,stat as ns}from"node:fs/promises";import{join as rs,relative as is,resolve as os,sep as fr}from"node:path";var ss=2*1024*1024;function as(e){return e.subarray(0,8192).includes(0)}async function Z(e,t={}){let n=t.maxBytes??ss,r=await gr(os(e)),i=[];async function o(s){let p=await es(s,{withFileTypes:!0});for(let a of p){let c=rs(s,a.name);if(a.isDirectory()){if(qe(a.name))continue;await o(c);continue}let d;try{d=await gr(c)}catch{continue}if(d!==r&&!d.startsWith(r+fr))continue;let u=is(r,d).split(fr).join("/");if(Te(a.name)){i.push({absolute:d,relative:u,bytes:0,binary:!1,text:null,skip:"denied-name"});continue}let h=await ns(d);if(!h.isFile())continue;if(h.size>n){i.push({absolute:d,relative:u,bytes:h.size,binary:!1,text:null,skip:"too-large"});continue}let T=await ts(d),y=as(T);i.push({absolute:d,relative:u,bytes:h.size,binary:y,text:y?null:T.toString("utf8"),skip:null})}}return await o(r),i.sort((s,p)=>s.relative.localeCompare(p.relative)),i}import{basename as ls}from"node:path";function cs(e){let t=new Map;return{entries:e.map(r=>{t.set(r.relative,r);let i=r.skip==="too-large"?Math.max(r.bytes,2097153):r.bytes;return r.text===null?{path:r.relative,bytes:i}:{path:r.relative,bytes:i,text:r.text}}),byPath:t}}function ps(e,t){let n=new Map;for(let{path:r,...i}of e){if(t.has(r))continue;let o=n.get(r);o?o.push(i):n.set(r,[i])}return[...n].map(([r,i])=>({relative:r,hits:i}))}function ds(e,t){let n=ps(e.flagged,t);return{skipped:[...e.skipped.map(r=>({relative:r.path,reason:r.reason})),...n.map(r=>({relative:r.relative,reason:"flagged"}))],flagged:n}}function Pt(e,t,n){let{entries:r,byPath:i}=cs(e),o=new Set(n.release??[]),s=Xe(r,{kinds:[t],release:n.release,...n.collection?{collection:n.collection}:{}});return{plan:s,byPath:i,...ds(s,o)}}function ms(e,t={}){let n=t.root?ls(t.root.replace(/[/\\]+$/,"")):"",{plan:r,byPath:i,skipped:o,flagged:s}=Pt(e,"skills",{...t,collection:n}),p=r.skills.map(a=>({name:a.name,source:i.get(a.sourcePath).absolute,sourcePath:a.sourcePath,description:a.description,collection:a.collection,bytes:a.bytes,files:a.files.map(c=>({path:c.path,absolute:i.get(c.sourcePath).absolute,bytes:c.bytes,binary:c.text===void 0}))}));return{plans:p,skipped:o,noDescription:p.filter(a=>a.description==="").map(a=>a.name).sort(),flagged:s}}function us(e,t={}){let{plan:n,byPath:r,skipped:i,flagged:o}=Pt(e,"agents",t);return{plans:n.agents.map(s=>({name:s.name,source:r.get(s.sourcePath).absolute,bytes:s.bytes})),skipped:i,flagged:o}}function gs(e,t={}){let{plan:n,byPath:r,skipped:i,flagged:o}=Pt(e,"memory",t);return{plans:n.memory.map(s=>({path:s.path,source:r.get(s.sourcePath).absolute,bytes:s.bytes})),skipped:i,flagged:o}}function It(e,t={}){let n=ms(e.skills??[],{root:t.skillsRoot,release:t.release}),r=us(e.agents??[],{release:t.release}),i=gs(e.memory??[],{release:t.release});return{skills:n.plans,agents:r.plans,memory:i.plans,flagged:[...n.flagged,...r.flagged,...i.flagged],skipped:[...n.skipped,...r.skipped,...i.skipped],noDescription:n.noDescription}}import{readFile as He}from"node:fs/promises";import{hostname as fs}from"node:os";function We(e){return e instanceof b?e.code:e instanceof Error?e.message:String(e)}function _t(e){return e.skills.length+e.skills.reduce((t,n)=>t+n.files.length,0)+e.agents.length+e.memory.length}async function hr(e,t,n){let r={skills:0,skillFiles:0,agents:0,memory:0,failures:[]},i=_t(t),o=0,s=a=>n(o+=1,i,a);for(let a of t.skills){try{await e.putSkill(a.name,await He(a.source,"utf8"),{...a.description?{description:a.description}:{},sourcePath:a.sourcePath,...a.collection?{collection:a.collection}:{}}),r.skills+=1}catch(c){r.failures.push({what:`skill ${a.name}`,code:We(c)}),o+=a.files.length,s(a.name);continue}s(a.name);for(let c of a.files){try{let d=await He(c.absolute);await e.putSkillFile(a.name,c.path,c.binary?d.toString("base64"):d.toString("utf8"),c.binary?"base64":"utf8"),r.skillFiles+=1}catch(d){r.failures.push({what:`${a.name}/${c.path}`,code:We(d)})}s(`${a.name}/${c.path}`)}}for(let a of t.agents){try{let c=await He(a.source,"utf8"),d=te(c);if(!d){r.failures.push({what:`agent ${a.name}`,code:"no-frontmatter"}),s(a.name);continue}await e.putAgent(a.name,{...d,body:ce(c)}),r.agents+=1}catch(c){r.failures.push({what:`agent ${a.name}`,code:We(c)})}s(a.name)}let p=fs();for(let a of t.memory){try{await e.writeMemory(a.path,await He(a.source,"utf8"),p),r.memory+=1}catch(c){r.failures.push({what:a.path,code:We(c)})}s(a.path)}return r}function yr(e){return e.skills.length===0&&e.agents.length===0&&e.memory.length===0}function br(e){return e.skills.length+e.agents.length+e.memory.length}function Nt(e){return e.scope==="personal"&&e.isOwn&&e.archivedAt===null}async function kr(e,t,n){let r={skills:[],agents:[],memory:[]};if(n.skills){let i=new Set(t.skills.map(s=>s.name)),{skills:o}=await e.listSkills();r.skills=o.filter(s=>Nt(s)&&!i.has(s.name)).map(s=>s.name)}if(n.agents){let i=new Set(t.agents.map(s=>s.name)),{agents:o}=await e.listAgents();r.agents=o.filter(s=>Nt(s)&&!i.has(s.name)).map(s=>s.name)}if(n.memory){let i=new Set(t.memory.map(s=>s.path)),{files:o}=await e.listMemory();r.memory=o.filter(s=>Nt(s)&&!i.has(s.path)).map(s=>s.path)}return r.skills.sort(),r.agents.sort(),r.memory.sort(),r}function hs(e){return e instanceof b?e.code:e instanceof Error?e.message:String(e)}async function xr(e,t){let n={deleted:0,failures:[]},r=async(i,o,s)=>{for(let p of i)try{await s(p),n.deleted+=1}catch(a){n.failures.push({what:o(p),code:hs(a)})}};return await r(t.skills,i=>`skill ${i}`,i=>e.deleteSkill(i)),await r(t.agents,i=>`agent ${i}`,i=>e.deleteAgent(i)),await r(t.memory,i=>i,i=>e.deleteMemory(i)),n}import{mkdir as wr,writeFile as ys}from"node:fs/promises";import{dirname as bs,resolve as vr,sep as ks}from"node:path";async function Sr(e,t){let n=vr(t);await wr(n,{recursive:!0});let r={written:0,refused:[],collisions:[],failures:[]},{files:i}=await e.listMemory(),o=[...i].sort((p,a)=>p.scope===a.scope?p.path.localeCompare(a.path):p.scope==="personal"?-1:1),s=new Set;for(let p of o){if(!$(p.path)){r.refused.push(p.path);continue}let a=vr(n,...p.path.split("/"));if(!a.startsWith(n+ks)){r.refused.push(p.path);continue}if(s.has(a)){r.collisions.push(p.path);continue}try{let c=await e.readMemory(p.path);await wr(bs(a),{recursive:!0}),await ys(a,c.content,"utf8"),s.add(a),r.written+=1}catch(c){r.failures.push({what:p.path,code:c instanceof Error?c.message:String(c)})}}return r}import{mkdir as Cr,writeFile as xs}from"node:fs/promises";import{dirname as ws,resolve as $r,sep as vs}from"node:path";import{unzipSync as Ss}from"fflate";async function Ar(e,t){let n=$r(t);await Cr(n,{recursive:!0});let r={written:0,refused:[],failed:[]},i=Ss(e);for(let[o,s]of Object.entries(i)){if(o.endsWith("/"))continue;let p=o.split("/");if(o.startsWith("/")||/^[a-zA-Z]:/.test(o)||o.includes("\\")||p.some(d=>d===""||d==="."||d==="..")){r.refused.push(o);continue}let c=$r(n,...p);if(!c.startsWith(n+vs)){r.refused.push(o);continue}try{await Cr(ws(c),{recursive:!0}),await xs(c,s),r.written+=1}catch(d){r.failed.push({path:o,reason:d instanceof Error?d.message:String(d)})}}return r}var z=process.env.ONLYMCP_API_URL??"https://only-mcp.com",F=new $s().name("onlymcp").version(Q);function Rs(e,t){try{let n=new URL(e);return(n.protocol==="https:"||n.protocol==="http:")&&n.origin===t}catch{return!1}}F.command("login").description("Connect this device to OnlyMCP").action(async()=>{Lt("OnlyMCP"),f.info(`This device will register itself as: ${await Je()}`);let t=await(await fetch(`${z}/api/auth/device/code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:"onlymcp-cli"})})).json();f.info(`Code: ${t.user_code}`),f.info(t.verification_uri),console.log(await Ts.toString(t.verification_uri_complete,{type:"terminal",small:!0})),Rs(t.verification_uri_complete,new URL(z).origin)&&await As(t.verification_uri_complete).catch(()=>{});let n=Ke();n.start("Waiting for confirmation");let r=await Jt(z,t.device_code,t.interval??5);O.save(r),n.stop("Connected");let i=new L(z,()=>O.read()),o=await Nr(i),s=Er(o);s&&f.info(s),oe(`${o.skills} skills, ${o.agents} agents, ${o.files} files ready`)});async function Nr(e){let t=await Re(),n={skills:0,agents:0,files:0,kept:[],ignored:new Set,removed:0};for(let r of Se()){let i=await De(e,r,{ignore:t});n.skills+=i.skills,n.agents+=i.agents,n.files+=i.files;for(let o of i.kept)n.kept.push(`${r}/${o}`);for(let o of i.ignored)n.ignored.add(o);n.removed+=i.removed}return n}function Er(e){if(e.ignored.size===0)return null;let t=e.removed>0?`, ${e.removed} earlier stubs removed`:"";return`${e.ignored.size} left out by ${ve()}${t}`}async function Ot(e,t,n){try{await e.reportRun(t,n)}catch{}}async function Os(e){try{return await new L(z,()=>e).signOut(),null}catch(t){return t instanceof b&&t.status>0?`HTTP ${t.status}`:t instanceof Error?t.message:String(t)}}F.command("logout").description("End this device's session, then remove its login and cache").action(async()=>{let e=O.read(),t=e?await Os(e):null;if(O.clear(),await new ee().clear(),t){f.warn(`The session on the server could not be ended (${t}). It counts as a device until it expires, or until you remove it in the dashboard under Sessions and devices.`),f.success("Logged out on this device");return}f.success("Logged out")});F.command("status").description("Show whether this device is logged in").action(()=>{f.info(O.read()?"logged in":"not logged in")});F.command("sync").description("Rewrite the stub files").option("--memory <dir>","Also write memory as files into this folder").action(async e=>{let t=new L(z,()=>O.read()),n=await Nr(t);f.success(`${n.skills} skills, ${n.agents} agents, ${n.files} files`);let r=Er(n);r&&f.info(r),n.kept.length>0&&f.warn([`Left untouched, because something of your own is already there (${n.kept.length})`,...n.kept.slice(0,10).map(s=>` ${s}`),...n.kept.length>10?[` ... and ${n.kept.length-10} more`]:[]].join(`
73
- `));let i=n.skills+n.agents+n.files;if(!e.memory){await Ot(t,"sync",i);return}let o=await Sr(t,e.memory);f.success(`${o.written} memory files to ${e.memory}`),o.collisions.length>0&&f.warn(["Team files with a path an existing file of yours already has",...o.collisions.map(s=>` ${s}`)].join(`
74
- `)),o.refused.length>0&&f.warn(["Paths refused",...o.refused.map(s=>` ${s}`)].join(`
75
- `)),o.failures.length>0&&(f.error([`${o.failures.length} failed`,...o.failures.map(s=>` ${s.what} ${s.code}`)].join(`
76
- `)),process.exitCode=1),o.failures.length===0&&await Ot(t,"sync",i+o.written)});F.command("install").description("Register OnlyMCP in an MCP client").option("--client <id>","claude-code, codex or antigravity (aliases: claude, gemini, gemini-cli)").option("--all","Write every config file that already exists on this machine").option("--print","Only print, write nothing").action(e=>{let t=process.env.ONLYMCP_HOME??_r(),n=dn(t,e);function r(i){if(e.print){f.info(`${i.name} -> ${i.configPath}`),console.log(i.snippet);return}try{mn(i)==="already-present"?f.info(`${i.name} is already set up: ${i.configPath}`):f.success(`${i.name} set up: ${i.configPath}`),i.id==="claude-code"&&f.info(cn)}catch(o){f.error(o instanceof Error?o.message:String(o)),process.exitCode=1}}switch(n.kind){case"conflicting-options":f.error("Pass either --client <id> or --all, not both."),process.exitCode=2;return;case"missing-client":f.info(`Known clients: ${n.targets.map(i=>i.id).join(", ")}`),f.info("Pass --client <id>, or --all."),process.exitCode=2;return;case"unknown-client":f.error(`Unknown client. Known: ${n.targets.map(i=>i.id).join(", ")}`),process.exitCode=1;return;case"none-present-for-all":f.error("No known client is set up on this machine yet."),f.info(`Pass --client <id> to write its config anyway. Known: ${n.targets.map(i=>i.id).join(", ")}.`),process.exitCode=2;return;case"single":r(n.target);return;case"all":for(let i of n.present)r(i);n.skipped.length>0&&f.info(`Skipped, not set up on this machine: ${n.skipped.map(i=>i.id).join(", ")}`);return}});function Rt(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Be(e){return e.reduce((t,n)=>t+n.bytes,0)}function Ls(e,t){let n=e.skills.reduce((o,s)=>o+s.files.length,0),r=e.skills.filter(o=>o.files.length>0).length,i=e.skills.reduce((o,s)=>o+Be(s.files),0);if(t.skills&&f.message(`Skills ${String(e.skills.length).padStart(4)} from ${t.skills}
77
- ${String(n).padStart(4)} more files across ${r} skills ${Rt(Be(e.skills)+i)}`),t.agents&&f.message(`Agents ${String(e.agents.length).padStart(4)} from ${t.agents} ${Rt(Be(e.agents))}`),t.memory&&f.message(`Memory ${String(e.memory.length).padStart(4)} from ${t.memory} ${Rt(Be(e.memory))}`),e.skipped.length>0){let o=new Map;for(let s of e.skipped)o.set(s.reason,(o.get(s.reason)??0)+1);f.message(["Skipped",...[...o].map(([s,p])=>` ${String(p).padStart(4)} ${s}`)].join(`
78
- `))}e.noDescription.length>0&&f.warn(["Missing a description in the SKILL.md header",...e.noDescription.map(o=>` ${o}`)].join(`
79
- `)),e.flagged.length>0&&f.warn(["Held back over possible credentials (none of it left this machine)",...e.flagged.flatMap(o=>[` ${o.relative}`,...o.hits.map(s=>` line ${s.line} rule ${s.rule} ${s.excerpt}`)])].join(`
80
- `))}F.command("import").description("Bring existing local skills, agents and memory into OnlyMCP").option("--skills <dir>","Folder with skill subfolders, or a plugin cache (~/.claude/skills when no folder is named)").option("--agents <dir>","Folder with agent files (~/.claude/agents when no folder is named)").option("--memory <dir>","Folder with memory files (no default)").option("--dry-run","Only show what would be uploaded, then stop").option("--yes","Upload without asking first").option("--prune","Delete, after confirmation, what the account holds and the source no longer has").action(async e=>{let t=process.env.ONLYMCP_HOME??_r(),n=!!(e.skills||e.agents||e.memory),r={skills:n?e.skills:Ir(t,".claude","skills"),agents:n?e.agents:Ir(t,".claude","agents"),memory:e.memory};Lt("OnlyMCP Import");let i=Ke();i.start("Reading the folders");let o;try{let[a,c,d]=await Promise.all([r.skills&&R(r.skills)?Z(r.skills):Promise.resolve([]),r.agents&&R(r.agents)?Z(r.agents):Promise.resolve([]),r.memory&&R(r.memory)?Z(r.memory):Promise.resolve([])]);o=It({skills:a,agents:c,memory:d},{skillsRoot:r.skills})}catch(a){i.stop("Aborted"),f.error(a instanceof Error?a.message:String(a)),process.exitCode=1;return}i.stop("Read"),Ls(o,{skills:r.skills&&R(r.skills)?r.skills:void 0,agents:r.agents&&R(r.agents)?r.agents:void 0,memory:r.memory&&R(r.memory)?r.memory:void 0});let s=_t(o);if(s===0&&!e.prune){oe("Nothing to do.");return}if(e.dryRun&&!e.prune){oe("Nothing uploaded (--dry-run).");return}let p=new L(z,()=>O.read());try{let a=await p.getMe();f.info(`Target ${z} as ${a.email} plan ${a.plan.name}`)}catch(a){f.error(`Not logged in, or the server is unreachable (${a instanceof Error?a.message:String(a)}).`),f.info("First: npx onlymcp login"),process.exitCode=1;return}if(s>0&&!e.yes&&!e.dryRun){if(!process.stdin.isTTY){f.error("No terminal for the prompt. Run --dry-run first, then --yes."),process.exitCode=1;return}let a=await Pr({message:`Upload ${s} entries?`,initialValue:!1});if(Et(a)||!a){Tr("Cancelled. Nothing uploaded.");return}if(o.flagged.length>0){let c=await Cs({message:"Send the held-back files anyway?",options:o.flagged.map(d=>({value:d.relative,label:d.relative})),required:!1,initialValues:[]});if(Et(c)){Tr("Cancelled. Nothing uploaded.");return}if(c.length>0){let[d,u,h]=await Promise.all([r.skills&&R(r.skills)?Z(r.skills):Promise.resolve([]),r.agents&&R(r.agents)?Z(r.agents):Promise.resolve([]),r.memory&&R(r.memory)?Z(r.memory):Promise.resolve([])]);o=It({skills:d,agents:u,memory:h},{skillsRoot:r.skills,release:c})}}}if(s>0&&!e.dryRun){let a=Ke();a.start("Uploading");let c=await hr(p,o,(d,u,h)=>{a.message(`${d}/${u} ${h}`)});a.stop("Done"),f.success(`${c.skills} skills, ${c.skillFiles} skill files, ${c.agents} agents, ${c.memory} memory files`),c.failures.length>0?(f.error([`${c.failures.length} failed`,...c.failures.map(d=>` ${d.what} ${d.code}`)].join(`
81
- `)),process.exitCode=1):await Ot(p,"import",c.skills+c.skillFiles+c.agents+c.memory)}if(e.prune){let a={skills:!!(r.skills&&R(r.skills)),agents:!!(r.agents&&R(r.agents)),memory:!!(r.memory&&R(r.memory))},c=await kr(p,o,a);if(yr(c))f.info("Nothing to delete: the account holds nothing the source does not know.");else if(f.warn(["Would delete (only your own, nothing from a team, nothing archived)",...c.skills.map(d=>` Skill ${d}`),...c.agents.map(d=>` Agent ${d}`),...c.memory.map(d=>` Memory ${d}`)].join(`
82
- `)),e.dryRun)f.info("Nothing deleted (--dry-run).");else if(!process.stdin.isTTY)f.error("No terminal for the prompt. Nothing deleted."),process.exitCode=1;else{let d=await Pr({message:`Delete ${br(c)} entries in the account?`,initialValue:!1});if(Et(d)||!d)f.info("Nothing deleted.");else{let u=await xr(p,c);f.success(`${u.deleted} deleted`),u.failures.length>0&&(f.error([`${u.failures.length} failed`,...u.failures.map(h=>` ${h.what} ${h.code}`)].join(`
83
- `)),process.exitCode=1)}}}oe(e.dryRun?"Nothing changed (--dry-run).":"Then: npx onlymcp sync on every device.")});F.command("export").description("Get everything out of the account: memory, skills, agents, connections").option("--out <dir>","Unpack the archive into this folder").option("--zip <file>","Keep the archive as a file").option("--scope <scope>","personal, all or team:<id>","all").option("--types <list>","memory,skills,agents,connections").action(async e=>{if((e.out?1:0)+(e.zip?1:0)!=1){f.error("Either --out <folder> or --zip <file>, not both and not neither."),process.exitCode=1;return}Lt("OnlyMCP Export");let t=new L(z,()=>O.read()),n=Ke();n.start("Fetching the archive");let r;try{r=await t.exportArchive({scope:e.scope,types:e.types?.split(",").map(s=>s.trim()).filter(s=>s!=="")})}catch(s){n.stop("Aborted"),f.error(s instanceof Error?s.message:String(s)),f.info("Not logged in? First: npx onlymcp login"),process.exitCode=1;return}if(e.zip){Is(Es(e.zip),{recursive:!0}),await _s(Ns.fromWeb(r.body),Ps(e.zip)),n.stop("Done"),oe(`Archive: ${e.zip}`);return}let i=new Uint8Array(await r.arrayBuffer()),o=await Ar(i,e.out);n.stop("Done"),f.success(`${o.written} files in ${e.out}`),o.refused.length>0&&f.warn(["Not written, path in the archive is not allowed",...o.refused.map(s=>` ${s}`)].join(`
84
- `)),o.failed.length>0&&(f.warn(["Not written, the filename doesn't work on this system",...o.failed.map(s=>` ${s.path} ${s.reason}`),"With --zip <file> the archive stays unchanged."].join(`
85
- `)),process.exitCode=1),oe(`Restore: npx onlymcp import --skills ${e.out}/skills --agents ${e.out}/agents --memory ${e.out}/memory`)});F.command("mcp").description("Run the stdio MCP server, the process an MCP client starts").action(ur);await F.parseAsync();
66
+ Its tools are now available as "${n.slug}__<tool>".`})}}var No=S.object({slug:xe,name:S.string().min(1).max(80).optional(),url:S.string().url().max(2e3).optional(),transport:S.enum(["http","sse"]).optional(),authType:S.enum(["none","bearer","header"]).optional(),authHeaderName:S.string().max(80).optional(),secret:S.string().max(4e3).optional(),enabled:S.boolean().optional()});function Zn(e){return{name:"connection_update",description:"Change a connected MCP server. Only the fields you pass are touched; url, transport, authType and secret trigger a fresh probe.",inputSchema:No,handler:t=>ce(async()=>{let n=await We(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{slug:r,...i}=t,{connection:o}=await e.updateConnection(n.id,i);return`Updated.
67
+ ${_t(o)}`})}}var Eo=S.object({slug:xe});function Xn(e){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:Eo,handler:t=>ce(async()=>{let n=await We(e,t.slug);return n?(await e.deleteConnection(n.id),`Disconnected ${t.slug}.`):`Connection not found: ${t.slug}`})}}var Ro=S.object({slug:xe});function Qn(e){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:Ro,handler:t=>ce(async()=>{let n=await We(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:r}=await e.listCapabilities(n.id);return r.length===0?`${t.slug} has nothing on record yet. Its status is "${n.status}".`:r.map(i=>`${i.enabled?"[on] ":"[off]"} ${i.kind} ${i.name}${i.exposedAs?` -> ${i.exposedAs}`:""}${i.description?` \u2014 ${i.description}`:""}`).join(`
68
+ `)})}}var Oo=S.object({slug:xe,tool:S.string().min(1).max(200),enabled:S.boolean()});function er(e){return{name:"connection_tool_toggle",description:"Switch one tool of a connected server on or off. A tool that is off costs no room in any client's tool list.",inputSchema:Oo,handler:t=>ce(async()=>{let n=await We(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:r}=await e.listCapabilities(n.id),i=r.find(o=>o.kind==="tool"&&o.name===t.tool);return i?(await e.toggleCapability(n.id,i.id,t.enabled),`${t.slug}__${i.name} is now ${t.enabled?"on":"off"}.`):`${t.slug} offers no tool called ${t.tool}.`})}}import{z as $}from"zod";var Lo=e=>({content:[{type:"text",text:e}]}),we=e=>({content:[{type:"text",text:e}],isError:!0});async function H(e){try{return Lo(await e())}catch(t){if(t instanceof b){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return we(`${t.code}${n}`)}return we("errors.UNKNOWN")}}var ne=$.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),Mo=$.object({name:ne,body:$.string().max(2e5)});function tr(e){return{name:"skill_write",description:"Create a skill or replace the body of an existing one. The body is the whole SKILL.md, frontmatter included.",inputSchema:Mo,handler:t=>H(async()=>{let n=await e.putSkill(t.name,t.body);return`${n.name} ${n.updatedAt}`})}}var Do=$.object({name:ne});function nr(e){return{name:"skill_delete",description:"Delete one skill and every file that belongs to it. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Do,handler:t=>H(async()=>(await e.deleteSkill(t.name),`Deleted skill ${t.name}`))}}var jo=$.object({skill:ne});function rr(e){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:jo,handler:t=>H(async()=>{let{files:n}=await e.getSkill(t.skill);return n.length===0?`${t.skill} has no companion files.`:n.map(r=>`${r.path} (${r.size} bytes, ${r.encoding})`).join(`
69
+ `)})}}var Uo=$.object({skill:ne,path:$.string().min(1).max(256),content:$.string().max(3e6),encoding:$.enum(["utf8","base64"]).default("utf8")});function ir(e){return{name:"skill_file_write",description:"Create or replace one companion file of a skill. Use encoding base64 for anything that is not text.",inputSchema:Uo,handler:t=>q(t.path)?H(async()=>{let n=await e.putSkillFile(t.skill,t.path,t.content,t.encoding);return`${t.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(we("errors.INVALID_PATH"))}}var zo=$.object({skill:ne,path:$.string().min(1).max(256)});function or(e){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:zo,handler:t=>q(t.path)?H(async()=>(await e.deleteSkillFile(t.skill,t.path),`Deleted ${t.skill}/${t.path}`)):Promise.resolve(we("errors.INVALID_PATH"))}}var Fo=$.object({name:ne,description:$.string().min(1).max(1e3),body:$.string().max(2e5),model:$.string().max(64).optional(),tools:$.array($.string().max(128)).max(200).optional()});function sr(e){return{name:"agent_write",description:"Create an agent or replace an existing one. Leave model out to keep the one it already has.",inputSchema:Fo,handler:t=>H(async()=>{let n=await e.getAgent(t.name).catch(()=>null),r=await e.putAgent(t.name,{description:t.description,body:t.body,model:t.model??n?.model??void 0,tools:t.tools??n?.tools??[]});return`${r.name} ${r.updatedAt}`})}}var Go=$.object({name:ne});function ar(e){return{name:"agent_delete",description:"Delete one agent. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Go,handler:t=>H(async()=>(await e.deleteAgent(t.name),`Deleted agent ${t.name}`))}}var Ho=$.object({});function lr(e){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:Ho,handler:()=>H(async()=>{let{files:t}=await e.listMemory();return t.length===0?"(none)":t.map(n=>n.path+te(n)).sort().join(`
70
+ `)})}}var Wo=$.object({path:$.string().min(3).max(256)});function cr(e){return{name:"memory_delete",description:"Delete one memory file. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Wo,handler:t=>A(t.path)?H(async()=>(await e.deleteMemory(t.path),`Deleted ${t.path}`)):Promise.resolve(we("errors.INVALID_PATH"))}}import{z as W}from"zod";var Be=e=>({content:[{type:"text",text:e}]}),ve=e=>({content:[{type:"text",text:e}],isError:!0});async function Nt(e){try{return await e()}catch(t){if(t instanceof b){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return ve(`${t.code}${n}`)}return ve("errors.UNKNOWN")}}var Bo=W.object({}),dr=W.enum(["memory","skill","agent"]),Ko=W.object({kind:dr,name:W.string().min(1).max(300),team:W.string().min(1).max(200)}),Vo=W.object({kind:dr,team:W.string().min(1).max(200),name:W.string().min(1).max(300).optional(),id:W.string().uuid().optional()});async function pr(e,t){let n=t.trim(),{teams:r}=await e.listTeams(),i=r.find(s=>s.id===n);if(i)return i;let o=r.filter(s=>s.name===n);if(o.length===1)return o[0];if(o.length>1){let s=o.map(d=>d.id).sort();return ve(`Several of your teams are named "${t}": ${s.join(", ")}. Pass the id as team.
71
+ errors.TEAM_AMBIGUOUS ${JSON.stringify({team:t,ids:s})}`)}return ve(`You are not in that team.
72
+ errors.NOT_A_MEMBER ${JSON.stringify({team:t})}`)}var mr=e=>"content"in e;function ur(e){return{name:"list_teams",description:"List the teams this account is in, one per line: the team id, its name and your role in it.",inputSchema:Bo,handler:t=>Nt(async()=>{let{teams:n}=await e.listTeams();if(n.length===0)return Be("(none)");let r=(i,o)=>i<o?-1:i>o?1:0;return Be([...n].sort((i,o)=>r(i.name,o.name)||r(i.id,o.id)).map(i=>`${i.id} ${i.name} ${i.role}`).join(`
73
+ `))})}}function gr(e){return{name:"team_share",description:"Move one of your own memory files, skills or agents into a team, so its members can use it. You need the right to create that kind of content in the team, the team must not hold an item of that name already, and a frozen team takes nothing new.",inputSchema:Ko,handler:t=>Nt(async()=>{let n=await pr(e,t.team);return mr(n)?n:(await e.shareWithTeam(n.id,{kind:t.kind,name:t.name}),Be(`Shared ${t.kind} ${t.name} with the team ${n.name}.`))})}}function fr(e){return{name:"team_return",description:"Take an item out of a team and back under its owner. Name one of your own items, or pass the id of any item of the team if you may delete that kind of content there. The item keeps its owner, and the return is never refused on a quota.",inputSchema:Vo,handler:t=>t.name===void 0==(t.id===void 0)?Promise.resolve(ve("Invalid arguments: pass name or id, not both.")):Nt(async()=>{let n=await pr(e,t.team);return mr(n)?n:(await e.returnFromTeam(n.id,t.name!==void 0?{kind:t.kind,name:t.name}:{kind:t.kind,id:t.id}),Be(`Returned ${t.kind} ${t.name??t.id} from the team ${n.name}.`))})}}function hr(e,t){return[Un(e),zn(e),Dn(e),lr(e),cr(e),Gn(e),Hn(e),Wn(e),Bn(e),Kn(e),On(e),En(e,t),tr(e),nr(e),rr(e),_n(e),ir(e),or(e),Ln(e),Sn(e,t),sr(e),ar(e),Yn(e),qn(e),Zn(e),Xn(e),Qn(e),er(e),ur(e),gr(e),fr(e)]}function yr(e){return e.map(t=>{let n=ht[t.name];if(!n)throw new Error(`No title and annotations in the registry table for the tool ${t.name}`);return{name:t.name,title:n.title,description:t.description,inputSchema:Jo.toJSONSchema(t.inputSchema),annotations:n.annotations}})}async function br(){let e=kn(),t=new z(e,()=>j.read()),n=new oe,r=hr(t,n),i=await(async()=>{try{let[{skills:s},{agents:d},a]=await Promise.all([t.listSkills(),t.listAgents(),t.getMe().catch(()=>({brainvaultMode:!0}))]);return Ct(s.map(c=>c.name),d.map(c=>c.name),{brainvault:a.brainvaultMode!==!1})}catch{return Ct([],[])}})(),o=new Yo(ft(e,ie),{capabilities:{tools:{},resources:{},prompts:{}},instructions:i});o.setRequestHandler(ns,async()=>({tools:yr(r)})),o.setRequestHandler(ts,async s=>$n(t,s.params?.cursor)),o.setRequestHandler(es,async()=>({resourceTemplates:[..._e]})),o.setRequestHandler(rs,async s=>An(t,s.params.uri)),o.setRequestHandler(Qo,async s=>Pn(t,s.params?.cursor)),o.setRequestHandler(Xo,async s=>In(t,s.params.name)),o.setRequestHandler(Zo,async s=>{let d=r.find(c=>c.name===s.params.name);if(!d)return{content:[{type:"text",text:"errors.UNKNOWN_TOOL"}],isError:!0};let a=d.inputSchema.safeParse(s.params.arguments??{});return a.success?d.handler(a.data):{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0}}),Me().then(s=>{for(let d of $e())ze(t,d,{ignore:s}).catch(()=>{})}).catch(()=>{}),await o.connect(new qo)}import{readdir as is,readFile as os,realpath as kr,stat as ss}from"node:fs/promises";import{join as as,relative as ls,resolve as cs,sep as xr}from"node:path";var ds=2*1024*1024;function ps(e){return e.subarray(0,8192).includes(0)}async function re(e,t={}){let n=t.maxBytes??ds,r=await kr(cs(e)),i=[];async function o(s){let d=await is(s,{withFileTypes:!0});for(let a of d){let c=as(s,a.name);if(a.isDirectory()){if(Qe(a.name))continue;await o(c);continue}let p;try{p=await kr(c)}catch{continue}if(p!==r&&!p.startsWith(r+xr))continue;let g=ls(r,p).split(xr).join("/");if(Ie(a.name)){i.push({absolute:p,relative:g,bytes:0,binary:!1,text:null,skip:"denied-name"});continue}let f=await ss(p);if(!f.isFile())continue;if(f.size>n){i.push({absolute:p,relative:g,bytes:f.size,binary:!1,text:null,skip:"too-large"});continue}let C=await os(p),P=ps(C);i.push({absolute:p,relative:g,bytes:f.size,binary:P,text:P?null:C.toString("utf8"),skip:null})}}return await o(r),i.sort((s,d)=>s.relative.localeCompare(d.relative)),i}import{basename as ms}from"node:path";function us(e){let t=new Map;return{entries:e.map(r=>{t.set(r.relative,r);let i=r.skip==="too-large"?Math.max(r.bytes,2097153):r.bytes;return r.text===null?{path:r.relative,bytes:i}:{path:r.relative,bytes:i,text:r.text}}),byPath:t}}function gs(e,t){let n=new Map;for(let{path:r,...i}of e){if(t.has(r))continue;let o=n.get(r);o?o.push(i):n.set(r,[i])}return[...n].map(([r,i])=>({relative:r,hits:i}))}function fs(e,t){let n=gs(e.flagged,t);return{skipped:[...e.skipped.map(r=>({relative:r.path,reason:r.reason})),...n.map(r=>({relative:r.relative,reason:"flagged"}))],flagged:n}}function Et(e,t,n){let{entries:r,byPath:i}=us(e),o=new Set(n.release??[]),s=tt(r,{kinds:[t],release:n.release,...n.collection?{collection:n.collection}:{}});return{plan:s,byPath:i,...fs(s,o)}}function hs(e,t={}){let n=t.root?ms(t.root.replace(/[/\\]+$/,"")):"",{plan:r,byPath:i,skipped:o,flagged:s}=Et(e,"skills",{...t,collection:n}),d=r.skills.map(a=>({name:a.name,source:i.get(a.sourcePath).absolute,sourcePath:a.sourcePath,description:a.description,collection:a.collection,bytes:a.bytes,files:a.files.map(c=>({path:c.path,absolute:i.get(c.sourcePath).absolute,bytes:c.bytes,binary:c.text===void 0}))}));return{plans:d,skipped:o,noDescription:d.filter(a=>a.description==="").map(a=>a.name).sort(),flagged:s}}function ys(e,t={}){let{plan:n,byPath:r,skipped:i,flagged:o}=Et(e,"agents",t);return{plans:n.agents.map(s=>({name:s.name,source:r.get(s.sourcePath).absolute,bytes:s.bytes})),skipped:i,flagged:o}}function bs(e,t={}){let{plan:n,byPath:r,skipped:i,flagged:o}=Et(e,"memory",t);return{plans:n.memory.map(s=>({path:s.path,source:r.get(s.sourcePath).absolute,bytes:s.bytes})),skipped:i,flagged:o}}function Rt(e,t={}){let n=hs(e.skills??[],{root:t.skillsRoot,release:t.release}),r=ys(e.agents??[],{release:t.release}),i=bs(e.memory??[],{release:t.release});return{skills:n.plans,agents:r.plans,memory:i.plans,flagged:[...n.flagged,...r.flagged,...i.flagged],skipped:[...n.skipped,...r.skipped,...i.skipped],noDescription:n.noDescription}}import{readFile as Ke}from"node:fs/promises";import{hostname as ks}from"node:os";function Ve(e){return e instanceof b?e.code:e instanceof Error?e.message:String(e)}function Ot(e){return e.skills.length+e.skills.reduce((t,n)=>t+n.files.length,0)+e.agents.length+e.memory.length}async function wr(e,t,n){let r={skills:0,skillFiles:0,agents:0,memory:0,failures:[]},i=Ot(t),o=0,s=a=>n(o+=1,i,a);for(let a of t.skills){try{await e.putSkill(a.name,await Ke(a.source,"utf8"),{...a.description?{description:a.description}:{},sourcePath:a.sourcePath,...a.collection?{collection:a.collection}:{}}),r.skills+=1}catch(c){r.failures.push({what:`skill ${a.name}`,code:Ve(c)}),o+=a.files.length,s(a.name);continue}s(a.name);for(let c of a.files){try{let p=await Ke(c.absolute);await e.putSkillFile(a.name,c.path,c.binary?p.toString("base64"):p.toString("utf8"),c.binary?"base64":"utf8"),r.skillFiles+=1}catch(p){r.failures.push({what:`${a.name}/${c.path}`,code:Ve(p)})}s(`${a.name}/${c.path}`)}}for(let a of t.agents){try{let c=await Ke(a.source,"utf8"),p=se(c);if(!p){r.failures.push({what:`agent ${a.name}`,code:"no-frontmatter"}),s(a.name);continue}await e.putAgent(a.name,{...p,body:me(c)}),r.agents+=1}catch(c){r.failures.push({what:`agent ${a.name}`,code:Ve(c)})}s(a.name)}let d=ks();for(let a of t.memory){try{await e.writeMemory(a.path,await Ke(a.source,"utf8"),d),r.memory+=1}catch(c){r.failures.push({what:a.path,code:Ve(c)})}s(a.path)}return r}function vr(e){return e.skills.length===0&&e.agents.length===0&&e.memory.length===0}function Sr(e){return e.skills.length+e.agents.length+e.memory.length}function Lt(e){return e.scope==="personal"&&e.isOwn&&e.archivedAt===null}async function Cr(e,t,n){let r={skills:[],agents:[],memory:[]};if(n.skills){let i=new Set(t.skills.map(s=>s.name)),{skills:o}=await e.listSkills();r.skills=o.filter(s=>Lt(s)&&!i.has(s.name)).map(s=>s.name)}if(n.agents){let i=new Set(t.agents.map(s=>s.name)),{agents:o}=await e.listAgents();r.agents=o.filter(s=>Lt(s)&&!i.has(s.name)).map(s=>s.name)}if(n.memory){let i=new Set(t.memory.map(s=>s.path)),{files:o}=await e.listMemory();r.memory=o.filter(s=>Lt(s)&&!i.has(s.path)).map(s=>s.path)}return r.skills.sort(),r.agents.sort(),r.memory.sort(),r}function xs(e){return e instanceof b?e.code:e instanceof Error?e.message:String(e)}async function $r(e,t){let n={deleted:0,failures:[]},r=async(i,o,s)=>{for(let d of i)try{await s(d),n.deleted+=1}catch(a){n.failures.push({what:o(d),code:xs(a)})}};return await r(t.skills,i=>`skill ${i}`,i=>e.deleteSkill(i)),await r(t.agents,i=>`agent ${i}`,i=>e.deleteAgent(i)),await r(t.memory,i=>i,i=>e.deleteMemory(i)),n}import{mkdir as Ar,writeFile as ws}from"node:fs/promises";import{dirname as vs,resolve as Tr,sep as Ss}from"node:path";async function Pr(e,t){let n=Tr(t);await Ar(n,{recursive:!0});let r={written:0,refused:[],collisions:[],failures:[]},{files:i}=await e.listMemory(),o=[...i].sort((d,a)=>d.scope===a.scope?d.path.localeCompare(a.path):d.scope==="personal"?-1:1),s=new Set;for(let d of o){if(!A(d.path)){r.refused.push(d.path);continue}let a=Tr(n,...d.path.split("/"));if(!a.startsWith(n+Ss)){r.refused.push(d.path);continue}if(s.has(a)){r.collisions.push(d.path);continue}try{let c=await e.readMemory(d.path);await Ar(vs(a),{recursive:!0}),await ws(a,c.content,"utf8"),s.add(a),r.written+=1}catch(c){r.failures.push({what:d.path,code:c instanceof Error?c.message:String(c)})}}return r}import{mkdir as Ir,writeFile as Cs}from"node:fs/promises";import{dirname as $s,resolve as _r,sep as As}from"node:path";import{unzipSync as Ts}from"fflate";async function Nr(e,t){let n=_r(t);await Ir(n,{recursive:!0});let r={written:0,refused:[],failed:[]},i=Ts(e);for(let[o,s]of Object.entries(i)){if(o.endsWith("/"))continue;let d=o.split("/");if(o.startsWith("/")||/^[a-zA-Z]:/.test(o)||o.includes("\\")||d.some(p=>p===""||p==="."||p==="..")){r.refused.push(o);continue}let c=_r(n,...d);if(!c.startsWith(n+As)){r.refused.push(o);continue}try{await Ir($s(c),{recursive:!0}),await Cs(c,s),r.written+=1}catch(p){r.failed.push({path:o,reason:p instanceof Error?p.message:String(p)})}}return r}var B=process.env.ONLYMCP_API_URL??"https://only-mcp.com",K=new Is().name("onlymcp").version(ie);function Ds(e,t){try{let n=new URL(e);return(n.protocol==="https:"||n.protocol==="http:")&&n.origin===t}catch{return!1}}K.command("login").description("Connect this device to OnlyMCP").action(async()=>{Ut("OnlyMCP"),y.info(`This device will register itself as: ${await Ze()}`);let t=await(await fetch(`${B}/api/auth/device/code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:"onlymcp-cli"})})).json();y.info(`Code: ${t.user_code}`),y.info(t.verification_uri),console.log(await Ns.toString(t.verification_uri_complete,{type:"terminal",small:!0})),Ds(t.verification_uri_complete,new URL(B).origin)&&await _s(t.verification_uri_complete).catch(()=>{});let n=Ye();n.start("Waiting for confirmation");let r=await Xt(B,t.device_code,t.interval??5);j.save(r),n.stop("Connected");let i=new z(B,()=>j.read()),o=await Mr(i),s=Dr(o);s&&y.info(s),de(`${o.skills} skills, ${o.agents} agents, ${o.files} files ready`)});async function Mr(e){let t=await Me(),n={skills:0,agents:0,files:0,kept:[],ignored:new Set,removed:0};for(let r of $e()){let i=await ze(e,r,{ignore:t});n.skills+=i.skills,n.agents+=i.agents,n.files+=i.files;for(let o of i.kept)n.kept.push(`${r}/${o}`);for(let o of i.ignored)n.ignored.add(o);n.removed+=i.removed}return n}function Dr(e){if(e.ignored.size===0)return null;let t=e.removed>0?`, ${e.removed} earlier stubs removed`:"";return`${e.ignored.size} left out by ${Ce()}${t}`}async function jt(e,t,n){try{await e.reportRun(t,n)}catch{}}async function js(e){try{return await new z(B,()=>e).signOut(),null}catch(t){return t instanceof b&&t.status>0?`HTTP ${t.status}`:t instanceof Error?t.message:String(t)}}K.command("logout").description("End this device's session, then remove its login and cache").action(async()=>{let e=j.read(),t=e?await js(e):null;if(j.clear(),await new oe().clear(),t){y.warn(`The session on the server could not be ended (${t}). It counts as a device until it expires, or until you remove it in the dashboard under Sessions and devices.`),y.success("Logged out on this device");return}y.success("Logged out")});K.command("status").description("Show whether this device is logged in").action(()=>{y.info(j.read()?"logged in":"not logged in")});K.command("sync").description("Rewrite the stub files").option("--memory <dir>","Also write memory as files into this folder").action(async e=>{let t=new z(B,()=>j.read()),n=await Mr(t);y.success(`${n.skills} skills, ${n.agents} agents, ${n.files} files`);let r=Dr(n);r&&y.info(r),n.kept.length>0&&y.warn([`Left untouched, because something of your own is already there (${n.kept.length})`,...n.kept.slice(0,10).map(s=>` ${s}`),...n.kept.length>10?[` ... and ${n.kept.length-10} more`]:[]].join(`
74
+ `));let i=n.skills+n.agents+n.files;if(!e.memory){await jt(t,"sync",i);return}let o=await Pr(t,e.memory);y.success(`${o.written} memory files to ${e.memory}`),o.collisions.length>0&&y.warn(["Team files with a path an existing file of yours already has",...o.collisions.map(s=>` ${s}`)].join(`
75
+ `)),o.refused.length>0&&y.warn(["Paths refused",...o.refused.map(s=>` ${s}`)].join(`
76
+ `)),o.failures.length>0&&(y.error([`${o.failures.length} failed`,...o.failures.map(s=>` ${s.what} ${s.code}`)].join(`
77
+ `)),process.exitCode=1),o.failures.length===0&&await jt(t,"sync",i+o.written)});K.command("install").description("Register OnlyMCP in an MCP client").option("--client <id>","claude-code, codex or antigravity (aliases: claude, gemini, gemini-cli)").option("--all","Write every config file that already exists on this machine").option("--print","Only print, write nothing").action(e=>{let t=process.env.ONLYMCP_HOME??Lr(),n=fn(t,e);function r(i){if(e.print){y.info(`${i.name} -> ${i.configPath}`),console.log(i.snippet);return}try{hn(i)==="already-present"?y.info(`${i.name} is already set up: ${i.configPath}`):y.success(`${i.name} set up: ${i.configPath}`),i.id==="claude-code"&&y.info(un)}catch(o){y.error(o instanceof Error?o.message:String(o)),process.exitCode=1}}switch(n.kind){case"conflicting-options":y.error("Pass either --client <id> or --all, not both."),process.exitCode=2;return;case"missing-client":y.info(`Known clients: ${n.targets.map(i=>i.id).join(", ")}`),y.info("Pass --client <id>, or --all."),process.exitCode=2;return;case"unknown-client":y.error(`Unknown client. Known: ${n.targets.map(i=>i.id).join(", ")}`),process.exitCode=1;return;case"none-present-for-all":y.error("No known client is set up on this machine yet."),y.info(`Pass --client <id> to write its config anyway. Known: ${n.targets.map(i=>i.id).join(", ")}.`),process.exitCode=2;return;case"single":r(n.target);return;case"all":for(let i of n.present)r(i);n.skipped.length>0&&y.info(`Skipped, not set up on this machine: ${n.skipped.map(i=>i.id).join(", ")}`);return}});function Dt(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Je(e){return e.reduce((t,n)=>t+n.bytes,0)}function Us(e,t){let n=e.skills.reduce((o,s)=>o+s.files.length,0),r=e.skills.filter(o=>o.files.length>0).length,i=e.skills.reduce((o,s)=>o+Je(s.files),0);if(t.skills&&y.message(`Skills ${String(e.skills.length).padStart(4)} from ${t.skills}
78
+ ${String(n).padStart(4)} more files across ${r} skills ${Dt(Je(e.skills)+i)}`),t.agents&&y.message(`Agents ${String(e.agents.length).padStart(4)} from ${t.agents} ${Dt(Je(e.agents))}`),t.memory&&y.message(`Memory ${String(e.memory.length).padStart(4)} from ${t.memory} ${Dt(Je(e.memory))}`),e.skipped.length>0){let o=new Map;for(let s of e.skipped)o.set(s.reason,(o.get(s.reason)??0)+1);y.message(["Skipped",...[...o].map(([s,d])=>` ${String(d).padStart(4)} ${s}`)].join(`
79
+ `))}e.noDescription.length>0&&y.warn(["Missing a description in the SKILL.md header",...e.noDescription.map(o=>` ${o}`)].join(`
80
+ `)),e.flagged.length>0&&y.warn(["Held back over possible credentials (none of it left this machine)",...e.flagged.flatMap(o=>[` ${o.relative}`,...o.hits.map(s=>` line ${s.line} rule ${s.rule} ${s.excerpt}`)])].join(`
81
+ `))}K.command("import").description("Bring existing local skills, agents and memory into OnlyMCP").option("--skills <dir>","Folder with skill subfolders, or a plugin cache (~/.claude/skills when no folder is named)").option("--agents <dir>","Folder with agent files (~/.claude/agents when no folder is named)").option("--memory <dir>","Folder with memory files (no default)").option("--dry-run","Only show what would be uploaded, then stop").option("--yes","Upload without asking first").option("--prune","Delete, after confirmation, what the account holds and the source no longer has").action(async e=>{let t=process.env.ONLYMCP_HOME??Lr(),n=!!(e.skills||e.agents||e.memory),r={skills:n?e.skills:Or(t,".claude","skills"),agents:n?e.agents:Or(t,".claude","agents"),memory:e.memory};Ut("OnlyMCP Import");let i=Ye();i.start("Reading the folders");let o;try{let[a,c,p]=await Promise.all([r.skills&&D(r.skills)?re(r.skills):Promise.resolve([]),r.agents&&D(r.agents)?re(r.agents):Promise.resolve([]),r.memory&&D(r.memory)?re(r.memory):Promise.resolve([])]);o=Rt({skills:a,agents:c,memory:p},{skillsRoot:r.skills})}catch(a){i.stop("Aborted"),y.error(a instanceof Error?a.message:String(a)),process.exitCode=1;return}i.stop("Read"),Us(o,{skills:r.skills&&D(r.skills)?r.skills:void 0,agents:r.agents&&D(r.agents)?r.agents:void 0,memory:r.memory&&D(r.memory)?r.memory:void 0});let s=Ot(o);if(s===0&&!e.prune){de("Nothing to do.");return}if(e.dryRun&&!e.prune){de("Nothing uploaded (--dry-run).");return}let d=new z(B,()=>j.read());try{let a=await d.getMe();y.info(`Target ${B} as ${a.email} plan ${a.plan.name}`)}catch(a){y.error(`Not logged in, or the server is unreachable (${a instanceof Error?a.message:String(a)}).`),y.info("First: npx onlymcp login"),process.exitCode=1;return}if(s>0&&!e.yes&&!e.dryRun){if(!process.stdin.isTTY){y.error("No terminal for the prompt. Run --dry-run first, then --yes."),process.exitCode=1;return}let a=await Rr({message:`Upload ${s} entries?`,initialValue:!1});if(Mt(a)||!a){Er("Cancelled. Nothing uploaded.");return}if(o.flagged.length>0){let c=await Ps({message:"Send the held-back files anyway?",options:o.flagged.map(p=>({value:p.relative,label:p.relative})),required:!1,initialValues:[]});if(Mt(c)){Er("Cancelled. Nothing uploaded.");return}if(c.length>0){let[p,g,f]=await Promise.all([r.skills&&D(r.skills)?re(r.skills):Promise.resolve([]),r.agents&&D(r.agents)?re(r.agents):Promise.resolve([]),r.memory&&D(r.memory)?re(r.memory):Promise.resolve([])]);o=Rt({skills:p,agents:g,memory:f},{skillsRoot:r.skills,release:c})}}}if(s>0&&!e.dryRun){let a=Ye();a.start("Uploading");let c=await wr(d,o,(p,g,f)=>{a.message(`${p}/${g} ${f}`)});a.stop("Done"),y.success(`${c.skills} skills, ${c.skillFiles} skill files, ${c.agents} agents, ${c.memory} memory files`),c.failures.length>0?(y.error([`${c.failures.length} failed`,...c.failures.map(p=>` ${p.what} ${p.code}`)].join(`
82
+ `)),process.exitCode=1):await jt(d,"import",c.skills+c.skillFiles+c.agents+c.memory)}if(e.prune){let a={skills:!!(r.skills&&D(r.skills)),agents:!!(r.agents&&D(r.agents)),memory:!!(r.memory&&D(r.memory))},c=await Cr(d,o,a);if(vr(c))y.info("Nothing to delete: the account holds nothing the source does not know.");else if(y.warn(["Would delete (only your own, nothing from a team, nothing archived)",...c.skills.map(p=>` Skill ${p}`),...c.agents.map(p=>` Agent ${p}`),...c.memory.map(p=>` Memory ${p}`)].join(`
83
+ `)),e.dryRun)y.info("Nothing deleted (--dry-run).");else if(!process.stdin.isTTY)y.error("No terminal for the prompt. Nothing deleted."),process.exitCode=1;else{let p=await Rr({message:`Delete ${Sr(c)} entries in the account?`,initialValue:!1});if(Mt(p)||!p)y.info("Nothing deleted.");else{let g=await $r(d,c);y.success(`${g.deleted} deleted`),g.failures.length>0&&(y.error([`${g.failures.length} failed`,...g.failures.map(f=>` ${f.what} ${f.code}`)].join(`
84
+ `)),process.exitCode=1)}}}de(e.dryRun?"Nothing changed (--dry-run).":"Then: npx onlymcp sync on every device.")});K.command("export").description("Get everything out of the account: memory, skills, agents, connections").option("--out <dir>","Unpack the archive into this folder").option("--zip <file>","Keep the archive as a file").option("--scope <scope>","personal, all or team:<id>","all").option("--types <list>","memory,skills,agents,connections").action(async e=>{if((e.out?1:0)+(e.zip?1:0)!=1){y.error("Either --out <folder> or --zip <file>, not both and not neither."),process.exitCode=1;return}Ut("OnlyMCP Export");let t=new z(B,()=>j.read()),n=Ye();n.start("Fetching the archive");let r;try{r=await t.exportArchive({scope:e.scope,types:e.types?.split(",").map(s=>s.trim()).filter(s=>s!=="")})}catch(s){n.stop("Aborted"),y.error(s instanceof Error?s.message:String(s)),y.info("Not logged in? First: npx onlymcp login"),process.exitCode=1;return}if(e.zip){Rs(Ms(e.zip),{recursive:!0}),await Os(Ls.fromWeb(r.body),Es(e.zip)),n.stop("Done"),de(`Archive: ${e.zip}`);return}let i=new Uint8Array(await r.arrayBuffer()),o=await Nr(i,e.out);n.stop("Done"),y.success(`${o.written} files in ${e.out}`),o.refused.length>0&&y.warn(["Not written, path in the archive is not allowed",...o.refused.map(s=>` ${s}`)].join(`
85
+ `)),o.failed.length>0&&(y.warn(["Not written, the filename doesn't work on this system",...o.failed.map(s=>` ${s.path} ${s.reason}`),"With --zip <file> the archive stays unchanged."].join(`
86
+ `)),process.exitCode=1),de(`Restore: npx onlymcp import --skills ${e.out}/skills --agents ${e.out}/agents --memory ${e.out}/memory`)});K.command("mcp").description("Run the stdio MCP server, the process an MCP client starts").action(br);await K.parseAsync();
package/dist/bin/mcp.js CHANGED
@@ -1,63 +1,64 @@
1
1
  #!/usr/bin/env node
2
- import{Server as Zr}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Xr}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as Qr,GetPromptRequestSchema as eo,ListPromptsRequestSchema as to,ListResourceTemplatesRequestSchema as no,ListResourcesRequestSchema as ro,ListToolsRequestSchema as oo,ReadResourceRequestSchema as io}from"@modelcontextprotocol/sdk/types.js";import{hostname as Mn}from"node:os";import{execFile as In}from"node:child_process";import{hostname as _n}from"node:os";import{readFile as Nn}from"node:fs/promises";import{promisify as En}from"node:util";import{randomUUID as Xe}from"node:crypto";import{link as yn,mkdir as bn,readFile as xn,rename as kn,rm as vn,writeFile as Qe}from"node:fs/promises";import{basename as Sn,dirname as tt,join as wn}from"node:path";import{existsSync as hn}from"node:fs";import{homedir as Ve}from"node:os";import{join as L}from"node:path";function X(){return process.env.ONLYMCP_HOME??L(Ve(),".claude","onlymcp")}function Ke(){return process.env.ONLYMCP_HOME??Ve()}function Je(){return L(X(),"device-id")}function qe(){return L(X(),"cache")}function Ye(){return L(X(),"stub-ignore")}function Ze(){let t=[];process.env.CLAUDE_PLUGIN_ROOT&&t.push(process.env.CLAUDE_PLUGIN_ROOT);for(let e of(process.env.ONLYMCP_STUB_DIRS??"").split(":"))e&&t.push(e);for(let e of[L(Ke(),".claude"),L(Ke(),".codex")])hn(e)&&!t.includes(e)&&t.push(e);return t.length>0?t:[L(X(),"plugin")]}var Cn=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,et;function nt(){return et??=An(),et}async function he(t){try{let e=(await xn(t,"utf8")).trim().toLowerCase();return Cn.test(e)?e:null}catch{return null}}async function An(){let t=Je(),e=await he(t);if(e)return e;try{return await bn(tt(t),{recursive:!0}),await $n(t)}catch{return null}}var Tn=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function $n(t){let e=Xe(),n=wn(tt(t),`.${Sn(t)}.${process.pid}.${Xe()}.tmp`);try{await Qe(n,`${e}
3
- `,{flag:"wx",mode:384});try{return await yn(n,t),e}catch(o){let i=o.code;if(i!=="EEXIST"&&!Tn.has(i??""))throw o;if(i!=="EEXIST")try{return await Qe(t,`${e}
4
- `,{flag:"wx",mode:384}),e}catch(s){if(s.code!=="EEXIST")throw s}}let r=await he(t);return r||(await kn(n,t),await he(t)??e)}finally{await vn(n,{force:!0}).catch(()=>{})}}var Q="0.25.1";var Ln=En(In),Rn=`onlymcp-cli/${Q} (${process.platform} ${process.arch}; node ${process.versions.node})`,rt=200;async function ot(t,e){let n;try{return await Promise.race([t,new Promise(r=>{n=setTimeout(()=>r(null),e),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function Pn(){try{if(process.platform==="linux"){let t=Nn("/sys/class/dmi/id/product_version","utf8"),n=(await ot(t,rt))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let t=Ln("sysctl",["-n","hw.model"]);return(await ot(t,rt))?.stdout.trim()||null}}catch{}return null}async function On(){let t="unknown";try{t=_n()||"unknown"}catch{}let e=await Pn();return(e&&e!==t?`${t} (${e})`:t).slice(0,60)}var it=null;async function ye(){it??=await On();let t=await nt();return{"user-agent":Rn,"x-onlymcp-device":it,...t?{"x-onlymcp-device-id":t}:{}}}var p=class extends Error{constructor(n,r={},o=0){super(n);this.code=n;this.params=r;this.status=o;this.name="ApiError"}code;params;status},ee=class{constructor(e,n){this.baseUrl=e;this.token=n}baseUrl;token;async call(e,n={}){let r=this.token();if(!r)throw new p("errors.NOT_LOGGED_IN");let o=await fetch(`${this.baseUrl}${e}`,{...n,headers:{...await ye(),...n.headers??{},authorization:`Bearer ${r}`,"content-type":"application/json"}});if(o.status===204)return;let i=await o.json().catch(()=>({}));if(!o.ok)throw new p(i.code??"errors.UNKNOWN",i.params??{},o.status);return i}getMe(){return this.call("/api/me")}reportRun(e,n){return this.call("/api/devices/current/run",{method:"POST",body:JSON.stringify({kind:e,files:n}),signal:AbortSignal.timeout(5e3)})}signOut(){return this.call("/api/auth/sign-out",{method:"POST",body:"{}",signal:AbortSignal.timeout(5e3)})}listSkills(){return this.call("/api/skills")}getSkill(e,n){return this.call(`/api/skills/${encodeURIComponent(e)}${this.teamQuery(n)}`)}putSkill(e,n,r={}){return this.call(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({body:n,...r})})}skillFileUrl(e,n){let r=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(e)}/files/${r}`}getSkillFile(e,n){return this.call(this.skillFileUrl(e,n))}putSkillFile(e,n,r,o="utf8"){return this.call(this.skillFileUrl(e,n),{method:"PUT",body:JSON.stringify({content:r,encoding:o})})}listAgents(){return this.call("/api/agents")}putAgent(e,n){return this.call(`/api/agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(n)})}getAgent(e,{use:n=!1,team:r}={}){let o=[n?"use=1":null,r===void 0?null:`team=${encodeURIComponent(r)}`].filter(Boolean);return this.call(`/api/agents/${encodeURIComponent(e)}${o.length?`?${o.join("&")}`:""}`)}readMemory(e,n){return this.call(`${this.memoryUrl(e)}${this.teamQuery(n)}`)}writeMemory(e,n,r,o){return this.call(this.memoryUrl(e),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:r,...o===void 0?{}:{ifMatch:o}})})}memoryUrl(e){return`/api/memory/${e.split("/").map(encodeURIComponent).join("/")}`}teamQuery(e,n="?"){return e===void 0?"":`${n}team=${encodeURIComponent(e)}`}listMemory(){return this.call("/api/memory")}searchContent(e,n={}){let r=new URLSearchParams({q:e});n.types?.length&&r.set("types",n.types.join(",")),n.limit&&r.set("limit",String(n.limit));for(let o of["type","project","tag"])n[o]!==void 0&&r.set(o,n[o]);return this.call(`/api/search?${r.toString()}`)}graphNodeByRid(e,n){return this.call(`/api/graph/rid/${e}/${encodeURIComponent(n)}`)}graphAround(e,n,r={}){let o=new URLSearchParams({scope:"all",focus:e,depth:String(n),walk:"links"});return r.types?.length&&o.set("types",r.types.join(",")),r.folder!==void 0&&o.set("folder",r.folder),r.project!==void 0&&o.set("project",r.project),this.call(`/api/graph?${o.toString()}`)}memoryTree(e="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(e)}`)}moveMemory(e,n,r=!0,o=Mn()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:e,to:n,updateLinks:r,deviceLabel:o})})}async exportArchive(e={}){let n=this.token();if(!n)throw new p("errors.NOT_LOGGED_IN");let r=new URLSearchParams;e.scope&&r.set("scope",e.scope),e.types?.length&&r.set("types",e.types.join(","));let o=r.size>0?`?${r.toString()}`:"",i=await fetch(`${this.baseUrl}/api/export${o}`,{headers:{...await ye(),authorization:`Bearer ${n}`}});if(!i.ok){let s=await i.json().catch(()=>({}));throw new p(s.code??"errors.UNKNOWN",s.params??{},i.status)}return i}deleteMemory(e){return this.call(this.memoryUrl(e),{method:"DELETE"})}deleteSkill(e){return this.call(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"})}deleteSkillFile(e,n){return this.call(this.skillFileUrl(e,n),{method:"DELETE"})}deleteAgent(e){return this.call(`/api/agents/${encodeURIComponent(e)}`,{method:"DELETE"})}listConnections(){return this.call("/api/mcp-connections")}listTeams(){return this.call("/api/teams")}shareWithTeam(e,n){return this.call(`/api/teams/${encodeURIComponent(e)}/share`,{method:"POST",body:JSON.stringify(n)})}returnFromTeam(e,n){return this.call(`/api/teams/${encodeURIComponent(e)}/unshare`,{method:"POST",body:JSON.stringify(n)})}createConnection(e){return this.call("/api/mcp-connections",{method:"POST",body:JSON.stringify(e)})}updateConnection(e,n){return this.call(`/api/mcp-connections/${e}`,{method:"PATCH",body:JSON.stringify(n)})}deleteConnection(e){return this.call(`/api/mcp-connections/${e}`,{method:"DELETE"})}listCapabilities(e){return this.call(`/api/mcp-connections/${e}/capabilities`)}toggleCapability(e,n,r){return this.call(`/api/mcp-connections/${e}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:r})})}};var Un="https://only-mcp.com";function st(t=process.env.ONLYMCP_API_URL){if(t===void 0)return Un;let e;try{e=new URL(t).protocol}catch{}if(e!=="http:"&&e!=="https:"){let n=t.replace(/\/\/[^/@]*@/,"//***@");throw new Error(`ONLYMCP_API_URL is not a valid http(s) URL: ${JSON.stringify(n)}`)}return t}import{Entry as Dn}from"@napi-rs/keyring";function jn(t,e){let n=()=>new Dn(t,e);return{save(r){n().setPassword(r)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var at=jn("onlymcp","session-token");import te from"cacache";var zn=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),ne=class{constructor(e=qe()){this.dir=e}dir;async get(e){try{let n=await te.get(this.dir,e),r=n.metadata;return!r||r.expiresAt<=Date.now()?(await te.rm.entry(this.dir,e),null):n.data.toString("utf8")}catch{return null}}async set(e,n,r=zn){await te.put(this.dir,e,n,{metadata:{expiresAt:Date.now()+r*1e3}})}async clear(){await te.rm.all(this.dir)}};var lt=["OnlyMCP holds this user's skills, agents and memory in the cloud, identical","on every machine. The names below are names only, not content: call","get_skill(name) to load a skill before following it, and","get_agent_definition(name) for an agent. Call list_skills or list_agents for","anything not named here. Memory is live: memory_read(path) and","memory_write(path, content). All of it is writable, not just readable:","skill_write, agent_write and the matching *_delete tools; connection_create","adds another MCP server to this account.","Link with [[name]] or typed: [[skill:name]], [[agent:name]], [[mcp:slug]], [[memory:path]]."].join(" "),Gn=["Memory is a vault, not a scratch file: read MEMORY.md first, it is the index.","After finishing a task, write one solutions/sol-*.md for what was not obvious","and one entry in history/YYYY-MM-DD.md. Link related files with [[name]];","memory_links(path) says which of a file's links point nowhere yet."].join(" ");function ct(t,e,n,r){if(n.length===0)return"";let o=[];for(let l of n){let a=n.length-o.length-1,f=a>0?` (+${a} more, call ${e})`:"",h=`
2
+ import{Server as oo}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as io}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as so,GetPromptRequestSchema as ao,ListPromptsRequestSchema as lo,ListResourceTemplatesRequestSchema as co,ListResourcesRequestSchema as po,ListToolsRequestSchema as mo,ReadResourceRequestSchema as uo}from"@modelcontextprotocol/sdk/types.js";import{hostname as Wn}from"node:os";import{execFile as Mn}from"node:child_process";import{hostname as Un}from"node:os";import{readFile as Dn}from"node:fs/promises";import{promisify as jn}from"node:util";import{randomUUID as ot}from"node:crypto";import{link as An,mkdir as Tn,readFile as $n,rename as In,rm as _n,writeFile as it}from"node:fs/promises";import{basename as Nn,dirname as at,join as En}from"node:path";import{existsSync as Cn}from"node:fs";import{homedir as Qe}from"node:os";import{join as O}from"node:path";function ne(){return process.env.ONLYMCP_HOME??O(Qe(),".claude","onlymcp")}function Xe(){return process.env.ONLYMCP_HOME??Qe()}function et(){return O(ne(),"device-id")}function tt(){return O(ne(),"cache")}function nt(){return O(ne(),"stub-ignore")}function rt(){let t=[];process.env.CLAUDE_PLUGIN_ROOT&&t.push(process.env.CLAUDE_PLUGIN_ROOT);for(let e of(process.env.ONLYMCP_STUB_DIRS??"").split(":"))e&&t.push(e);for(let e of[O(Xe(),".claude"),O(Xe(),".codex")])Cn(e)&&!t.includes(e)&&t.push(e);return t.length>0?t:[O(ne(),"plugin")]}var Ln=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,st;function lt(){return st??=Rn(),st}async function Se(t){try{let e=(await $n(t,"utf8")).trim().toLowerCase();return Ln.test(e)?e:null}catch{return null}}async function Rn(){let t=et(),e=await Se(t);if(e)return e;try{return await Tn(at(t),{recursive:!0}),await On(t)}catch{return null}}var Pn=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function On(t){let e=ot(),n=En(at(t),`.${Nn(t)}.${process.pid}.${ot()}.tmp`);try{await it(n,`${e}
3
+ `,{flag:"wx",mode:384});try{return await An(n,t),e}catch(o){let i=o.code;if(i!=="EEXIST"&&!Pn.has(i??""))throw o;if(i!=="EEXIST")try{return await it(t,`${e}
4
+ `,{flag:"wx",mode:384}),e}catch(s){if(s.code!=="EEXIST")throw s}}let r=await Se(t);return r||(await In(n,t),await Se(t)??e)}finally{await _n(n,{force:!0}).catch(()=>{})}}var re="0.25.3";var zn=jn(Mn),Gn=`onlymcp-cli/${re} (${process.platform} ${process.arch}; node ${process.versions.node})`,ct=200;async function dt(t,e){let n;try{return await Promise.race([t,new Promise(r=>{n=setTimeout(()=>r(null),e),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function Fn(){try{if(process.platform==="linux"){let t=Dn("/sys/class/dmi/id/product_version","utf8"),n=(await dt(t,ct))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let t=zn("sysctl",["-n","hw.model"]);return(await dt(t,ct))?.stdout.trim()||null}}catch{}return null}async function Hn(){let t="unknown";try{t=Un()||"unknown"}catch{}let e=await Fn();return(e&&e!==t?`${t} (${e})`:t).slice(0,60)}var pt=null;async function we(){pt??=await Hn();let t=await lt();return{"user-agent":Gn,"x-onlymcp-device":pt,...t?{"x-onlymcp-device-id":t}:{}}}var m=class extends Error{constructor(n,r={},o=0){super(n);this.code=n;this.params=r;this.status=o;this.name="ApiError"}code;params;status},oe=class{constructor(e,n){this.baseUrl=e;this.token=n}baseUrl;token;async call(e,n={}){let r=this.token();if(!r)throw new m("errors.NOT_LOGGED_IN");let o=await fetch(`${this.baseUrl}${e}`,{...n,headers:{...await we(),...n.headers??{},authorization:`Bearer ${r}`,"content-type":"application/json"}});if(o.status===204)return;let i=await o.json().catch(()=>({}));if(!o.ok)throw new m(i.code??"errors.UNKNOWN",i.params??{},o.status);return i}getMe(){return this.call("/api/me")}reportRun(e,n){return this.call("/api/devices/current/run",{method:"POST",body:JSON.stringify({kind:e,files:n}),signal:AbortSignal.timeout(5e3)})}signOut(){return this.call("/api/auth/sign-out",{method:"POST",body:"{}",signal:AbortSignal.timeout(5e3)})}listSkills(){return this.call("/api/skills")}getSkill(e,n){return this.call(`/api/skills/${encodeURIComponent(e)}${this.teamQuery(n)}`)}putSkill(e,n,r={}){return this.call(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({body:n,...r})})}skillFileUrl(e,n){let r=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(e)}/files/${r}`}getSkillFile(e,n){return this.call(this.skillFileUrl(e,n))}putSkillFile(e,n,r,o="utf8"){return this.call(this.skillFileUrl(e,n),{method:"PUT",body:JSON.stringify({content:r,encoding:o})})}listAgents(){return this.call("/api/agents")}putAgent(e,n){return this.call(`/api/agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(n)})}getAgent(e,{use:n=!1,team:r}={}){let o=[n?"use=1":null,r===void 0?null:`team=${encodeURIComponent(r)}`].filter(Boolean);return this.call(`/api/agents/${encodeURIComponent(e)}${o.length?`?${o.join("&")}`:""}`)}readMemory(e,n){return this.call(`${this.memoryUrl(e)}${this.teamQuery(n)}`)}writeMemory(e,n,r,o){return this.call(this.memoryUrl(e),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:r,...o===void 0?{}:{ifMatch:o}})})}memoryUrl(e){return`/api/memory/${e.split("/").map(encodeURIComponent).join("/")}`}teamQuery(e,n="?"){return e===void 0?"":`${n}team=${encodeURIComponent(e)}`}listMemory(){return this.call("/api/memory")}searchContent(e,n={}){let r=new URLSearchParams({q:e});n.types?.length&&r.set("types",n.types.join(",")),n.limit&&r.set("limit",String(n.limit));for(let o of["type","project","tag"])n[o]!==void 0&&r.set(o,n[o]);return this.call(`/api/search?${r.toString()}`)}graphNodeByRid(e,n){return this.call(`/api/graph/rid/${e}/${encodeURIComponent(n)}`)}graphAround(e,n,r={}){let o=new URLSearchParams({scope:"all",focus:e,depth:String(n),walk:"links"});return r.types?.length&&o.set("types",r.types.join(",")),r.folder!==void 0&&o.set("folder",r.folder),r.project!==void 0&&o.set("project",r.project),this.call(`/api/graph?${o.toString()}`)}memoryTree(e="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(e)}`)}moveMemory(e,n,r=!0,o=Wn()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:e,to:n,updateLinks:r,deviceLabel:o})})}async exportArchive(e={}){let n=this.token();if(!n)throw new m("errors.NOT_LOGGED_IN");let r=new URLSearchParams;e.scope&&r.set("scope",e.scope),e.types?.length&&r.set("types",e.types.join(","));let o=r.size>0?`?${r.toString()}`:"",i=await fetch(`${this.baseUrl}/api/export${o}`,{headers:{...await we(),authorization:`Bearer ${n}`}});if(!i.ok){let s=await i.json().catch(()=>({}));throw new m(s.code??"errors.UNKNOWN",s.params??{},i.status)}return i}deleteMemory(e){return this.call(this.memoryUrl(e),{method:"DELETE"})}deleteSkill(e){return this.call(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"})}deleteSkillFile(e,n){return this.call(this.skillFileUrl(e,n),{method:"DELETE"})}deleteAgent(e){return this.call(`/api/agents/${encodeURIComponent(e)}`,{method:"DELETE"})}listConnections(){return this.call("/api/mcp-connections")}listTeams(){return this.call("/api/teams")}shareWithTeam(e,n){return this.call(`/api/teams/${encodeURIComponent(e)}/share`,{method:"POST",body:JSON.stringify(n)})}returnFromTeam(e,n){return this.call(`/api/teams/${encodeURIComponent(e)}/unshare`,{method:"POST",body:JSON.stringify(n)})}createConnection(e){return this.call("/api/mcp-connections",{method:"POST",body:JSON.stringify(e)})}updateConnection(e,n){return this.call(`/api/mcp-connections/${e}`,{method:"PATCH",body:JSON.stringify(n)})}deleteConnection(e){return this.call(`/api/mcp-connections/${e}`,{method:"DELETE"})}listCapabilities(e){return this.call(`/api/mcp-connections/${e}/capabilities`)}toggleCapability(e,n,r){return this.call(`/api/mcp-connections/${e}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:r})})}};var Bn="https://only-mcp.com";function mt(t=process.env.ONLYMCP_API_URL){if(t===void 0)return Bn;let e;try{e=new URL(t).protocol}catch{}if(e!=="http:"&&e!=="https:"){let n=t.replace(/\/\/[^/@]*@/,"//***@");throw new Error(`ONLYMCP_API_URL is not a valid http(s) URL: ${JSON.stringify(n)}`)}return t}import{Entry as Kn}from"@napi-rs/keyring";function Vn(t,e){let n=()=>new Kn(t,e);return{save(r){n().setPassword(r)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var ut=Vn("onlymcp","session-token");import ie from"cacache";var Jn=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),se=class{constructor(e=tt()){this.dir=e}dir;async get(e){try{let n=await ie.get(this.dir,e),r=n.metadata;return!r||r.expiresAt<=Date.now()?(await ie.rm.entry(this.dir,e),null):n.data.toString("utf8")}catch{return null}}async set(e,n,r=Jn){await ie.put(this.dir,e,n,{metadata:{expiresAt:Date.now()+r*1e3}})}async clear(){await ie.rm.all(this.dir)}};var ft=["OnlyMCP holds this user's skills, agents and memory in the cloud, identical","on every machine. The names below are names only, not content: call","get_skill(name) to load a skill before following it, and","get_agent_definition(name) for an agent. Call list_skills or list_agents for","anything not named here. Memory is live: memory_read(path) and","memory_write(path, content). All of it is writable, not just readable:","skill_write, agent_write and the matching *_delete tools; connection_create","adds another MCP server to this account.","Link with [[name]] or typed: [[skill:name]], [[agent:name]], [[mcp:slug]], [[memory:path]]."].join(" "),qn=["Memory is a vault, not a scratch file: read MEMORY.md first, it is the index.","After finishing a task, write one solutions/sol-*.md for what was not obvious","and one entry in history/YYYY-MM-DD.md. Link related files with [[name]];","memory_links(path) says which of a file's links point nowhere yet."].join(" ");function gt(t,e,n,r){if(n.length===0)return"";let o=[];for(let c of n){let a=n.length-o.length-1,f=a>0?` (+${a} more, call ${e})`:"",g=`
5
5
 
6
- ${t}: ${[...o,l].join(", ")}${f}`;if(r+h.length>1800)break;o.push(l)}if(o.length===0)return`
6
+ ${t}: ${[...o,c].join(", ")}${f}`;if(r+g.length>1800)break;o.push(c)}if(o.length===0)return`
7
7
 
8
8
  ${t}: call ${e}`;let i=n.length-o.length,s=i>0?` (+${i} more, call ${e})`:"";return`
9
9
 
10
- ${t}: ${o.join(", ")}${s}`}function be(t,e,n={}){let r=n.brainvault===!1?lt:`${lt} ${Gn}`,o=e.length>0?26:0;return r+=ct("Skills","list_skills",t,r.length+o),r+=ct("Agents","list_agents",e,r.length),r}var Fn=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function k(t){return Fn.test(t)&&!t.split("/").includes("..")}var Hn=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Wn=8,Bn=200;function R(t){if(t.length===0||t.length>Bn||t==="SKILL.md")return!1;let e=t.split("/");return e.length>Wn?!1:e.every(n=>Hn.test(n)&&n!==".."&&n!==".")}function re(t){if(!t.startsWith(`---
10
+ ${t}: ${o.join(", ")}${s}`}function Ce(t,e,n={}){let r=n.brainvault===!1?ft:`${ft} ${qn}`,o=e.length>0?26:0;return r+=gt("Skills","list_skills",t,r.length+o),r+=gt("Agents","list_agents",e,r.length),r}var Yn=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function k(t){return Yn.test(t)&&!t.split("/").includes("..")}var Zn=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Xn=8,Qn=200;function M(t){if(t.length===0||t.length>Qn||t==="SKILL.md")return!1;let e=t.split("/");return e.length>Xn?!1:e.every(n=>Zn.test(n)&&n!==".."&&n!==".")}function ae(t){if(!t.startsWith(`---
11
11
  `))return null;let e=t.indexOf(`
12
- ---`,3);return e<0?null:t.slice(4,e)}function G(t,e){if(!/^[a-zA-Z0-9_-]+$/.test(e))return;let n=new RegExp(`^${e}:[ \\t]*(.*)$`,"m").exec(t);if(!n)return;let o=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return o.length>0?o:void 0}var Kn={memory:"memory",skill:"skills",agent:"agents"},Vn={memory:"memory",skills:"skill",agents:"agent"};function F(t){let e=t.teamId===null?"":`?team=${encodeURIComponent(t.teamId)}`;return`onlymcp://${Kn[t.kind]}/${t.name}${e}`}var Jn=/^onlymcp:\/\/(memory|skills|agents)\/([^?]+)(?:\?team=([^&]+))?$/;function xe(t){let e=Jn.exec(t);if(!e)return null;let n=null;if(e[3]!==void 0)try{n=decodeURIComponent(e[3])}catch{return null}return{kind:Vn[e[1]],name:e[2],teamId:n}}var oe=[{uriTemplate:"onlymcp://memory/{+path}{?team}",name:"Memory file",description:"One memory file by path; ?team=<id> for a team file.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://skills/{name}{?team}",name:"Skill",description:"The SKILL.md of one skill.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://agents/{name}{?team}",name:"Agent",description:"The definition file of one agent.",mimeType:"text/markdown"}],ie=(t,e)=>`${t}__${e}`;function ke(t){let e=/^(skill|agent)__(.+)$/.exec(t);return e?{kind:e[1],name:e[2]}:null}function H(t,e,n,r){let o=0;if(n!==void 0){let l=t.findIndex(a=>e(a)===n);if(l===-1)return null;o=l+1}let i=t.slice(o,o+r),s=o+r<t.length;return{page:i,next:s&&i.length>0?e(i[i.length-1]):void 0}}function ve(t,e){return t===null||t===""?e:t.endsWith(`
12
+ ---`,3);return e<0?null:t.slice(4,e)}function B(t,e){if(!/^[a-zA-Z0-9_-]+$/.test(e))return;let n=new RegExp(`^${e}:[ \\t]*(.*)$`,"m").exec(t);if(!n)return;let o=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return o.length>0?o:void 0}var er={memory:"memory",skill:"skills",agent:"agents"},tr={memory:"memory",skills:"skill",agents:"agent"};function K(t){let e=t.teamId===null?"":`?team=${encodeURIComponent(t.teamId)}`;return`onlymcp://${er[t.kind]}/${t.name}${e}`}var nr=/^onlymcp:\/\/(memory|skills|agents)\/([^?]+)(?:\?team=([^&]+))?$/;function Ae(t){let e=nr.exec(t);if(!e)return null;let n=null;if(e[3]!==void 0)try{n=decodeURIComponent(e[3])}catch{return null}return{kind:tr[e[1]],name:e[2],teamId:n}}var le=[{uriTemplate:"onlymcp://memory/{+path}{?team}",name:"Memory file",description:"One memory file by path; ?team=<id> for a team file.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://skills/{name}{?team}",name:"Skill",description:"The SKILL.md of one skill.",mimeType:"text/markdown"},{uriTemplate:"onlymcp://agents/{name}{?team}",name:"Agent",description:"The definition file of one agent.",mimeType:"text/markdown"}],ce=(t,e)=>`${t}__${e}`;function Te(t){let e=/^(skill|agent)__(.+)$/.exec(t);return e?{kind:e[1],name:e[2]}:null}function V(t,e,n,r){let o=0;if(n!==void 0){let c=t.findIndex(a=>e(a)===n);if(c===-1)return null;o=c+1}let i=t.slice(o,o+r),s=o+r<t.length;return{page:i,next:s&&i.length>0?e(i[i.length-1]):void 0}}function $e(t,e){return t===null||t===""?e:t.endsWith(`
13
13
  `)?t+e:`${t}
14
- ${e}`}function Se(t,e,n){let r=t===""?[]:t.split(`
14
+ ${e}`}function Ie(t,e,n){let r=t===""?[]:t.split(`
15
15
  `);r.length>0&&t.endsWith(`
16
16
  `)&&r.pop();let o=r.length,i=Math.min(e+n-1,o);return{text:e>o?"":r.slice(e-1,i).join(`
17
- `),totalLines:o,from:e,to:i}}var we=(t,e)=>`No lines from ${t}: the file has ${e} ${e===1?"line":"lines"}.`;var pt=["links_to","uses_skill","uses_tool","provides"],qn=t=>pt.includes(t);function Ae(t){return t.folder!==void 0||t.project!==void 0?!1:!t.types||t.types.includes("memory")}function Te(t){return t?` \u2192 superseded by ${t}`:""}var se=40,$e=5,ae=8,mt=["memory","folder","project","type","tag","skill","collection","agent","connection","tool"],Yn={connection:"mcp"},Zn=t=>Yn[t]??t;function W(t){let e;return t.kind==="memory"&&typeof t.props.path=="string"?e=t.props.path:t.kind==="connection"&&typeof t.props.slug=="string"?e=t.props.slug:e=t.name??t.key,`${Zn(t.kind)} ${e}`}var Xn={links_to:{out:"links to",in:"linked from"},about:{out:"about",in:"also about it:"},has_type:{out:"has",in:"also of this type:"},tagged:{out:"has",in:"also tagged:"},contains:{out:"contains",in:"in"},in_collection:{out:"in collection",in:"in it:"},uses_skill:{out:"uses",in:"used by"},uses_tool:{out:"uses",in:"used by"},provides:{out:"provides",in:"provided by"}},Qn={links_to:0,uses_skill:1,uses_tool:1,provides:2,in_collection:2,contains:3},dt=t=>Qn[t]??4;function er(t,e){return Xn[t]?.[e]??`${t}${e==="in"?" (in)":""}`}var tr={out:"\u2192",in:"\u2190"};function Ie(t){let e=t.split(",").map(r=>r.trim()).filter(r=>r!=="");if(e.length===0)return null;let n=e.map(r=>r==="mcp"?"connection":r);return n.every(r=>mt.includes(r))?n:null}var Ce=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function _e(t){let{path:e,focus:n,depth:r,kept:o}=t,i=new Map(t.nodes.map(d=>[d.id,d])),s=new Map,l=(d,u)=>{let b=s.get(d)??[];b.push(u),s.set(d,b)};for(let d of t.edges)l(d.from,{other:d.to,type:d.type,direction:"out"}),l(d.to,{other:d.from,type:d.type,direction:"in"});let a=d=>{if(d===n)return 0;let u=i.get(d);if(!u)return 1/0;if(u.depth!==void 0)return u.depth;let b=(s.get(d)??[]).map(T=>T.other===n?0:i.get(T.other)?.depth??1/0);return Math.min(1/0,...b)+1},f=new Map;for(let d of t.nodes){let u=a(d.id);if(d.id===n||!Number.isFinite(u)||u<1||u>r||o&&!o.has(d.id))continue;let b=f.get(u)??[];b.push(d.id),f.set(u,b)}let h=new Map;for(let d of new Map((t.missing??[]).map(u=>[`${u.from}\0${u.target}`,u])).values()){let u=a(d.from)+1;if(!Number.isFinite(u)||u>r)continue;let b=i.get(d.from),T=u>1&&b?` (via ${W(b)})`:"",N=h.get(u)??[];N.push(` \u2192 links to (missing) ${d.target}${T}`),h.set(u,N)}let c=[],m=0;for(let d=1;d<=r;d+=1){let u=f.get(d)??[];if(u.length===0&&!h.has(d))continue;m+=u.length;let b=u.map(T=>{let N=i.get(T),We=(s.get(T)??[]).filter(w=>a(w.other)===d-1&&(d===1||qn(w.type))).sort((w,E)=>+(E.other===n)-+(w.other===n)||dt(w.type)-dt(E.type)||w.type.localeCompare(E.type)),z=We[0],Be=z?We.filter(w=>w.other===z.other).sort((w,E)=>+(w.direction==="out")-+(E.direction==="out")):[],gn=Be.length===0?"\xB7 ":`${Be.map(w=>{let E=w.direction==="out"?"in":"out";return`${tr[E]} ${er(w.type,E)}`}).join(" / ")} `,fn=d>1&&z&&i.has(z.other)?` (via ${W(i.get(z.other))})`:"";return` ${gn}${W(N)}${fn}`}).concat(h.get(d)??[]).sort();m+=h.get(d)?.length??0,c.push(`depth ${d}:`),c.push(...b.slice(0,se)),b.length>se&&c.push(` (+${b.length-se} more)`)}if(m===0)return o?`Nothing around ${e} within ${Ce(r,"hop")} matches the filter.`:`${e} is connected to nothing yet.`;let A=t.truncated?" (cut at the graph limit)":"";return[`${e}: ${Ce(m,"node")} within ${Ce(r,"hop")}${A}`,...c].join(`
18
- `)}function Ne(t,e=[]){let n=i=>i.startsWith("\u2190")?2:i.startsWith("(missing)")?1:0,r=[...new Set([...t.filter(i=>i.type==="links_to"||i.type==="uses_skill"||i.type==="uses_tool").map(i=>`${i.direction==="in"?"\u2190 ":""}${W(i.node)}`),...e.map(i=>`(missing) ${i}`)])].sort((i,s)=>n(i)-n(s)||i.localeCompare(s));if(r.length===0)return null;let o=r.length>ae?` (+${r.length-ae} more)`:"";return` \u21B3 ${r.slice(0,ae).join(", ")}${o}`}function Ee(t,e){let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new TypeError(`serverInfo: "${t}" is not an http(s) origin`);let r=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:e,websiteUrl:r,icons:[{src:`${r}/brand/connector-512.png`,mimeType:"image/png"},{src:`${r}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}var S=t=>({title:t,annotations:{title:t,readOnlyHint:!0,openWorldHint:!1}}),v=(t,e)=>({title:t,annotations:{title:t,readOnlyHint:!1,destructiveHint:e.destructive,idempotentHint:e.idempotent,openWorldHint:e.openWorld??!1}}),Le={list_memory:S("List memory files"),memory_read:S("Read a memory file"),memory_write:v("Write a memory file",{destructive:!0,idempotent:!0}),memory_append:v("Append to a memory file",{destructive:!1,idempotent:!1}),memory_delete:v("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:S("Search memory"),memory_tree:S("Show the memory tree"),memory_move:v("Move a memory file",{destructive:!1,idempotent:!1}),memory_links:S("Show memory links"),memory_graph:S("Walk the memory graph"),list_skills:S("List skills"),get_skill:S("Load a skill"),skill_write:v("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:v("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:S("List skill files"),get_skill_file:S("Read a skill file"),skill_file_write:v("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:v("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:S("List agents"),get_agent_definition:S("Load an agent definition"),agent_write:v("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:v("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:S("List connections"),connection_create:v("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:v("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:v("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:S("List a connection's tools"),connection_tool_toggle:v("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:S("Show a connection tool's schema"),connection_call:v("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0}),list_teams:S("List teams"),team_share:v("Share with a team",{destructive:!1,idempotent:!0}),team_return:v("Return from a team",{destructive:!1,idempotent:!0})};import{z as ut}from"zod";var sr=ut.object({name:ut.string().min(1).max(64)}),Re=t=>t.replace(/[\r\n]+/g," ").trim();function B(t){let e=t.model?`model: ${Re(t.model)}
17
+ `),totalLines:o,from:e,to:i}}var _e=(t,e)=>`No lines from ${t}: the file has ${e} ${e===1?"line":"lines"}.`;var yt=["links_to","uses_skill","uses_tool","provides"],Ne=t=>yt.includes(t);function Le(t){return t.folder!==void 0||t.project!==void 0?!1:!t.types||t.types.includes("memory")}function Re(t){return t?` \u2192 superseded by ${t}`:""}var de=40,Pe=5,pe=8,bt=["memory","folder","project","type","tag","skill","collection","agent","connection","tool"],rr={connection:"mcp"},or=t=>rr[t]??t;function J(t){let e;return t.kind==="memory"&&typeof t.props.path=="string"?e=t.props.path:t.kind==="connection"&&typeof t.props.slug=="string"?e=t.props.slug:e=t.name??t.key,`${or(t.kind)} ${e}`}var ir={links_to:{out:"links to",in:"linked from"},about:{out:"about",in:"also about it:"},has_type:{out:"has",in:"also of this type:"},tagged:{out:"has",in:"also tagged:"},contains:{out:"contains",in:"in"},in_collection:{out:"in collection",in:"in it:"},uses_skill:{out:"uses",in:"used by"},uses_tool:{out:"uses",in:"used by"},provides:{out:"provides",in:"provided by"}},sr={links_to:0,uses_skill:1,uses_tool:1,provides:2,in_collection:2,contains:3},ht=t=>sr[t]??4;function ar(t,e){return ir[t]?.[e]??`${t}${e==="in"?" (in)":""}`}var lr={out:"\u2192",in:"\u2190"};function Oe(t){let e=t.split(",").map(r=>r.trim()).filter(r=>r!=="");if(e.length===0)return null;let n=e.map(r=>r==="mcp"?"connection":r);return n.every(r=>bt.includes(r))?n:null}var Ee=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function Me(t){let{path:e,focus:n,depth:r,kept:o}=t,i=new Map(t.nodes.map(l=>[l.id,l])),s=new Map,c=(l,u)=>{let h=s.get(l)??[];h.push(u),s.set(l,h)};for(let l of t.edges)c(l.from,{other:l.to,type:l.type,direction:"out"}),c(l.to,{other:l.from,type:l.type,direction:"in"});let a=l=>l===n?0:i.get(l)?.depth??1/0,f=l=>(s.get(l)??[]).filter(u=>u.direction==="in"&&Ne(u.type)),g=new Set([n]);for(let l=1;l<=r;l+=1)for(let u of t.nodes)a(u.id)===l&&f(u.id).some(h=>g.has(h.other)&&a(h.other)===l-1)&&g.add(u.id);let p=l=>{let u=a(l);if(Number.isFinite(u)||!i.has(l))return u;let h=f(l).filter(w=>g.has(w.other)).map(w=>a(w.other));return Math.min(1/0,...h)+1},d=(l,u)=>(s.get(l)??[]).filter(h=>u===1?h.other===n:h.direction==="in"&&Ne(h.type)&&g.has(h.other)&&a(h.other)===u-1),C=new Map;for(let l of t.nodes){let u=p(l.id);if(l.id===n||!Number.isFinite(u)||u<1||u>r||o&&!o.has(l.id)||d(l.id,u).length===0)continue;let h=C.get(u)??[];h.push(l.id),C.set(u,h)}let $=new Map;for(let l of new Map((t.missing??[]).map(u=>[`${u.from}\0${u.target}`,u])).values()){if(!g.has(l.from))continue;let u=p(l.from)+1;if(!Number.isFinite(u)||u>r)continue;let h=i.get(l.from),w=u>1&&h?` (via ${J(h)})`:"",R=$.get(u)??[];R.push({line:` \u2192 links to (missing) ${l.target}${w}`,weight:1}),$.set(u,R)}let N=[],_=0;for(let l=1;l<=r;l+=1){let u=C.get(l)??[];if(u.length===0&&!$.has(l))continue;_+=u.length;let h=u.map(w=>{let R=i.get(w),ve=d(w,l).sort((A,P)=>+(P.other===n)-+(A.other===n)||ht(A.type)-ht(P.type)||A.type.localeCompare(P.type)),W=ve[0],Ze=W?(l===1?ve:s.get(w)??[]).filter(A=>A.other===W.other&&(l===1||Ne(A.type))).sort((A,P)=>+(A.direction==="out")-+(P.direction==="out")):[],vn=Ze.length===0?"\xB7 ":`${Ze.map(A=>{let P=A.direction==="out"?"in":"out";return`${lr[P]} ${ar(A.type,P)}`}).join(" / ")} `,Sn=l>1&&W&&i.has(W.other)?` (via ${J(i.get(W.other))})`:"",wn=l===1?1:new Set(ve.map(A=>A.other)).size;return{line:` ${vn}${J(R)}${Sn}`,weight:wn}}).concat($.get(l)??[]).sort((w,R)=>R.weight-w.weight||(w.line<R.line?-1:w.line>R.line?1:0)).map(w=>w.line);_+=$.get(l)?.length??0,N.push(`depth ${l}:`),N.push(...h.slice(0,de)),h.length>de&&N.push(` (+${h.length-de} more)`)}if(_===0)return o?`Nothing around ${e} within ${Ee(r,"hop")} matches the filter.`:`${e} is connected to nothing yet.`;let H=t.truncated?" (cut at the graph limit)":"";return[`${e}: ${Ee(_,"node")} within ${Ee(r,"hop")}${H}`,...N].join(`
18
+ `)}function Ue(t,e=[]){let n=i=>i.startsWith("\u2190")?2:i.startsWith("(missing)")?1:0,r=[...new Set([...t.filter(i=>i.type==="links_to"||i.type==="uses_skill"||i.type==="uses_tool").map(i=>`${i.direction==="in"?"\u2190 ":""}${J(i.node)}`),...e.map(i=>`(missing) ${i}`)])].sort((i,s)=>n(i)-n(s)||i.localeCompare(s));if(r.length===0)return null;let o=r.length>pe?` (+${r.length-pe} more)`:"";return` \u21B3 ${r.slice(0,pe).join(", ")}${o}`}function me(t,e){let n=[...new Set(e)].sort();if(n.includes(t))return{folder:t,note:null};let r=n.filter(s=>s.endsWith(`/${t}`));if(r.length===0){let s=t.toLowerCase();r=n.filter(c=>c.toLowerCase()===s||c.toLowerCase().endsWith(`/${s}`))}if(r.length===1)return{folder:r[0],note:`(folder ${r[0]})`};let o=s=>s.slice(0,8).join(", ")+(s.length>8?` (+${s.length-8} more)`:"");if(r.length>1)return{error:`No folder ${t}. Did you mean: ${o(r)}?`};let i=n.filter(s=>!s.includes("/"));return{error:i.length===0?`No folder ${t}. This memory has no folders yet.`:`No folder ${t}. Top-level folders: ${o(i)}.`}}function De(t,e){let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new TypeError(`serverInfo: "${t}" is not an http(s) origin`);let r=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:e,websiteUrl:r,icons:[{src:`${r}/brand/connector-512.png`,mimeType:"image/png"},{src:`${r}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}var S=t=>({title:t,annotations:{title:t,readOnlyHint:!0,openWorldHint:!1}}),v=(t,e)=>({title:t,annotations:{title:t,readOnlyHint:!1,destructiveHint:e.destructive,idempotentHint:e.idempotent,openWorldHint:e.openWorld??!1}}),je={list_memory:S("List memory files"),memory_read:S("Read a memory file"),memory_write:v("Write a memory file",{destructive:!0,idempotent:!0}),memory_append:v("Append to a memory file",{destructive:!1,idempotent:!1}),memory_delete:v("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:S("Search memory"),memory_tree:S("Show the memory tree"),memory_move:v("Move a memory file",{destructive:!1,idempotent:!1}),memory_links:S("Show memory links"),memory_graph:S("Walk the memory graph"),list_skills:S("List skills"),get_skill:S("Load a skill"),skill_write:v("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:v("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:S("List skill files"),get_skill_file:S("Read a skill file"),skill_file_write:v("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:v("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:S("List agents"),get_agent_definition:S("Load an agent definition"),agent_write:v("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:v("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:S("List connections"),connection_create:v("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:v("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:v("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:S("List a connection's tools"),connection_tool_toggle:v("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:S("Show a connection tool's schema"),connection_call:v("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0}),list_teams:S("List teams"),team_share:v("Share with a team",{destructive:!1,idempotent:!0}),team_return:v("Return from a team",{destructive:!1,idempotent:!0})};import{z as xt}from"zod";var ur=xt.object({name:xt.string().min(1).max(64)}),ze=t=>t.replace(/[\r\n]+/g," ").trim();function q(t){let e=t.model?`model: ${ze(t.model)}
19
19
  `:"";return`---
20
20
  name: ${t.name}
21
- description: ${Re(t.description??"")}
22
- ${e}tools: ${(t.tools??[]).map(Re).join(", ")}
21
+ description: ${ze(t.description??"")}
22
+ ${e}tools: ${(t.tools??[]).map(ze).join(", ")}
23
23
  ---
24
- ${t.body}`}function gt(t,e){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:sr,async handler(n){let r=`agent:${n.name}`,o=await e.get(r);if(o!==null)return{content:[{type:"text",text:o}]};try{let i=await t.getAgent(n.name,{use:!0}),s=B(i);return await e.set(r,s),{content:[{type:"text",text:s}]}}catch(i){return{content:[{type:"text",text:i instanceof p?i.code:"errors.UNKNOWN"}],isError:!0}}}}}var P=(t,e)=>Object.assign(new Error(e),{code:t}),Pe=t=>Buffer.from(t,"utf8").toString("base64url");function Oe(t){return/^[A-Za-z0-9_-]+$/.test(t)?Buffer.from(t,"base64url").toString("utf8"):null}var K=()=>P(-32602,"Invalid cursor."),U=(t,e)=>t<e?-1:t>e?1:0,ft={memory:0,skill:1,agent:2};function ar(t,e){return ft[t.kind]-ft[e.kind]||U(t.name,e.name)||(t.teamId===e.teamId?0:t.teamId===null?-1:e.teamId===null?1:U(t.teamId,e.teamId))||U(e.updatedAt,t.updatedAt)}async function ht(t,e,n=200){let r=e===void 0?void 0:Oe(e);if(r===null)throw K();let[{files:o},{skills:i},{agents:s}]=await Promise.all([t.listMemory(),t.listSkills(),t.listAgents()]),l=[...o.filter(c=>c.archivedAt===null).map(c=>({kind:"memory",name:c.path,teamId:c.teamId,description:"",updatedAt:c.updatedAt})),...i.filter(c=>c.archivedAt===null).map(c=>({kind:"skill",name:c.name,teamId:c.teamId,description:c.description,updatedAt:c.updatedAt})),...s.filter(c=>c.archivedAt===null).map(c=>({kind:"agent",name:c.name,teamId:c.teamId,description:c.description,updatedAt:c.updatedAt}))].sort(ar),a=new Set,f=l.filter(c=>{let m=F(c);return a.has(m)?!1:(a.add(m),!0)}),h=H(f,c=>F(c),r,n);if(!h)throw K();return{resources:h.page.map(c=>({uri:F(c),name:c.name,...c.description?{description:c.description}:{},mimeType:"text/markdown"})),...h.next===void 0?{}:{nextCursor:Pe(h.next)}}}function Me(t){return P(-32603,t instanceof p?t.code:"errors.UNKNOWN")}async function yt(t,e){let n=xe(e);if(!n)throw P(-32002,`Unknown resource: ${e}`);let r=n.teamId??void 0;try{let o=n.kind==="memory"?(await t.readMemory(n.name,r)).content:n.kind==="skill"?(await t.getSkill(n.name,r)).body:B(await t.getAgent(n.name,{team:r}));return{contents:[{uri:e,mimeType:"text/markdown",text:o}]}}catch(o){throw o instanceof p&&o.status===404?P(-32002,`Unknown resource: ${e}`):Me(o)}}function bt(t){let e=new Map;for(let n of t)n.archivedAt===null&&e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()].map(n=>n.find(r=>r.isOwn)??[...n].sort((r,o)=>U(o.updatedAt,r.updatedAt))[0]).sort((n,r)=>U(n.name,r.name))}async function xt(t,e,n=200){let r=e===void 0?void 0:Oe(e);if(r===null)throw K();let[{skills:o},{agents:i}]=await Promise.all([t.listSkills(),t.listAgents()]),s=[...bt(o).map(a=>({name:ie("skill",a.name),description:a.description})),...bt(i).map(a=>({name:ie("agent",a.name),description:a.description}))],l=H(s,a=>a.name,r,n);if(!l)throw K();return{prompts:l.page.map(a=>({name:a.name,...a.description?{description:a.description}:{}})),...l.next===void 0?{}:{nextCursor:Pe(l.next)}}}async function kt(t,e){let n=ke(e);if(!n)throw P(-32602,`Unknown prompt: ${e}`);let r=(o,i)=>({...o?{description:o}:{},messages:[{role:"user",content:{type:"text",text:i}}]});try{if(n.kind==="skill"){let i=await t.getSkill(n.name);return r(i.description,i.body)}let o=await t.getAgent(n.name,{use:!0});return r(o.description,B(o))}catch(o){throw o instanceof p&&o.status===404?P(-32602,`Unknown prompt: ${e}`):Me(o)}}import{access as pr,mkdir as De,readFile as mr,rm as St,writeFile as le}from"node:fs/promises";import{dirname as ur,join as V}from"node:path";import{readFile as lr}from"node:fs/promises";var Ue=()=>!1;function cr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dr(t){let e=t.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(cr).join(".*")}$`));return n=>e.some(r=>r.test(n))}async function vt(t=Ye()){try{return dr(await lr(t,"utf8"))}catch(e){if(e.code==="ENOENT")return Ue;throw e}}var gr=/^[a-z0-9]+(-[a-z0-9]+)*$/,fr=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,je="x-onlymcp-stub";function ce(t){return t.replace(/:/g,"-")}function de(t){return(t??"").replace(/[\r\n]+/g," ").trim()}async function ze(t,e){let n;try{n=await mr(t,"utf8")}catch{return!0}let r=re(n);if(r===null||G(r,je)!=="true")return!1;let o=G(r,"x-onlymcp-name");return o===void 0||o===e}async function wt(t,e){return await pr(t).then(()=>!0,()=>!1)&&await ze(t,e)}async function Ct(t,e,n={}){let r=n.ignore??Ue,[{skills:o},{agents:i}]=await Promise.all([t.listSkills(),t.listAgents()]),s=0,l=0,a=[],f=[],h=0;for(let m of o){if(!fr.test(m.name))continue;let A=V(e,"skills",ce(m.name)),d=V(A,"SKILL.md");if(r(m.name)||r(ce(m.name))){f.push(m.name),await wt(d,m.name)&&(await St(A,{recursive:!0,force:!0}),h+=1);continue}if(!await ze(d,m.name)){a.push(`skills/${ce(m.name)}`);continue}await De(A,{recursive:!0}),await le(d,`---
25
- name: ${ce(m.name)}
26
- description: ${de(m.description)||"Synchronisiert ueber OnlyMCP. Inhalt wird bei Bedarf geladen."}
27
- ${je}: true
28
- x-onlymcp-name: ${m.name}
24
+ ${t.body}`}function kt(t,e){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:ur,async handler(n){let r=`agent:${n.name}`,o=await e.get(r);if(o!==null)return{content:[{type:"text",text:o}]};try{let i=await t.getAgent(n.name,{use:!0}),s=q(i);return await e.set(r,s),{content:[{type:"text",text:s}]}}catch(i){return{content:[{type:"text",text:i instanceof m?i.code:"errors.UNKNOWN"}],isError:!0}}}}}var U=(t,e)=>Object.assign(new Error(e),{code:t}),Ge=t=>Buffer.from(t,"utf8").toString("base64url");function Fe(t){return/^[A-Za-z0-9_-]+$/.test(t)?Buffer.from(t,"base64url").toString("utf8"):null}var Y=()=>U(-32602,"Invalid cursor."),z=(t,e)=>t<e?-1:t>e?1:0,vt={memory:0,skill:1,agent:2};function fr(t,e){return vt[t.kind]-vt[e.kind]||z(t.name,e.name)||(t.teamId===e.teamId?0:t.teamId===null?-1:e.teamId===null?1:z(t.teamId,e.teamId))||z(e.updatedAt,t.updatedAt)}async function St(t,e,n=200){let r=e===void 0?void 0:Fe(e);if(r===null)throw Y();let[{files:o},{skills:i},{agents:s}]=await Promise.all([t.listMemory(),t.listSkills(),t.listAgents()]),c=[...o.filter(p=>p.archivedAt===null).map(p=>({kind:"memory",name:p.path,teamId:p.teamId,description:"",updatedAt:p.updatedAt})),...i.filter(p=>p.archivedAt===null).map(p=>({kind:"skill",name:p.name,teamId:p.teamId,description:p.description,updatedAt:p.updatedAt})),...s.filter(p=>p.archivedAt===null).map(p=>({kind:"agent",name:p.name,teamId:p.teamId,description:p.description,updatedAt:p.updatedAt}))].sort(fr),a=new Set,f=c.filter(p=>{let d=K(p);return a.has(d)?!1:(a.add(d),!0)}),g=V(f,p=>K(p),r,n);if(!g)throw Y();return{resources:g.page.map(p=>({uri:K(p),name:p.name,...p.description?{description:p.description}:{},mimeType:"text/markdown"})),...g.next===void 0?{}:{nextCursor:Ge(g.next)}}}function He(t){return U(-32603,t instanceof m?t.code:"errors.UNKNOWN")}async function wt(t,e){let n=Ae(e);if(!n)throw U(-32002,`Unknown resource: ${e}`);let r=n.teamId??void 0;try{let o=n.kind==="memory"?(await t.readMemory(n.name,r)).content:n.kind==="skill"?(await t.getSkill(n.name,r)).body:q(await t.getAgent(n.name,{team:r}));return{contents:[{uri:e,mimeType:"text/markdown",text:o}]}}catch(o){throw o instanceof m&&o.status===404?U(-32002,`Unknown resource: ${e}`):He(o)}}function Ct(t){let e=new Map;for(let n of t)n.archivedAt===null&&e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()].map(n=>n.find(r=>r.isOwn)??[...n].sort((r,o)=>z(o.updatedAt,r.updatedAt))[0]).sort((n,r)=>z(n.name,r.name))}async function At(t,e,n=200){let r=e===void 0?void 0:Fe(e);if(r===null)throw Y();let[{skills:o},{agents:i}]=await Promise.all([t.listSkills(),t.listAgents()]),s=[...Ct(o).map(a=>({name:ce("skill",a.name),description:a.description})),...Ct(i).map(a=>({name:ce("agent",a.name),description:a.description}))],c=V(s,a=>a.name,r,n);if(!c)throw Y();return{prompts:c.page.map(a=>({name:a.name,...a.description?{description:a.description}:{}})),...c.next===void 0?{}:{nextCursor:Ge(c.next)}}}async function Tt(t,e){let n=Te(e);if(!n)throw U(-32602,`Unknown prompt: ${e}`);let r=(o,i)=>({...o?{description:o}:{},messages:[{role:"user",content:{type:"text",text:i}}]});try{if(n.kind==="skill"){let i=await t.getSkill(n.name);return r(i.description,i.body)}let o=await t.getAgent(n.name,{use:!0});return r(o.description,q(o))}catch(o){throw o instanceof m&&o.status===404?U(-32602,`Unknown prompt: ${e}`):He(o)}}import{access as br,mkdir as Be,readFile as xr,rm as It,writeFile as ue}from"node:fs/promises";import{dirname as kr,join as Z}from"node:path";import{readFile as gr}from"node:fs/promises";var We=()=>!1;function hr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yr(t){let e=t.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(hr).join(".*")}$`));return n=>e.some(r=>r.test(n))}async function $t(t=nt()){try{return yr(await gr(t,"utf8"))}catch(e){if(e.code==="ENOENT")return We;throw e}}var vr=/^[a-z0-9]+(-[a-z0-9]+)*$/,Sr=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,Ke="x-onlymcp-stub";function fe(t){return t.replace(/:/g,"-")}function ge(t){return(t??"").replace(/[\r\n]+/g," ").trim()}async function Ve(t,e){let n;try{n=await xr(t,"utf8")}catch{return!0}let r=ae(n);if(r===null||B(r,Ke)!=="true")return!1;let o=B(r,"x-onlymcp-name");return o===void 0||o===e}async function _t(t,e){return await br(t).then(()=>!0,()=>!1)&&await Ve(t,e)}async function Nt(t,e,n={}){let r=n.ignore??We,[{skills:o},{agents:i}]=await Promise.all([t.listSkills(),t.listAgents()]),s=0,c=0,a=[],f=[],g=0;for(let d of o){if(!Sr.test(d.name))continue;let C=Z(e,"skills",fe(d.name)),$=Z(C,"SKILL.md");if(r(d.name)||r(fe(d.name))){f.push(d.name),await _t($,d.name)&&(await It(C,{recursive:!0,force:!0}),g+=1);continue}if(!await Ve($,d.name)){a.push(`skills/${fe(d.name)}`);continue}await Be(C,{recursive:!0}),await ue($,`---
25
+ name: ${fe(d.name)}
26
+ description: ${ge(d.description)||"Synchronisiert ueber OnlyMCP. Inhalt wird bei Bedarf geladen."}
27
+ ${Ke}: true
28
+ x-onlymcp-name: ${d.name}
29
29
  ---
30
30
 
31
- Call \`get_skill({ name: "${m.name}" })\` on the OnlyMCP server and follow whatever comes back.
32
- `,"utf8"),l+=1;try{let u=await t.getSkill(m.name);for(let b of u.files??[]){if(!R(b.path))continue;let T=await t.getSkillFile(m.name,b.path),N=V(A,...b.path.split("/"));await De(ur(N),{recursive:!0}),T.encoding==="base64"?await le(N,Buffer.from(T.content,"base64")):await le(N,T.content,"utf8"),s+=1}}catch{}}await De(V(e,"agents"),{recursive:!0});let c=0;for(let m of i){if(!gr.test(m.name))continue;let A=V(e,"agents",`${m.name}.md`);if(r(m.name)){f.push(m.name),await wt(A,m.name)&&(await St(A),h+=1);continue}if(!await ze(A,m.name)){a.push(`agents/${m.name}.md`);continue}let d=de(m.description),u=m.model?de(m.model):"",b=m.tools.map(de).join(", ");await le(A,`---
33
- name: ${m.name}
34
- description: ${d}
35
- ${u?`model: ${u}
36
- `:""}tools: ${b}
37
- ${je}: true
38
- x-onlymcp-name: ${m.name}
31
+ Call \`get_skill({ name: "${d.name}" })\` on the OnlyMCP server and follow whatever comes back.
32
+ `,"utf8"),c+=1;try{let N=await t.getSkill(d.name);for(let _ of N.files??[]){if(!M(_.path))continue;let H=await t.getSkillFile(d.name,_.path),l=Z(C,..._.path.split("/"));await Be(kr(l),{recursive:!0}),H.encoding==="base64"?await ue(l,Buffer.from(H.content,"base64")):await ue(l,H.content,"utf8"),s+=1}}catch{}}await Be(Z(e,"agents"),{recursive:!0});let p=0;for(let d of i){if(!vr.test(d.name))continue;let C=Z(e,"agents",`${d.name}.md`);if(r(d.name)){f.push(d.name),await _t(C,d.name)&&(await It(C),g+=1);continue}if(!await Ve(C,d.name)){a.push(`agents/${d.name}.md`);continue}let $=ge(d.description),N=d.model?ge(d.model):"",_=d.tools.map(ge).join(", ");await ue(C,`---
33
+ name: ${d.name}
34
+ description: ${$}
35
+ ${N?`model: ${N}
36
+ `:""}tools: ${_}
37
+ ${Ke}: true
38
+ x-onlymcp-name: ${d.name}
39
39
  ---
40
40
 
41
- Call \`get_agent_definition({ name: "${m.name}" })\` on the OnlyMCP server and follow whatever comes back.
42
- `,"utf8"),c+=1}return{skills:l,agents:c,files:s,kept:a,ignored:f,removed:h}}import{z as Yr}from"zod";import{z as Ge}from"zod";var hr=Ge.object({name:Ge.string().min(1).max(64),path:Ge.string().min(1).max(200)});function At(t){return{name:"get_skill_file",description:"Delivers a single companion file of a skill from the OnlyMCP cloud, e.g. references/palette.md. Usually not needed: `npx onlymcp sync` places these files next to the SKILL.md.",inputSchema:hr,async handler(e){try{let n=await t.getSkillFile(e.name,e.path);return n.encoding==="base64"?{content:[{type:"text",text:`errors.BINARY_FILE ${n.path} (${n.size} bytes) - fetch it to disk with \`npx onlymcp sync\`.`}],isError:!0}:{content:[{type:"text",text:n.content}]}}catch(n){return{content:[{type:"text",text:n instanceof p?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Tt}from"zod";var yr=Tt.object({name:Tt.string().min(1).max(64)});function $t(t,e){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:yr,async handler(n){let r=`skill:${n.name}`,o=await e.get(r);if(o!==null)return{content:[{type:"text",text:o}]};try{let i=await t.getSkill(n.name);return await e.set(r,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof p?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as br}from"zod";var It=br.object({}),O=t=>t.scope==="team"?` (team: ${t.teamName??"unknown"})`:"";function _t(t){return{name:"list_skills",description:"List every skill name available to this user. Use when a skill you need is not named in the server instructions.",inputSchema:It,async handler(){try{let{skills:e}=await t.listSkills();return{content:[{type:"text",text:e.map(n=>`${n.name}${O(n)}`).join(`
43
- `)}]}}catch(e){return{content:[{type:"text",text:e instanceof p?e.code:"errors.UNKNOWN"}],isError:!0}}}}}function Nt(t){return{name:"list_agents",description:"List every agent available to this user, with its description. Use when this client has no agent files of its own.",inputSchema:It,async handler(){try{let{agents:e}=await t.listAgents();return{content:[{type:"text",text:e.map(r=>`${r.name}${O(r)}: ${r.description}`).join(`
44
- `)}]}}catch(e){return{content:[{type:"text",text:e instanceof p?e.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as xr}from"node:os";import{z as pe}from"zod";var kr=pe.object({path:pe.string().min(3).max(256),content:pe.string().min(1).max(1e6),ifMatch:pe.string().max(64).optional()}),Et=t=>({content:[{type:"text",text:t instanceof p?t.code:"errors.UNKNOWN"}],isError:!0});function Lt(t){return{name:"memory_append",description:"Appends text to a memory file, after a newline when the file does not end with one. A missing file is created.",inputSchema:kr,async handler(e){if(!k(e.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};for(let n=0;;n+=1){let r;try{r=await t.readMemory(e.path)}catch(o){if(!(o instanceof p&&o.code==="errors.MEMORY_NOT_FOUND"))return Et(o);r=null}try{let o=await t.writeMemory(e.path,r===null?e.content:ve(r.content,e.content),xr(),r===null?void 0:e.ifMatch??r.updatedAt),i=e.content.length,s=o.routedTo?` (created in team ${o.routedTo.teamName})`:"";return{content:[{type:"text",text:`Appended ${i} ${i===1?"character":"characters"} to ${e.path}.${s}`}]}}catch(o){if(o instanceof p&&o.code==="errors.MEMORY_CHANGED"&&e.ifMatch===void 0&&n===0)continue;return Et(o)}}}}}import{z as D}from"zod";var vr=D.object({path:D.string().min(3).max(256),from:D.string().optional(),lines:D.string().optional()}),Rt=2e3;function Pt(t){let e=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache. from (first line, counted from 1) and lines (how many, 1 to 2000) return a range and the total number of lines.",inputSchema:vr,async handler(n){if(!k(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};let r=n.from!==void 0||n.lines!==void 0,o=D.coerce.number().int().min(1).safeParse(n.from??"1"),i=D.coerce.number().int().min(1).max(Rt).safeParse(n.lines??String(Rt));if(r&&(!o.success||!i.success))return{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0};try{let s=e.get(n.path);s||(s=t.readMemory(n.path).then(h=>({content:h.content,updatedAt:h.updatedAt})),e.set(n.path,s),s.finally(()=>e.delete(n.path)));let l=await s;if(!r||!o.success||!i.success)return{content:[{type:"text",text:l.content}],_meta:{updatedAt:l.updatedAt}};let a=Se(l.content,o.data,i.data);return{content:[{type:"text",text:o.data>a.totalLines?we(o.data,a.totalLines):a.text}],_meta:{updatedAt:l.updatedAt,totalLines:a.totalLines,from:a.from,to:a.to}}}catch(s){return{content:[{type:"text",text:s instanceof p?s.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as Sr}from"node:os";import{z as me}from"zod";var wr=me.object({path:me.string().min(3).max(256),content:me.string().max(1e6),ifMatch:me.string().max(64).optional()});function Ot(t){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through). When a note replaces an older one, add superseded_by: <new name> to the old file's frontmatter: search then lists it after the current one.",inputSchema:wr,async handler(e){if(!k(e.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await t.writeMemory(e.path,e.content,Sr(),e.ifMatch),r=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(r+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:r}]}}catch(n){if(n instanceof p&&n.code==="errors.MEMORY_CHANGED"){let{updatedAt:o,by:i}=n.params;return{content:[{type:"text",text:`${`The file changed since you read it (at ${o??"an unknown time"}, by ${i??"a device"}). Read it again, then write.`}
45
- ${n.code} ${JSON.stringify(n.params)}`}],isError:!0}}return{content:[{type:"text",text:n instanceof p?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as x}from"zod";var $=t=>({content:[{type:"text",text:t}]}),C=t=>({content:[{type:"text",text:t}],isError:!0});function J(t){return t instanceof p?t.code:"errors.UNKNOWN"}var ue=x.string().trim().min(1).max(128).optional(),Cr=x.object({query:x.string().min(1).max(200),types:x.string().max(64).optional(),limit:x.number().int().min(1).max(50).optional(),type:ue.describe("Only memory files of this metadata.type, e.g. solution, project, feedback."),project:ue.describe("Only memory files about this project."),tag:ue.describe("Only memory files carrying this tag."),expand:x.enum(["links","none"]).optional().describe("links: name the direct links of the first five hits.")});async function Ar(t,e){let n=new Map;for(let r of e.slice(0,$e))try{let o=await t.graphNodeByRid(r.kind,r.id),i=Ne(o.neighbours,o.missing??[]);i&&n.set(`${r.kind}:${r.id}`,i)}catch{}return n}function Ut(t){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each; between equally good matches the more recently changed one ranks first, and a file marked superseded_by comes after the current ones (\u2192 superseded by <name>). type, project and tag narrow it to memory files whose frontmatter says so. expand=links names, under each of the first five, what it links to and what links to it (\u2190).",inputSchema:Cr,async handler(e){try{let{hits:n}=await t.searchContent(e.query,{types:e.types?.split(",").map(i=>i.trim()).filter(i=>i!==""),limit:e.limit,...e.type===void 0?{}:{type:e.type},...e.project===void 0?{}:{project:e.project},...e.tag===void 0?{}:{tag:e.tag}});if(n.length===0)return $(`Nothing found for ${e.query}`);let r=new Map;if(n.some(i=>i.teamId!==null))try{for(let i of(await t.listTeams()).teams)r.set(i.id,i.name)}catch{}let o=e.expand==="links"?await Ar(t,n):new Map;return $(n.map(i=>{let s=`${i.kind} ${i.path??i.name}${O({scope:i.scope,teamName:i.teamId===null?null:r.get(i.teamId)??null})}${Te(i.supersededBy)}
46
- ${i.snippet}`,l=o.get(`${i.kind}:${i.id}`);return l?`${s}
47
- ${l}`:s}).join(`
48
- `))}catch(n){return C(J(n))}}}}var Tr=x.object({scope:x.string().max(96).optional(),folder:x.string().max(256).optional().describe("Only this folder and what is under it, e.g. solutions.")});function Dt(t){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it, each with its frontmatter type in brackets ([solution]). folder narrows it to one folder and what is under it.",inputSchema:Tr,async handler(e){try{let n=(e.folder??"").trim().replace(/^\/+|\/+$/g,"");if(n!==""&&!k(`${n}/x.md`))return C("errors.INVALID_PATH");let r=n===""?null:`${n}/`,{nodes:o}=await t.memoryTree(e.scope??"all"),i=r===null?o:o.filter(s=>s.path.startsWith(r)||s.kind==="folder"&&s.path===n);return i.length===0?$(r===null?"(empty)":`No folder ${n}`):$(i.map(s=>{let l=s.path.split("/").length-1,a=s.kind==="folder"?`${s.name}/`:s.name,f=s.kind==="file"&&s.type?` [${s.type}]`:"";return`${" ".repeat(l)}${a}${f}${O(s)}`}).join(`
49
- `))}catch(n){return C(J(n))}}}}var $r=x.object({from:x.string().min(3).max(256),to:x.string().min(3).max(256),updateLinks:x.boolean().optional()});function Mt(t){return`${t} ${t===1?"file":"files"}`}function jt(t){return{name:"memory_move",description:"Moves or renames a memory file. Every [[link]] that would no longer find it follows along, by name or by path, unless turned off.",inputSchema:$r,async handler(e){if(!k(e.from)||!k(e.to))return C("errors.INVALID_PATH");let n=e.updateLinks??!0;try{let r=await t.moveMemory(e.from,e.to,n);return $(`${r.from} moved to ${r.to}`+(n?`, links updated in ${Mt(r.rewritten)}, ${Mt(r.skipped)} left unchanged`:""))}catch(r){return C(J(r))}}}}var Ir=x.object({path:x.string().min(3).max(256)});function zt(t){return{name:"memory_links",description:"A memory file's [[links]], split between the ones that point somewhere and the ones that point nowhere.",inputSchema:Ir,async handler(e){if(!k(e.path))return C("errors.INVALID_PATH");try{let n=await t.readMemory(e.path),{resolved:r,unresolved:o}=n.links;return r.length===0&&o.length===0?$(`${e.path} does not link to anything.`):$([r.length>0?`Resolved: ${r.join(", ")}`:"",o.length>0?`Open (no file with this name yet): ${o.join(", ")}`:""].filter(i=>i!=="").join(`
50
- `))}catch(n){return C(J(n))}}}}var _r=x.object({path:x.string().min(3).max(256).describe("Path of the memory file to start from."),depth:x.number().int().min(1).max(3).optional().describe("Hops to walk, 1 to 3. Default 1."),types:x.string().max(128).optional().describe("Comma-separated node kinds to list: memory, skill, agent, mcp, tool, folder, type, project, tag, collection."),folder:x.string().max(256).optional().describe("Only memory files and folders under this folder."),project:ue.describe("Only nodes about this project (and the project itself).")});function Gt(t){return{name:"memory_graph",description:"The graph around one memory file, up to three hops. Depth 1: the files, skills, agents and servers it links to or is linked from, its folder, type, project and tags, and links that land on nothing (\u2192 links to (missing) name). From depth 2 on only links are followed, never a shared folder, type, project or tag. Start with depth 1; use 2-3 to follow links further. Grouped by depth; each line names the edge and, from depth 2, the node it was reached through. types, folder and project narrow what is listed, not the walk.",inputSchema:_r,async handler(e){if(!k(e.path))return C("errors.INVALID_PATH");let n=e.depth??1,r=e.types===void 0||e.types.trim()===""?void 0:Ie(e.types);if(r===null)return C(`Invalid types: ${e.types}`);let o=(e.folder??"").trim().replace(/^\/+|\/+$/g,"");if(o!==""&&!k(`${o}/x.md`))return C("errors.INVALID_PATH");try{let i=await t.readMemory(e.path);if(!i.id)return C("This server is too old for memory_graph: it does not send a file id.");let s;try{s=(await t.graphNodeByRid("memory",i.id)).node.id}catch(c){if(c instanceof p&&c.code==="errors.NODE_NOT_FOUND")return $(`${i.path} is not in the graph yet (it is added on its next save).`);throw c}let l=await t.graphAround(s,n),a={...r?{types:r}:{},...o!==""?{folder:o}:{},...e.project!==void 0?{project:e.project}:{}},f=Object.keys(a).length>0?new Set((await t.graphAround(s,n,a)).nodes.map(c=>c.id)):null,h=Ae(a)?l.missing??[]:[];return $(_e({path:i.path,focus:s,depth:n,nodes:l.nodes,edges:l.edges,truncated:l.truncated,kept:f,missing:h}))}catch(i){return C(J(i))}}}}import{z as g}from"zod";var Nr=t=>({content:[{type:"text",text:t}]}),Ft=t=>({content:[{type:"text",text:t}],isError:!0});async function j(t){try{return Nr(await t())}catch(e){if(e instanceof p){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return Ft(`${e.code}${n}`)}return Ft("errors.UNKNOWN")}}var q=g.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function ge(t,e){let{connections:n}=await t.listConnections(),r=n.filter(o=>o.slug===e);return r.find(o=>o.scope==="personal")??r[0]??null}function Fe(t){let e=t.authType==="none"?"no auth":`${t.authType}, secret ...${t.secretHint??"?"}`;return`${t.slug} \u2014 ${t.name} (${t.scope}, ${t.enabled?t.status:"disabled"}, ${e})
41
+ Call \`get_agent_definition({ name: "${d.name}" })\` on the OnlyMCP server and follow whatever comes back.
42
+ `,"utf8"),p+=1}return{skills:c,agents:p,files:s,kept:a,ignored:f,removed:g}}import{z as ro}from"zod";import{z as Je}from"zod";var wr=Je.object({name:Je.string().min(1).max(64),path:Je.string().min(1).max(200)});function Et(t){return{name:"get_skill_file",description:"Delivers a single companion file of a skill from the OnlyMCP cloud, e.g. references/palette.md. Usually not needed: `npx onlymcp sync` places these files next to the SKILL.md.",inputSchema:wr,async handler(e){try{let n=await t.getSkillFile(e.name,e.path);return n.encoding==="base64"?{content:[{type:"text",text:`errors.BINARY_FILE ${n.path} (${n.size} bytes) - fetch it to disk with \`npx onlymcp sync\`.`}],isError:!0}:{content:[{type:"text",text:n.content}]}}catch(n){return{content:[{type:"text",text:n instanceof m?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Lt}from"zod";var Cr=Lt.object({name:Lt.string().min(1).max(64)});function Rt(t,e){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:Cr,async handler(n){let r=`skill:${n.name}`,o=await e.get(r);if(o!==null)return{content:[{type:"text",text:o}]};try{let i=await t.getSkill(n.name);return await e.set(r,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof m?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Ar}from"zod";var Pt=Ar.object({}),D=t=>t.scope==="team"?` (team: ${t.teamName??"unknown"})`:"";function Ot(t){return{name:"list_skills",description:"List every skill name available to this user. Use when a skill you need is not named in the server instructions.",inputSchema:Pt,async handler(){try{let{skills:e}=await t.listSkills();return{content:[{type:"text",text:e.map(n=>`${n.name}${D(n)}`).join(`
43
+ `)}]}}catch(e){return{content:[{type:"text",text:e instanceof m?e.code:"errors.UNKNOWN"}],isError:!0}}}}}function Mt(t){return{name:"list_agents",description:"List every agent available to this user, with its description. Use when this client has no agent files of its own.",inputSchema:Pt,async handler(){try{let{agents:e}=await t.listAgents();return{content:[{type:"text",text:e.map(r=>`${r.name}${D(r)}: ${r.description}`).join(`
44
+ `)}]}}catch(e){return{content:[{type:"text",text:e instanceof m?e.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as Tr}from"node:os";import{z as he}from"zod";var $r=he.object({path:he.string().min(3).max(256),content:he.string().min(1).max(1e6),ifMatch:he.string().max(64).optional()}),Ut=t=>({content:[{type:"text",text:t instanceof m?t.code:"errors.UNKNOWN"}],isError:!0});function Dt(t){return{name:"memory_append",description:"Appends text to a memory file, after a newline when the file does not end with one. A missing file is created.",inputSchema:$r,async handler(e){if(!k(e.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};for(let n=0;;n+=1){let r;try{r=await t.readMemory(e.path)}catch(o){if(!(o instanceof m&&o.code==="errors.MEMORY_NOT_FOUND"))return Ut(o);r=null}try{let o=await t.writeMemory(e.path,r===null?e.content:$e(r.content,e.content),Tr(),r===null?void 0:e.ifMatch??r.updatedAt),i=e.content.length,s=o.routedTo?` (created in team ${o.routedTo.teamName})`:"";return{content:[{type:"text",text:`Appended ${i} ${i===1?"character":"characters"} to ${e.path}.${s}`}]}}catch(o){if(o instanceof m&&o.code==="errors.MEMORY_CHANGED"&&e.ifMatch===void 0&&n===0)continue;return Ut(o)}}}}}import{z as G}from"zod";var Ir=G.object({path:G.string().min(3).max(256),from:G.string().optional(),lines:G.string().optional()}),jt=2e3;function zt(t){let e=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache. from (first line, counted from 1) and lines (how many, 1 to 2000) return a range and the total number of lines.",inputSchema:Ir,async handler(n){if(!k(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};let r=n.from!==void 0||n.lines!==void 0,o=G.coerce.number().int().min(1).safeParse(n.from??"1"),i=G.coerce.number().int().min(1).max(jt).safeParse(n.lines??String(jt));if(r&&(!o.success||!i.success))return{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0};try{let s=e.get(n.path);s||(s=t.readMemory(n.path).then(g=>({content:g.content,updatedAt:g.updatedAt})),e.set(n.path,s),s.finally(()=>e.delete(n.path)));let c=await s;if(!r||!o.success||!i.success)return{content:[{type:"text",text:c.content}],_meta:{updatedAt:c.updatedAt}};let a=Ie(c.content,o.data,i.data);return{content:[{type:"text",text:o.data>a.totalLines?_e(o.data,a.totalLines):a.text}],_meta:{updatedAt:c.updatedAt,totalLines:a.totalLines,from:a.from,to:a.to}}}catch(s){return{content:[{type:"text",text:s instanceof m?s.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as _r}from"node:os";import{z as ye}from"zod";var Nr=ye.object({path:ye.string().min(3).max(256),content:ye.string().max(1e6),ifMatch:ye.string().max(64).optional()});function Gt(t){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through). When a note replaces an older one, add superseded_by: <new name> to the old file's frontmatter: search then lists it after the current one.",inputSchema:Nr,async handler(e){if(!k(e.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await t.writeMemory(e.path,e.content,_r(),e.ifMatch),r=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(r+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:r}]}}catch(n){if(n instanceof m&&n.code==="errors.MEMORY_CHANGED"){let{updatedAt:o,by:i}=n.params;return{content:[{type:"text",text:`${`The file changed since you read it (at ${o??"an unknown time"}, by ${i??"a device"}). Read it again, then write.`}
45
+ ${n.code} ${JSON.stringify(n.params)}`}],isError:!0}}return{content:[{type:"text",text:n instanceof m?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as x}from"zod";var I=t=>({content:[{type:"text",text:t}]}),T=t=>({content:[{type:"text",text:t}],isError:!0});function X(t){return t instanceof m?t.code:"errors.UNKNOWN"}var be=x.string().trim().min(1).max(128).optional(),Er=x.object({query:x.string().min(1).max(200),types:x.string().max(64).optional(),limit:x.number().int().min(1).max(50).optional(),type:be.describe("Only memory files of this metadata.type, e.g. solution, project, feedback."),project:be.describe("Only memory files about this project."),tag:be.describe("Only memory files carrying this tag."),expand:x.enum(["links","none"]).optional().describe("links: name the direct links of the first five hits.")});async function Lr(t,e){let n=new Map;for(let r of e.slice(0,Pe))try{let o=await t.graphNodeByRid(r.kind,r.id),i=Ue(o.neighbours,o.missing??[]);i&&n.set(`${r.kind}:${r.id}`,i)}catch{}return n}function Ht(t){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each; between equally good matches the more recently changed one ranks first, and a file marked superseded_by comes after the current ones (\u2192 superseded by <name>). type, project and tag narrow it to memory files whose frontmatter says so. expand=links names, under each of the first five, what it links to and what links to it (\u2190).",inputSchema:Er,async handler(e){try{let{hits:n}=await t.searchContent(e.query,{types:e.types?.split(",").map(i=>i.trim()).filter(i=>i!==""),limit:e.limit,...e.type===void 0?{}:{type:e.type},...e.project===void 0?{}:{project:e.project},...e.tag===void 0?{}:{tag:e.tag}});if(n.length===0)return I(`Nothing found for ${e.query}`);let r=new Map;if(n.some(i=>i.teamId!==null))try{for(let i of(await t.listTeams()).teams)r.set(i.id,i.name)}catch{}let o=e.expand==="links"?await Lr(t,n):new Map;return I(n.map(i=>{let s=`${i.kind} ${i.path??i.name}${D({scope:i.scope,teamName:i.teamId===null?null:r.get(i.teamId)??null})}${Re(i.supersededBy)}
46
+ ${i.snippet}`,c=o.get(`${i.kind}:${i.id}`);return c?`${s}
47
+ ${c}`:s}).join(`
48
+ `))}catch(n){return T(X(n))}}}}var Rr=x.object({scope:x.string().max(96).optional(),folder:x.string().max(256).optional().describe("Only this folder and what is under it, its full path (Memories/solutions) or its last part (solutions) when only one folder ends in it.")});function Wt(t){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it, each with its frontmatter type in brackets ([solution]). folder narrows it to one folder and what is under it.",inputSchema:Rr,async handler(e){try{let n=(e.folder??"").trim().replace(/^\/+|\/+$/g,"");if(n!==""&&!k(`${n}/x.md`))return T("errors.INVALID_PATH");let{nodes:r}=await t.memoryTree(e.scope??"all"),o=n===""?null:me(n,Jt(r));if(o&&"error"in o)return I(o.error);let i=o?o.folder:"",s=o?`${i}/`:null,c=s===null?r:r.filter(a=>a.path.startsWith(s)||a.kind==="folder"&&a.path===i);return c.length===0?I(s===null?"(empty)":`No folder ${i}`):I((o?.note?`${o.note}
49
+ `:"")+c.map(a=>{let f=a.path.split("/").length-1,g=a.kind==="folder"?`${a.name}/`:a.name,p=a.kind==="file"&&a.type?` [${a.type}]`:"";return`${" ".repeat(f)}${g}${p}${D(a)}`}).join(`
50
+ `))}catch(n){return T(X(n))}}}}var Pr=x.object({from:x.string().min(3).max(256),to:x.string().min(3).max(256),updateLinks:x.boolean().optional()});function Ft(t){return`${t} ${t===1?"file":"files"}`}function Bt(t){return{name:"memory_move",description:"Moves or renames a memory file. Every [[link]] that would no longer find it follows along, by name or by path, unless turned off.",inputSchema:Pr,async handler(e){if(!k(e.from)||!k(e.to))return T("errors.INVALID_PATH");let n=e.updateLinks??!0;try{let r=await t.moveMemory(e.from,e.to,n);return I(`${r.from} moved to ${r.to}`+(n?`, links updated in ${Ft(r.rewritten)}, ${Ft(r.skipped)} left unchanged`:""))}catch(r){return T(X(r))}}}}var Or=x.object({path:x.string().min(3).max(256)});function Kt(t){return{name:"memory_links",description:"A memory file's [[links]], split between the ones that point somewhere and the ones that point nowhere.",inputSchema:Or,async handler(e){if(!k(e.path))return T("errors.INVALID_PATH");try{let n=await t.readMemory(e.path),{resolved:r,unresolved:o}=n.links;return r.length===0&&o.length===0?I(`${e.path} does not link to anything.`):I([r.length>0?`Resolved: ${r.join(", ")}`:"",o.length>0?`Open (no file with this name yet): ${o.join(", ")}`:""].filter(i=>i!=="").join(`
51
+ `))}catch(n){return T(X(n))}}}}var Mr=x.object({path:x.string().min(3).max(256).describe("Path of the memory file to start from."),depth:x.number().int().min(1).max(3).optional().describe("Hops to walk, 1 to 3. Default 1."),types:x.string().max(128).optional().describe("Comma-separated node kinds to list: memory, skill, agent, mcp, tool, folder, type, project, tag, collection."),folder:x.string().max(256).optional().describe("Only memory files and folders under this folder (full path, or its last part)."),project:be.describe("Only nodes about this project (and the project itself).")});function Vt(t){return{name:"memory_graph",description:"The graph around one memory file, up to three hops. Depth 1: the files, skills, agents and servers it links to or is linked from, its folder, type, project and tags, and links that land on nothing (\u2192 links to (missing) name). From depth 2 on only links out of a file reached by a link are followed: a backlink, folder, type, project or tag is listed at depth 1 and never walked through. Pick the depth yourself; 1 is the default and usually enough, 2-3 follow a chain of links further, the files most of the previous depth links to first. Grouped by depth; each line names the edge and, from depth 2, the node it was reached through. types, folder and project narrow what is listed, not the walk.",inputSchema:Mr,async handler(e){if(!k(e.path))return T("errors.INVALID_PATH");let n=e.depth??1,r=e.types===void 0||e.types.trim()===""?void 0:Oe(e.types);if(r===null)return T(`Invalid types: ${e.types}`);let o=(e.folder??"").trim().replace(/^\/+|\/+$/g,"");if(o!==""&&!k(`${o}/x.md`))return T("errors.INVALID_PATH");try{let i=await t.readMemory(e.path);if(!i.id)return T("This server is too old for memory_graph: it does not send a file id.");let s;try{s=(await t.graphNodeByRid("memory",i.id)).node.id}catch(d){if(d instanceof m&&d.code==="errors.NODE_NOT_FOUND")return I(`${i.path} is not in the graph yet (it is added on its next save).`);throw d}let c=o===""?null:me(o,Jt((await t.memoryTree("all")).nodes));if(c&&"error"in c)return I(c.error);let a=await t.graphAround(s,n),f={...r?{types:r}:{},...c?{folder:c.folder}:{},...e.project!==void 0?{project:e.project}:{}},g=Object.keys(f).length>0?new Set((await t.graphAround(s,n,f)).nodes.map(d=>d.id)):null,p=Le(f)?a.missing??[]:[];return I(Me({path:i.path,focus:s,depth:n,nodes:a.nodes,edges:a.edges,truncated:a.truncated,kept:g,missing:p}))}catch(i){return T(X(i))}}}}function Jt(t){let e=new Set;for(let n of t){n.kind==="folder"&&e.add(n.path);let r=n.path.split("/");for(let o=1;o<r.length;o+=1)e.add(r.slice(0,o).join("/"))}return[...e]}import{z as y}from"zod";var Ur=t=>({content:[{type:"text",text:t}]}),qt=t=>({content:[{type:"text",text:t}],isError:!0});async function F(t){try{return Ur(await t())}catch(e){if(e instanceof m){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return qt(`${e.code}${n}`)}return qt("errors.UNKNOWN")}}var Q=y.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function xe(t,e){let{connections:n}=await t.listConnections(),r=n.filter(o=>o.slug===e);return r.find(o=>o.scope==="personal")??r[0]??null}function qe(t){let e=t.authType==="none"?"no auth":`${t.authType}, secret ...${t.secretHint??"?"}`;return`${t.slug} \u2014 ${t.name} (${t.scope}, ${t.enabled?t.status:"disabled"}, ${e})
51
52
  ${t.url}${t.statusError?`
52
- last error: ${t.statusError}`:""}`}var Er=g.object({});function Ht(t){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:Er,handler:()=>j(async()=>{let{connections:e}=await t.listConnections();return e.length===0?"No MCP servers are connected yet. Add one with connection_create.":e.map(Fe).join(`
53
- `)})}}var Lr=g.object({name:g.string().min(1).max(80),slug:q,url:g.string().url().max(2e3),transport:g.enum(["http","sse"]).default("http"),authType:g.enum(["none","bearer","header"]).default("none"),authHeaderName:g.string().max(80).optional(),secret:g.string().max(4e3).optional(),teamId:g.string().max(64).optional()});function Wt(t){return{name:"connection_create",description:"Connect a remote MCP server (http or sse only - a stdio server cannot be started on somebody else's behalf). It is probed straight away. Passing a secret here puts it into this conversation; leave it out and set it in the dashboard if that matters.",inputSchema:Lr,handler:e=>j(async()=>{let{connection:n}=await t.createConnection(e);return`Connected.
54
- ${Fe(n)}
53
+ last error: ${t.statusError}`:""}`}var Dr=y.object({});function Yt(t){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:Dr,handler:()=>F(async()=>{let{connections:e}=await t.listConnections();return e.length===0?"No MCP servers are connected yet. Add one with connection_create.":e.map(qe).join(`
54
+ `)})}}var jr=y.object({name:y.string().min(1).max(80),slug:Q,url:y.string().url().max(2e3),transport:y.enum(["http","sse"]).default("http"),authType:y.enum(["none","bearer","header"]).default("none"),authHeaderName:y.string().max(80).optional(),secret:y.string().max(4e3).optional(),teamId:y.string().max(64).optional()});function Zt(t){return{name:"connection_create",description:"Connect a remote MCP server (http or sse only - a stdio server cannot be started on somebody else's behalf). It is probed straight away. Passing a secret here puts it into this conversation; leave it out and set it in the dashboard if that matters.",inputSchema:jr,handler:e=>F(async()=>{let{connection:n}=await t.createConnection(e);return`Connected.
55
+ ${qe(n)}
55
56
 
56
- Its tools are now available as "${n.slug}__<tool>".`})}}var Rr=g.object({slug:q,name:g.string().min(1).max(80).optional(),url:g.string().url().max(2e3).optional(),transport:g.enum(["http","sse"]).optional(),authType:g.enum(["none","bearer","header"]).optional(),authHeaderName:g.string().max(80).optional(),secret:g.string().max(4e3).optional(),enabled:g.boolean().optional()});function Bt(t){return{name:"connection_update",description:"Change a connected MCP server. Only the fields you pass are touched; url, transport, authType and secret trigger a fresh probe.",inputSchema:Rr,handler:e=>j(async()=>{let n=await ge(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{slug:r,...o}=e,{connection:i}=await t.updateConnection(n.id,o);return`Updated.
57
- ${Fe(i)}`})}}var Pr=g.object({slug:q});function Kt(t){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:Pr,handler:e=>j(async()=>{let n=await ge(t,e.slug);return n?(await t.deleteConnection(n.id),`Disconnected ${e.slug}.`):`Connection not found: ${e.slug}`})}}var Or=g.object({slug:q});function Vt(t){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:Or,handler:e=>j(async()=>{let n=await ge(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:r}=await t.listCapabilities(n.id);return r.length===0?`${e.slug} has nothing on record yet. Its status is "${n.status}".`:r.map(o=>`${o.enabled?"[on] ":"[off]"} ${o.kind} ${o.name}${o.exposedAs?` -> ${o.exposedAs}`:""}${o.description?` \u2014 ${o.description}`:""}`).join(`
58
- `)})}}var Mr=g.object({slug:q,tool:g.string().min(1).max(200),enabled:g.boolean()});function Jt(t){return{name:"connection_tool_toggle",description:"Switch one tool of a connected server on or off. A tool that is off costs no room in any client's tool list.",inputSchema:Mr,handler:e=>j(async()=>{let n=await ge(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:r}=await t.listCapabilities(n.id),o=r.find(i=>i.kind==="tool"&&i.name===e.tool);return o?(await t.toggleCapability(n.id,o.id,e.enabled),`${e.slug}__${o.name} is now ${e.enabled?"on":"off"}.`):`${e.slug} offers no tool called ${e.tool}.`})}}import{z as y}from"zod";var Ur=t=>({content:[{type:"text",text:t}]}),Y=t=>({content:[{type:"text",text:t}],isError:!0});async function I(t){try{return Ur(await t())}catch(e){if(e instanceof p){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return Y(`${e.code}${n}`)}return Y("errors.UNKNOWN")}}var M=y.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),Dr=y.object({name:M,body:y.string().max(2e5)});function qt(t){return{name:"skill_write",description:"Create a skill or replace the body of an existing one. The body is the whole SKILL.md, frontmatter included.",inputSchema:Dr,handler:e=>I(async()=>{let n=await t.putSkill(e.name,e.body);return`${n.name} ${n.updatedAt}`})}}var jr=y.object({name:M});function Yt(t){return{name:"skill_delete",description:"Delete one skill and every file that belongs to it. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:jr,handler:e=>I(async()=>(await t.deleteSkill(e.name),`Deleted skill ${e.name}`))}}var zr=y.object({skill:M});function Zt(t){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:zr,handler:e=>I(async()=>{let{files:n}=await t.getSkill(e.skill);return n.length===0?`${e.skill} has no companion files.`:n.map(r=>`${r.path} (${r.size} bytes, ${r.encoding})`).join(`
59
- `)})}}var Gr=y.object({skill:M,path:y.string().min(1).max(256),content:y.string().max(3e6),encoding:y.enum(["utf8","base64"]).default("utf8")});function Xt(t){return{name:"skill_file_write",description:"Create or replace one companion file of a skill. Use encoding base64 for anything that is not text.",inputSchema:Gr,handler:e=>R(e.path)?I(async()=>{let n=await t.putSkillFile(e.skill,e.path,e.content,e.encoding);return`${e.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(Y("errors.INVALID_PATH"))}}var Fr=y.object({skill:M,path:y.string().min(1).max(256)});function Qt(t){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:Fr,handler:e=>R(e.path)?I(async()=>(await t.deleteSkillFile(e.skill,e.path),`Deleted ${e.skill}/${e.path}`)):Promise.resolve(Y("errors.INVALID_PATH"))}}var Hr=y.object({name:M,description:y.string().min(1).max(1e3),body:y.string().max(2e5),model:y.string().max(64).optional(),tools:y.array(y.string().max(128)).max(200).optional()});function en(t){return{name:"agent_write",description:"Create an agent or replace an existing one. Leave model out to keep the one it already has.",inputSchema:Hr,handler:e=>I(async()=>{let n=await t.getAgent(e.name).catch(()=>null),r=await t.putAgent(e.name,{description:e.description,body:e.body,model:e.model??n?.model??void 0,tools:e.tools??n?.tools??[]});return`${r.name} ${r.updatedAt}`})}}var Wr=y.object({name:M});function tn(t){return{name:"agent_delete",description:"Delete one agent. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Wr,handler:e=>I(async()=>(await t.deleteAgent(e.name),`Deleted agent ${e.name}`))}}var Br=y.object({});function nn(t){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:Br,handler:()=>I(async()=>{let{files:e}=await t.listMemory();return e.length===0?"(none)":e.map(n=>n.path+O(n)).sort().join(`
60
- `)})}}var Kr=y.object({path:y.string().min(3).max(256)});function rn(t){return{name:"memory_delete",description:"Delete one memory file. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Kr,handler:e=>k(e.path)?I(async()=>(await t.deleteMemory(e.path),`Deleted ${e.path}`)):Promise.resolve(Y("errors.INVALID_PATH"))}}import{z as _}from"zod";var fe=t=>({content:[{type:"text",text:t}]}),Z=t=>({content:[{type:"text",text:t}],isError:!0});async function He(t){try{return await t()}catch(e){if(e instanceof p){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return Z(`${e.code}${n}`)}return Z("errors.UNKNOWN")}}var Vr=_.object({}),on=_.enum(["memory","skill","agent"]),Jr=_.object({kind:on,name:_.string().min(1).max(300),team:_.string().min(1).max(200)}),qr=_.object({kind:on,team:_.string().min(1).max(200),name:_.string().min(1).max(300).optional(),id:_.string().uuid().optional()});async function sn(t,e){let n=e.trim(),{teams:r}=await t.listTeams(),o=r.find(s=>s.id===n);if(o)return o;let i=r.filter(s=>s.name===n);if(i.length===1)return i[0];if(i.length>1){let s=i.map(l=>l.id).sort();return Z(`Several of your teams are named "${e}": ${s.join(", ")}. Pass the id as team.
61
- errors.TEAM_AMBIGUOUS ${JSON.stringify({team:e,ids:s})}`)}return Z(`You are not in that team.
62
- errors.NOT_A_MEMBER ${JSON.stringify({team:e})}`)}var an=t=>"content"in t;function ln(t){return{name:"list_teams",description:"List the teams this account is in, one per line: the team id, its name and your role in it.",inputSchema:Vr,handler:e=>He(async()=>{let{teams:n}=await t.listTeams();if(n.length===0)return fe("(none)");let r=(o,i)=>o<i?-1:o>i?1:0;return fe([...n].sort((o,i)=>r(o.name,i.name)||r(o.id,i.id)).map(o=>`${o.id} ${o.name} ${o.role}`).join(`
63
- `))})}}function cn(t){return{name:"team_share",description:"Move one of your own memory files, skills or agents into a team, so its members can use it. You need the right to create that kind of content in the team, the team must not hold an item of that name already, and a frozen team takes nothing new.",inputSchema:Jr,handler:e=>He(async()=>{let n=await sn(t,e.team);return an(n)?n:(await t.shareWithTeam(n.id,{kind:e.kind,name:e.name}),fe(`Shared ${e.kind} ${e.name} with the team ${n.name}.`))})}}function dn(t){return{name:"team_return",description:"Take an item out of a team and back under its owner. Name one of your own items, or pass the id of any item of the team if you may delete that kind of content there. The item keeps its owner, and the return is never refused on a quota.",inputSchema:qr,handler:e=>e.name===void 0==(e.id===void 0)?Promise.resolve(Z("Invalid arguments: pass name or id, not both.")):He(async()=>{let n=await sn(t,e.team);return an(n)?n:(await t.returnFromTeam(n.id,e.name!==void 0?{kind:e.kind,name:e.name}:{kind:e.kind,id:e.id}),fe(`Returned ${e.kind} ${e.name??e.id} from the team ${n.name}.`))})}}function pn(t,e){return[Pt(t),Ot(t),Lt(t),nn(t),rn(t),Ut(t),Dt(t),jt(t),zt(t),Gt(t),_t(t),$t(t,e),qt(t),Yt(t),Zt(t),At(t),Xt(t),Qt(t),Nt(t),gt(t,e),en(t),tn(t),Ht(t),Wt(t),Bt(t),Kt(t),Vt(t),Jt(t),ln(t),cn(t),dn(t)]}function mn(t){return t.map(e=>{let n=Le[e.name];if(!n)throw new Error(`No title and annotations in the registry table for the tool ${e.name}`);return{name:e.name,title:n.title,description:e.description,inputSchema:Yr.toJSONSchema(e.inputSchema),annotations:n.annotations}})}async function un(){let t=st(),e=new ee(t,()=>at.read()),n=new ne,r=pn(e,n),o=await(async()=>{try{let[{skills:s},{agents:l},a]=await Promise.all([e.listSkills(),e.listAgents(),e.getMe().catch(()=>({brainvaultMode:!0}))]);return be(s.map(f=>f.name),l.map(f=>f.name),{brainvault:a.brainvaultMode!==!1})}catch{return be([],[])}})(),i=new Zr(Ee(t,Q),{capabilities:{tools:{},resources:{},prompts:{}},instructions:o});i.setRequestHandler(oo,async()=>({tools:mn(r)})),i.setRequestHandler(ro,async s=>ht(e,s.params?.cursor)),i.setRequestHandler(no,async()=>({resourceTemplates:[...oe]})),i.setRequestHandler(io,async s=>yt(e,s.params.uri)),i.setRequestHandler(to,async s=>xt(e,s.params?.cursor)),i.setRequestHandler(eo,async s=>kt(e,s.params.name)),i.setRequestHandler(Qr,async s=>{let l=r.find(f=>f.name===s.params.name);if(!l)return{content:[{type:"text",text:"errors.UNKNOWN_TOOL"}],isError:!0};let a=l.inputSchema.safeParse(s.params.arguments??{});return a.success?l.handler(a.data):{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0}}),vt().then(s=>{for(let l of Ze())Ct(e,l,{ignore:s}).catch(()=>{})}).catch(()=>{}),await i.connect(new Xr)}await un();
57
+ Its tools are now available as "${n.slug}__<tool>".`})}}var zr=y.object({slug:Q,name:y.string().min(1).max(80).optional(),url:y.string().url().max(2e3).optional(),transport:y.enum(["http","sse"]).optional(),authType:y.enum(["none","bearer","header"]).optional(),authHeaderName:y.string().max(80).optional(),secret:y.string().max(4e3).optional(),enabled:y.boolean().optional()});function Xt(t){return{name:"connection_update",description:"Change a connected MCP server. Only the fields you pass are touched; url, transport, authType and secret trigger a fresh probe.",inputSchema:zr,handler:e=>F(async()=>{let n=await xe(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{slug:r,...o}=e,{connection:i}=await t.updateConnection(n.id,o);return`Updated.
58
+ ${qe(i)}`})}}var Gr=y.object({slug:Q});function Qt(t){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:Gr,handler:e=>F(async()=>{let n=await xe(t,e.slug);return n?(await t.deleteConnection(n.id),`Disconnected ${e.slug}.`):`Connection not found: ${e.slug}`})}}var Fr=y.object({slug:Q});function en(t){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:Fr,handler:e=>F(async()=>{let n=await xe(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:r}=await t.listCapabilities(n.id);return r.length===0?`${e.slug} has nothing on record yet. Its status is "${n.status}".`:r.map(o=>`${o.enabled?"[on] ":"[off]"} ${o.kind} ${o.name}${o.exposedAs?` -> ${o.exposedAs}`:""}${o.description?` \u2014 ${o.description}`:""}`).join(`
59
+ `)})}}var Hr=y.object({slug:Q,tool:y.string().min(1).max(200),enabled:y.boolean()});function tn(t){return{name:"connection_tool_toggle",description:"Switch one tool of a connected server on or off. A tool that is off costs no room in any client's tool list.",inputSchema:Hr,handler:e=>F(async()=>{let n=await xe(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:r}=await t.listCapabilities(n.id),o=r.find(i=>i.kind==="tool"&&i.name===e.tool);return o?(await t.toggleCapability(n.id,o.id,e.enabled),`${e.slug}__${o.name} is now ${e.enabled?"on":"off"}.`):`${e.slug} offers no tool called ${e.tool}.`})}}import{z as b}from"zod";var Wr=t=>({content:[{type:"text",text:t}]}),ee=t=>({content:[{type:"text",text:t}],isError:!0});async function E(t){try{return Wr(await t())}catch(e){if(e instanceof m){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return ee(`${e.code}${n}`)}return ee("errors.UNKNOWN")}}var j=b.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),Br=b.object({name:j,body:b.string().max(2e5)});function nn(t){return{name:"skill_write",description:"Create a skill or replace the body of an existing one. The body is the whole SKILL.md, frontmatter included.",inputSchema:Br,handler:e=>E(async()=>{let n=await t.putSkill(e.name,e.body);return`${n.name} ${n.updatedAt}`})}}var Kr=b.object({name:j});function rn(t){return{name:"skill_delete",description:"Delete one skill and every file that belongs to it. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Kr,handler:e=>E(async()=>(await t.deleteSkill(e.name),`Deleted skill ${e.name}`))}}var Vr=b.object({skill:j});function on(t){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:Vr,handler:e=>E(async()=>{let{files:n}=await t.getSkill(e.skill);return n.length===0?`${e.skill} has no companion files.`:n.map(r=>`${r.path} (${r.size} bytes, ${r.encoding})`).join(`
60
+ `)})}}var Jr=b.object({skill:j,path:b.string().min(1).max(256),content:b.string().max(3e6),encoding:b.enum(["utf8","base64"]).default("utf8")});function sn(t){return{name:"skill_file_write",description:"Create or replace one companion file of a skill. Use encoding base64 for anything that is not text.",inputSchema:Jr,handler:e=>M(e.path)?E(async()=>{let n=await t.putSkillFile(e.skill,e.path,e.content,e.encoding);return`${e.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(ee("errors.INVALID_PATH"))}}var qr=b.object({skill:j,path:b.string().min(1).max(256)});function an(t){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:qr,handler:e=>M(e.path)?E(async()=>(await t.deleteSkillFile(e.skill,e.path),`Deleted ${e.skill}/${e.path}`)):Promise.resolve(ee("errors.INVALID_PATH"))}}var Yr=b.object({name:j,description:b.string().min(1).max(1e3),body:b.string().max(2e5),model:b.string().max(64).optional(),tools:b.array(b.string().max(128)).max(200).optional()});function ln(t){return{name:"agent_write",description:"Create an agent or replace an existing one. Leave model out to keep the one it already has.",inputSchema:Yr,handler:e=>E(async()=>{let n=await t.getAgent(e.name).catch(()=>null),r=await t.putAgent(e.name,{description:e.description,body:e.body,model:e.model??n?.model??void 0,tools:e.tools??n?.tools??[]});return`${r.name} ${r.updatedAt}`})}}var Zr=b.object({name:j});function cn(t){return{name:"agent_delete",description:"Delete one agent. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Zr,handler:e=>E(async()=>(await t.deleteAgent(e.name),`Deleted agent ${e.name}`))}}var Xr=b.object({});function dn(t){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:Xr,handler:()=>E(async()=>{let{files:e}=await t.listMemory();return e.length===0?"(none)":e.map(n=>n.path+D(n)).sort().join(`
61
+ `)})}}var Qr=b.object({path:b.string().min(3).max(256)});function pn(t){return{name:"memory_delete",description:"Delete one memory file. Moves it to the trash; it can be restored in the dashboard for the trash period (default 7 days).",inputSchema:Qr,handler:e=>k(e.path)?E(async()=>(await t.deleteMemory(e.path),`Deleted ${e.path}`)):Promise.resolve(ee("errors.INVALID_PATH"))}}import{z as L}from"zod";var ke=t=>({content:[{type:"text",text:t}]}),te=t=>({content:[{type:"text",text:t}],isError:!0});async function Ye(t){try{return await t()}catch(e){if(e instanceof m){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return te(`${e.code}${n}`)}return te("errors.UNKNOWN")}}var eo=L.object({}),mn=L.enum(["memory","skill","agent"]),to=L.object({kind:mn,name:L.string().min(1).max(300),team:L.string().min(1).max(200)}),no=L.object({kind:mn,team:L.string().min(1).max(200),name:L.string().min(1).max(300).optional(),id:L.string().uuid().optional()});async function un(t,e){let n=e.trim(),{teams:r}=await t.listTeams(),o=r.find(s=>s.id===n);if(o)return o;let i=r.filter(s=>s.name===n);if(i.length===1)return i[0];if(i.length>1){let s=i.map(c=>c.id).sort();return te(`Several of your teams are named "${e}": ${s.join(", ")}. Pass the id as team.
62
+ errors.TEAM_AMBIGUOUS ${JSON.stringify({team:e,ids:s})}`)}return te(`You are not in that team.
63
+ errors.NOT_A_MEMBER ${JSON.stringify({team:e})}`)}var fn=t=>"content"in t;function gn(t){return{name:"list_teams",description:"List the teams this account is in, one per line: the team id, its name and your role in it.",inputSchema:eo,handler:e=>Ye(async()=>{let{teams:n}=await t.listTeams();if(n.length===0)return ke("(none)");let r=(o,i)=>o<i?-1:o>i?1:0;return ke([...n].sort((o,i)=>r(o.name,i.name)||r(o.id,i.id)).map(o=>`${o.id} ${o.name} ${o.role}`).join(`
64
+ `))})}}function hn(t){return{name:"team_share",description:"Move one of your own memory files, skills or agents into a team, so its members can use it. You need the right to create that kind of content in the team, the team must not hold an item of that name already, and a frozen team takes nothing new.",inputSchema:to,handler:e=>Ye(async()=>{let n=await un(t,e.team);return fn(n)?n:(await t.shareWithTeam(n.id,{kind:e.kind,name:e.name}),ke(`Shared ${e.kind} ${e.name} with the team ${n.name}.`))})}}function yn(t){return{name:"team_return",description:"Take an item out of a team and back under its owner. Name one of your own items, or pass the id of any item of the team if you may delete that kind of content there. The item keeps its owner, and the return is never refused on a quota.",inputSchema:no,handler:e=>e.name===void 0==(e.id===void 0)?Promise.resolve(te("Invalid arguments: pass name or id, not both.")):Ye(async()=>{let n=await un(t,e.team);return fn(n)?n:(await t.returnFromTeam(n.id,e.name!==void 0?{kind:e.kind,name:e.name}:{kind:e.kind,id:e.id}),ke(`Returned ${e.kind} ${e.name??e.id} from the team ${n.name}.`))})}}function bn(t,e){return[zt(t),Gt(t),Dt(t),dn(t),pn(t),Ht(t),Wt(t),Bt(t),Kt(t),Vt(t),Ot(t),Rt(t,e),nn(t),rn(t),on(t),Et(t),sn(t),an(t),Mt(t),kt(t,e),ln(t),cn(t),Yt(t),Zt(t),Xt(t),Qt(t),en(t),tn(t),gn(t),hn(t),yn(t)]}function xn(t){return t.map(e=>{let n=je[e.name];if(!n)throw new Error(`No title and annotations in the registry table for the tool ${e.name}`);return{name:e.name,title:n.title,description:e.description,inputSchema:ro.toJSONSchema(e.inputSchema),annotations:n.annotations}})}async function kn(){let t=mt(),e=new oe(t,()=>ut.read()),n=new se,r=bn(e,n),o=await(async()=>{try{let[{skills:s},{agents:c},a]=await Promise.all([e.listSkills(),e.listAgents(),e.getMe().catch(()=>({brainvaultMode:!0}))]);return Ce(s.map(f=>f.name),c.map(f=>f.name),{brainvault:a.brainvaultMode!==!1})}catch{return Ce([],[])}})(),i=new oo(De(t,re),{capabilities:{tools:{},resources:{},prompts:{}},instructions:o});i.setRequestHandler(mo,async()=>({tools:xn(r)})),i.setRequestHandler(po,async s=>St(e,s.params?.cursor)),i.setRequestHandler(co,async()=>({resourceTemplates:[...le]})),i.setRequestHandler(uo,async s=>wt(e,s.params.uri)),i.setRequestHandler(lo,async s=>At(e,s.params?.cursor)),i.setRequestHandler(ao,async s=>Tt(e,s.params.name)),i.setRequestHandler(so,async s=>{let c=r.find(f=>f.name===s.params.name);if(!c)return{content:[{type:"text",text:"errors.UNKNOWN_TOOL"}],isError:!0};let a=c.inputSchema.safeParse(s.params.arguments??{});return a.success?c.handler(a.data):{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0}}),$t().then(s=>{for(let c of rt())Nt(e,c,{ignore:s}).catch(()=>{})}).catch(()=>{}),await i.connect(new io)}await kn();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onlymcp",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
4
4
  "description": "Skills, agents and memory from the OnlyMCP cloud in every MCP client. Ships the stdio MCP server and the CLI that sets up Claude Code, Codex and Antigravity.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Francesco Palazzo",