onlymcp 0.20.0 → 0.21.2

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,18 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import{cancel as un,confirm as fn,intro as Ue,isCancel as Me,log as d,multiselect as Rr,outro as G,spinner as me}from"@clack/prompts";import{Command as Ur}from"commander";import Dr from"open";import jr from"qrcode";import{homedir as hn}from"node:os";import{createWriteStream as zr,existsSync as $,mkdirSync as Fr}from"node:fs";import{pipeline as Gr}from"node:stream/promises";import{Readable as Hr}from"node:stream";import{dirname as Wr,join as gn}from"node:path";import{hostname as Dn}from"node:os";import{execFile as En}from"node:child_process";import{hostname as On}from"node:os";import{readFile as Nn}from"node:fs/promises";import{promisify as Mn}from"node:util";import{randomUUID as Ge}from"node:crypto";import{link as kn,mkdir as wn,readFile as Sn,rename as Cn,rm as xn,writeFile as He}from"node:fs/promises";import{basename as $n,dirname as Be,join as An}from"node:path";import{existsSync as vn}from"node:fs";import{homedir as je}from"node:os";import{join as N}from"node:path";function J(){return process.env.ONLYMCP_HOME??N(je(),".claude","onlymcp")}function De(){return process.env.ONLYMCP_HOME??je()}function ze(){return N(J(),"device-id")}function Fe(){return N(J(),"cache")}function Y(){return N(J(),"stub-ignore")}function q(){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[N(De(),".claude"),N(De(),".codex")])vn(t)&&!e.includes(t)&&e.push(t);return e.length>0?e:[N(J(),"plugin")]}var Tn=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,We;function Ke(){return We??=Pn(),We}async function ge(e){try{let t=(await Sn(e,"utf8")).trim().toLowerCase();return Tn.test(t)?t:null}catch{return null}}async function Pn(){let e=ze(),t=await ge(e);if(t)return t;try{return await wn(Be(e),{recursive:!0}),await _n(e)}catch{return null}}var In=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function _n(e){let t=Ge(),n=An(Be(e),`.${$n(e)}.${process.pid}.${Ge()}.tmp`);try{await He(n,`${t}
3
- `,{flag:"wx",mode:384});try{return await kn(n,e),t}catch(r){let i=r.code;if(i!=="EEXIST"&&!In.has(i??""))throw r;if(i!=="EEXIST")try{return await He(e,`${t}
4
- `,{flag:"wx",mode:384}),t}catch(s){if(s.code!=="EEXIST")throw s}}let o=await ge(e);return o||(await Cn(n,e),await ge(e)??t)}finally{await xn(n,{force:!0}).catch(()=>{})}}var D="0.20.0";var Ln=Mn(En),Rn=`onlymcp-cli/${D} (${process.platform} ${process.arch}; node ${process.versions.node})`,Ve=200;async function Je(e,t){let n;try{return await Promise.race([e,new Promise(o=>{n=setTimeout(()=>o(null),t),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function Un(){try{if(process.platform==="linux"){let e=Nn("/sys/class/dmi/id/product_version","utf8"),n=(await Je(e,Ve))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let e=Ln("sysctl",["-n","hw.model"]);return(await Je(e,Ve))?.stdout.trim()||null}}catch{}return null}async function he(){let e="unknown";try{e=On()||"unknown"}catch{}let t=await Un();return(t&&t!==e?`${e} (${t})`:e).slice(0,60)}var Ye=null;async function H(){Ye??=await he();let e=await Ke();return{"user-agent":Rn,"x-onlymcp-device":Ye,...e?{"x-onlymcp-device-id":e}:{}}}var u=class extends Error{constructor(n,o={},r=0){super(n);this.code=n;this.params=o;this.status=r;this.name="ApiError"}code;params;status},T=class{constructor(t,n){this.baseUrl=t;this.token=n}baseUrl;token;async call(t,n={}){let o=this.token();if(!o)throw new u("errors.NOT_LOGGED_IN");let r=await fetch(`${this.baseUrl}${t}`,{...n,headers:{...await H(),...n.headers??{},authorization:`Bearer ${o}`,"content-type":"application/json"}});if(r.status===204)return;let i=await r.json().catch(()=>({}));if(!r.ok)throw new u(i.code??"errors.UNKNOWN",i.params??{},r.status);return i}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){return this.call(`/api/skills/${encodeURIComponent(t)}`)}putSkill(t,n,o={}){return this.call(`/api/skills/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({body:n,...o})})}skillFileUrl(t,n){let o=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(t)}/files/${o}`}getSkillFile(t,n){return this.call(this.skillFileUrl(t,n))}putSkillFile(t,n,o,r="utf8"){return this.call(this.skillFileUrl(t,n),{method:"PUT",body:JSON.stringify({content:o,encoding:r})})}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}={}){return this.call(`/api/agents/${encodeURIComponent(t)}${n?"?use=1":""}`)}readMemory(t){return this.call(this.memoryUrl(t))}writeMemory(t,n,o){return this.call(this.memoryUrl(t),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:o})})}memoryUrl(t){return`/api/memory/${t.split("/").map(encodeURIComponent).join("/")}`}listMemory(){return this.call("/api/memory")}searchContent(t,n={}){let o=new URLSearchParams({q:t});return n.types?.length&&o.set("types",n.types.join(",")),n.limit&&o.set("limit",String(n.limit)),this.call(`/api/search?${o.toString()}`)}memoryTree(t="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(t)}`)}moveMemory(t,n,o=!0,r=Dn()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:t,to:n,updateLinks:o,deviceLabel:r})})}async exportArchive(t={}){let n=this.token();if(!n)throw new u("errors.NOT_LOGGED_IN");let o=new URLSearchParams;t.scope&&o.set("scope",t.scope),t.types?.length&&o.set("types",t.types.join(","));let r=o.size>0?`?${o.toString()}`:"",i=await fetch(`${this.baseUrl}/api/export${r}`,{headers:{...await H(),authorization:`Bearer ${n}`}});if(!i.ok){let s=await i.json().catch(()=>({}));throw new u(s.code??"errors.UNKNOWN",s.params??{},i.status)}return i}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")}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,o){return this.call(`/api/mcp-connections/${t}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:o})})}};import{Entry as jn}from"@napi-rs/keyring";function zn(e,t){let n=()=>new jn(e,t);return{save(o){n().setPassword(o)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var A=zn("onlymcp","session-token");var Fn={sleep:e=>new Promise(t=>setTimeout(t,e))};async function qe(e,t,n,o=Fn){let r=n;for(;;){await o.sleep(r*1e3);let s=await(await fetch(`${e}/api/auth/device/token`,{method:"POST",headers:{...await H(),"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":r+=5;break;case"access_denied":throw new u("errors.DEVICE_ACCESS_DENIED");case"expired_token":throw new u("errors.DEVICE_CODE_EXPIRED");default:throw new u("errors.DEVICE_LOGIN_FAILED",{error:s.error})}}}import Z from"cacache";var Gn=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),j=class{constructor(t=Fe()){this.dir=t}dir;async get(t){try{let n=await Z.get(this.dir,t),o=n.metadata;return!o||o.expiresAt<=Date.now()?(await Z.rm.entry(this.dir,t),null):n.data.toString("utf8")}catch{return null}}async set(t,n,o=Gn){await Z.put(this.dir,t,n,{metadata:{expiresAt:Date.now()+o*1e3}})}async clear(){await Z.rm.all(this.dir)}};import{appendFileSync as ro,existsSync as Q,mkdirSync as Xe,readFileSync as et,writeFileSync as io}from"node:fs";import{dirname as tt,join as so}from"node:path";function Ze(e){return{language:"bash",text:e}}function E(e,t){return{language:"json",text:JSON.stringify(e,null,2),path:t}}var Hn={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=>[Ze(`claude mcp add --transport http --scope user onlymcp ${e.endpoint} --header "Authorization: Bearer ${e.token}"`)]},Wn={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},Bn={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},Kn={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=>[Ze([`export ONLYMCP_TOKEN=${e.token}`,`codex mcp add onlymcp --url ${e.endpoint} --bearer-token-env-var ONLYMCP_TOKEN`].join(`
5
- `))]},Vn={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-17",caveats:[],install:{configPath:"~/.gemini/config/mcp_config.json",format:"json",stubDir:null},oauthRedirectHosts:["antigravity.google"],remote:e=>[E({mcpServers:{onlymcp:{serverUrl:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.gemini/config/mcp_config.json")]},Jn={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},Yn={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},qn={id:"copilot-vscode",name:"GitHub Copilot (VS Code)",category:"ide",brand:"githubcopilot",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://code.visualstudio.com/docs/agents/reference/mcp-configuration",verifiedOn:"2026-09-25",caveats:["clients.caveat.copilotPolicy"],install:null,remote:e=>[E({servers:{onlymcp:{type:"http",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},".vscode/mcp.json")]},Zn={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,remote:e=>[E({mcpServers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cursor/mcp.json")]},Xn={id:"windsurf",name:"Windsurf",category:"ide",brand:"windsurf",methods:["remote-header","stdio"],docsUrl:"https://docs.windsurf.com/windsurf/cascade/mcp",verifiedOn:"2026-09-25",caveats:["clients.caveat.windsurfAllowlist"],install:null,remote:e=>[E({mcpServers:{onlymcp:{serverUrl:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.codeium/windsurf/mcp_config.json")]},Qn={id:"cline",name:"Cline",category:"ide",brand:"cline",methods:["remote-header","stdio"],docsUrl:"https://docs.cline.bot/mcp/mcp-overview",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[E({mcpServers:{onlymcp:{type:"streamableHttp",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cline/mcp.json")]},eo={id:"zed",name:"Zed",category:"ide",brand:"zedindustries",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://zed.dev/docs/assistant/model-context-protocol",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[E({context_servers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"settings.json")]},to={id:"continue",name:"Continue",category:"ide",brand:null,methods:["remote-header","stdio"],docsUrl:"https://docs.continue.dev/customize/deep-dives/mcp",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[{language:"yaml",path:"config.yaml",text:["mcpServers:"," - name: onlymcp"," type: streamable-http",` url: ${e.endpoint}`," requestOptions:"," headers:",` Authorization: Bearer ${e.token}`].join(`
6
- `)}]},no={id:"opencode",name:"opencode",category:"coding",brand:"opencode",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://opencode.ai/docs/mcp-servers/",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[E({mcp:{onlymcp:{type:"remote",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"opencode.json")]},oo={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-18",caveats:["clients.caveat.gitlabDuoUserFile"],install:null,remote:e=>[E({mcpServers:{onlymcp:{type:"http",url:e.endpoint}}},"~/.gitlab/duo/mcp.json")]},X=[Wn,Bn,Jn,Yn,Hn,Kn,Vn,no,qn,Zn,Xn,Qn,eo,to,oo];function ye(e){return X.find(t=>t.id===e||t.aliases?.includes(e))}function be(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 o=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:t,websiteUrl:o,icons:[{src:`${o}/brand/connector-512.png`,mimeType:"image/png"},{src:`${o}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}var w=e=>({title:e,annotations:{readOnlyHint:!0,openWorldHint:!1}}),S=(e,t)=>({title:e,annotations:{readOnlyHint:!1,destructiveHint:t.destructive,idempotentHint:t.idempotent,openWorldHint:t.openWorld??!1}}),ve={list_memory:w("List memory files"),memory_read:w("Read a memory file"),memory_write:S("Write a memory file",{destructive:!0,idempotent:!0}),memory_delete:S("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:w("Search memory"),memory_tree:w("Show the memory tree"),memory_move:S("Move a memory file or folder",{destructive:!1,idempotent:!1}),memory_links:w("Show memory links"),list_skills:w("List skills"),get_skill:w("Load a skill"),skill_write:S("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:S("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:w("List skill files"),get_skill_file:w("Read a skill file"),skill_file_write:S("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:S("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:w("List agents"),get_agent_definition:w("Load an agent definition"),agent_write:S("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:S("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:w("List connections"),connection_create:S("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:S("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:S("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:w("List a connection's tools"),connection_tool_toggle:S("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:w("Show a connection tool's schema"),connection_call:S("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0})};var ao="onlymcp",we="npx",Se=["-y","-p",ao,"onlymcp-mcp"],nt='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 ke(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function lo(e){return JSON.stringify({mcpServers:{onlymcp:e?{command:we,args:Se,env:e}:{command:we,args:Se}}},null,2)}function co(e){let t=["[mcp_servers.onlymcp]",`command = ${ke(we)}`,`args = [${Se.map(ke).join(", ")}]`];for(let[n,o]of Object.entries(e??{}))t.push(`env = { ${n} = ${ke(o)} }`);return`${t.join(`
2
+ import{cancel as gn,confirm as fn,intro as De,isCancel as Le,log as d,multiselect as Ui,outro as G,spinner as me}from"@clack/prompts";import{Command as Di}from"commander";import ji from"open";import zi from"qrcode";import{homedir as yn}from"node:os";import{createWriteStream as Fi,existsSync as $,mkdirSync as Gi}from"node:fs";import{pipeline as Hi}from"node:stream/promises";import{Readable as Wi}from"node:stream";import{dirname as Bi,join as hn}from"node:path";import{hostname as jn}from"node:os";import{execFile as On}from"node:child_process";import{hostname as Nn}from"node:os";import{readFile as Mn}from"node:fs/promises";import{promisify as Ln}from"node:util";import{randomUUID as He}from"node:crypto";import{link as wn,mkdir as Sn,readFile as Cn,rename as xn,rm as $n,writeFile as We}from"node:fs/promises";import{basename as An,dirname as Ke,join as Tn}from"node:path";import{existsSync as kn}from"node:fs";import{homedir as ze}from"node:os";import{join as N}from"node:path";function J(){return process.env.ONLYMCP_HOME??N(ze(),".claude","onlymcp")}function je(){return process.env.ONLYMCP_HOME??ze()}function Fe(){return N(J(),"device-id")}function Ge(){return N(J(),"cache")}function Y(){return N(J(),"stub-ignore")}function q(){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[N(je(),".claude"),N(je(),".codex")])kn(t)&&!e.includes(t)&&e.push(t);return e.length>0?e:[N(J(),"plugin")]}var Pn=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,Be;function Ve(){return Be??=In(),Be}async function fe(e){try{let t=(await Cn(e,"utf8")).trim().toLowerCase();return Pn.test(t)?t:null}catch{return null}}async function In(){let e=Fe(),t=await fe(e);if(t)return t;try{return await Sn(Ke(e),{recursive:!0}),await En(e)}catch{return null}}var _n=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function En(e){let t=He(),n=Tn(Ke(e),`.${An(e)}.${process.pid}.${He()}.tmp`);try{await We(n,`${t}
3
+ `,{flag:"wx",mode:384});try{return await wn(n,e),t}catch(i){let r=i.code;if(r!=="EEXIST"&&!_n.has(r??""))throw i;if(r!=="EEXIST")try{return await We(e,`${t}
4
+ `,{flag:"wx",mode:384}),t}catch(s){if(s.code!=="EEXIST")throw s}}let o=await fe(e);return o||(await xn(n,e),await fe(e)??t)}finally{await $n(n,{force:!0}).catch(()=>{})}}var D="0.21.2";var Rn=Ln(On),Un=`onlymcp-cli/${D} (${process.platform} ${process.arch}; node ${process.versions.node})`,Je=200;async function Ye(e,t){let n;try{return await Promise.race([e,new Promise(o=>{n=setTimeout(()=>o(null),t),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function Dn(){try{if(process.platform==="linux"){let e=Mn("/sys/class/dmi/id/product_version","utf8"),n=(await Ye(e,Je))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let e=Rn("sysctl",["-n","hw.model"]);return(await Ye(e,Je))?.stdout.trim()||null}}catch{}return null}async function he(){let e="unknown";try{e=Nn()||"unknown"}catch{}let t=await Dn();return(t&&t!==e?`${e} (${t})`:e).slice(0,60)}var qe=null;async function H(){qe??=await he();let e=await Ve();return{"user-agent":Un,"x-onlymcp-device":qe,...e?{"x-onlymcp-device-id":e}:{}}}var u=class extends Error{constructor(n,o={},i=0){super(n);this.code=n;this.params=o;this.status=i;this.name="ApiError"}code;params;status},T=class{constructor(t,n){this.baseUrl=t;this.token=n}baseUrl;token;async call(t,n={}){let o=this.token();if(!o)throw new u("errors.NOT_LOGGED_IN");let i=await fetch(`${this.baseUrl}${t}`,{...n,headers:{...await H(),...n.headers??{},authorization:`Bearer ${o}`,"content-type":"application/json"}});if(i.status===204)return;let r=await i.json().catch(()=>({}));if(!i.ok)throw new u(r.code??"errors.UNKNOWN",r.params??{},i.status);return r}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){return this.call(`/api/skills/${encodeURIComponent(t)}`)}putSkill(t,n,o={}){return this.call(`/api/skills/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({body:n,...o})})}skillFileUrl(t,n){let o=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(t)}/files/${o}`}getSkillFile(t,n){return this.call(this.skillFileUrl(t,n))}putSkillFile(t,n,o,i="utf8"){return this.call(this.skillFileUrl(t,n),{method:"PUT",body:JSON.stringify({content:o,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}={}){return this.call(`/api/agents/${encodeURIComponent(t)}${n?"?use=1":""}`)}readMemory(t){return this.call(this.memoryUrl(t))}writeMemory(t,n,o){return this.call(this.memoryUrl(t),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:o})})}memoryUrl(t){return`/api/memory/${t.split("/").map(encodeURIComponent).join("/")}`}listMemory(){return this.call("/api/memory")}searchContent(t,n={}){let o=new URLSearchParams({q:t});return n.types?.length&&o.set("types",n.types.join(",")),n.limit&&o.set("limit",String(n.limit)),this.call(`/api/search?${o.toString()}`)}memoryTree(t="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(t)}`)}moveMemory(t,n,o=!0,i=jn()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:t,to:n,updateLinks:o,deviceLabel:i})})}async exportArchive(t={}){let n=this.token();if(!n)throw new u("errors.NOT_LOGGED_IN");let o=new URLSearchParams;t.scope&&o.set("scope",t.scope),t.types?.length&&o.set("types",t.types.join(","));let i=o.size>0?`?${o.toString()}`:"",r=await fetch(`${this.baseUrl}/api/export${i}`,{headers:{...await H(),authorization:`Bearer ${n}`}});if(!r.ok){let s=await r.json().catch(()=>({}));throw new u(s.code??"errors.UNKNOWN",s.params??{},r.status)}return r}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")}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,o){return this.call(`/api/mcp-connections/${t}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:o})})}};import{Entry as zn}from"@napi-rs/keyring";function Fn(e,t){let n=()=>new zn(e,t);return{save(o){n().setPassword(o)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var A=Fn("onlymcp","session-token");var Gn={sleep:e=>new Promise(t=>setTimeout(t,e))};async function Ze(e,t,n,o=Gn){let i=n;for(;;){await o.sleep(i*1e3);let s=await(await fetch(`${e}/api/auth/device/token`,{method:"POST",headers:{...await H(),"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 u("errors.DEVICE_ACCESS_DENIED");case"expired_token":throw new u("errors.DEVICE_CODE_EXPIRED");default:throw new u("errors.DEVICE_LOGIN_FAILED",{error:s.error})}}}import Z from"cacache";var Hn=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),j=class{constructor(t=Ge()){this.dir=t}dir;async get(t){try{let n=await Z.get(this.dir,t),o=n.metadata;return!o||o.expiresAt<=Date.now()?(await Z.rm.entry(this.dir,t),null):n.data.toString("utf8")}catch{return null}}async set(t,n,o=Hn){await Z.put(this.dir,t,n,{metadata:{expiresAt:Date.now()+o*1e3}})}async clear(){await Z.rm.all(this.dir)}};import{appendFileSync as io,existsSync as Q,mkdirSync as Qe,readFileSync as tt,writeFileSync as ro}from"node:fs";import{dirname as nt,join as so}from"node:path";function Xe(e){return{language:"bash",text:e}}function E(e,t){return{language:"json",text:JSON.stringify(e,null,2),path:t}}var Wn={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=>[Xe(`claude mcp add --transport http --scope user onlymcp ${e.endpoint} --header "Authorization: Bearer ${e.token}"`)]},Bn={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},Kn={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},Vn={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=>[Xe([`export ONLYMCP_TOKEN=${e.token}`,`codex mcp add onlymcp --url ${e.endpoint} --bearer-token-env-var ONLYMCP_TOKEN`].join(`
5
+ `))]},Jn={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-17",caveats:[],install:{configPath:"~/.gemini/config/mcp_config.json",format:"json",stubDir:null},oauthRedirectHosts:["antigravity.google"],remote:e=>[E({mcpServers:{onlymcp:{serverUrl:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.gemini/config/mcp_config.json")]},Yn={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},qn={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},Zn={id:"copilot-vscode",name:"GitHub Copilot (VS Code)",category:"ide",brand:"githubcopilot",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://code.visualstudio.com/docs/agents/reference/mcp-configuration",verifiedOn:"2026-09-25",caveats:["clients.caveat.copilotPolicy"],install:null,remote:e=>[E({servers:{onlymcp:{type:"http",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},".vscode/mcp.json")]},Xn={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,remote:e=>[E({mcpServers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cursor/mcp.json")]},Qn={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-23",caveats:["clients.caveat.windsurfAllowlist"],install:null,remote:e=>[E({mcpServers:{onlymcp:{serverUrl:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.config/devin/mcp_config.json")]},eo={id:"cline",name:"Cline",category:"ide",brand:"cline",methods:["remote-header","stdio"],docsUrl:"https://docs.cline.bot/mcp/mcp-overview",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[E({mcpServers:{onlymcp:{type:"streamableHttp",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"~/.cline/mcp.json")]},to={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=>[E({context_servers:{onlymcp:{url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"settings.json")]},no={id:"opencode",name:"opencode",category:"coding",brand:"opencode",methods:["remote-header","remote-oauth","stdio"],docsUrl:"https://opencode.ai/docs/mcp-servers/",verifiedOn:"2026-09-25",caveats:[],install:null,remote:e=>[E({mcp:{onlymcp:{type:"remote",url:e.endpoint,headers:{Authorization:`Bearer ${e.token}`}}}},"opencode.json")]},oo={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-18",caveats:["clients.caveat.gitlabDuoUserFile"],install:null,remote:e=>[E({mcpServers:{onlymcp:{type:"http",url:e.endpoint}}},"~/.gitlab/duo/mcp.json")]},X=[Bn,Kn,Yn,qn,Wn,Vn,Jn,no,Zn,Xn,Qn,eo,to,oo];function ye(e){return X.find(t=>t.id===e||t.aliases?.includes(e))}function be(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 o=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:t,websiteUrl:o,icons:[{src:`${o}/brand/connector-512.png`,mimeType:"image/png"},{src:`${o}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}var w=e=>({title:e,annotations:{title:e,readOnlyHint:!0,openWorldHint:!1}}),S=(e,t)=>({title:e,annotations:{title:e,readOnlyHint:!1,destructiveHint:t.destructive,idempotentHint:t.idempotent,openWorldHint:t.openWorld??!1}}),ve={list_memory:w("List memory files"),memory_read:w("Read a memory file"),memory_write:S("Write a memory file",{destructive:!0,idempotent:!0}),memory_delete:S("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:w("Search memory"),memory_tree:w("Show the memory tree"),memory_move:S("Move a memory file or folder",{destructive:!1,idempotent:!1}),memory_links:w("Show memory links"),list_skills:w("List skills"),get_skill:w("Load a skill"),skill_write:S("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:S("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:w("List skill files"),get_skill_file:w("Read a skill file"),skill_file_write:S("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:S("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:w("List agents"),get_agent_definition:w("Load an agent definition"),agent_write:S("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:S("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:w("List connections"),connection_create:S("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:S("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:S("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:w("List a connection's tools"),connection_tool_toggle:S("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:w("Show a connection tool's schema"),connection_call:S("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0})};var ao="onlymcp",we="npx",Se=["-y","-p",ao,"onlymcp-mcp"],ot='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 ke(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function lo(e){return JSON.stringify({mcpServers:{onlymcp:e?{command:we,args:Se,env:e}:{command:we,args:Se}}},null,2)}function co(e){let t=["[mcp_servers.onlymcp]",`command = ${ke(we)}`,`args = [${Se.map(ke).join(", ")}]`];for(let[n,o]of Object.entries(e??{}))t.push(`env = { ${n} = ${ke(o)} }`);return`${t.join(`
7
6
  `)}
8
- `}var po={claude:"claude-code",gemini:"antigravity"};function ot(){return X.filter(e=>e.install!==null)}var mo=new Set(ot().map(e=>e.id));function uo(e){let t=po[e]??ye(e)?.id;return t&&mo.has(t)?t:void 0}function Qe(e,t){return e.startsWith("~/")?so(t,e.slice(2)):e}function fo(e){return ot().map(t=>{let n=Qe(t.install.configPath,e),o=t.install.stubDir?Qe(t.install.stubDir,e):null,r=o?tt(o):null,i=t.install.format==="toml"?co(r?{ONLYMCP_STUB_DIRS:r}:void 0):lo();return{id:t.id,name:t.name,configPath:n,format:t.install.format,stubDir:o,stubRoot:r,snippet:i}})}function go(e,t,n){let o={};if(Q(e)){let i=et(e,"utf8").trim();if(i)try{o=JSON.parse(i)}catch{throw new Error(`${e} contains invalid JSON. Nothing written.`)}}let r=o.mcpServers??{};o.mcpServers={...r,[t]:n},io(e,`${JSON.stringify(o,null,2)}
9
- `,"utf8")}function ho(e,t){return Q(e)&&et(e,"utf8").includes("[mcp_servers.onlymcp]")?"already-present":(ro(e,`
10
- ${t}`),"written")}function rt(e,t){let n=fo(e);if(t.all){if(t.client)return{kind:"conflicting-options"};let i=n.filter(p=>Q(p.configPath)),s=n.filter(p=>!Q(p.configPath));return i.length===0?{kind:"none-present-for-all",targets:n}:{kind:"all",present:i,skipped:s}}if(!t.client)return{kind:"missing-client",targets:n};let o=uo(t.client),r=o?n.find(i=>i.id===o):void 0;return r?{kind:"single",target:r}:{kind:"unknown-client",targets:n}}function it(e){Xe(tt(e.configPath),{recursive:!0});let t=e.format==="toml"?ho(e.configPath,e.snippet):(()=>{let n=JSON.parse(e.snippet),o=Object.entries(n.mcpServers)[0];if(!o)throw new Error(`${e.name}: empty mcpServers snippet.`);return go(e.configPath,o[0],o[1]),"written"})();return e.stubDir&&Xe(e.stubDir,{recursive:!0}),t}import{access as wo,mkdir as xe,readFile as So,rm as pt,writeFile as te}from"node:fs/promises";import{dirname as Co,join as B}from"node:path";function W(e){if(!e.startsWith(`---
7
+ `}var po={claude:"claude-code",gemini:"antigravity"};function it(){return X.filter(e=>e.install!==null)}var mo=new Set(it().map(e=>e.id));function uo(e){let t=po[e]??ye(e)?.id;return t&&mo.has(t)?t:void 0}function et(e,t){return e.startsWith("~/")?so(t,e.slice(2)):e}function go(e){return it().map(t=>{let n=et(t.install.configPath,e),o=t.install.stubDir?et(t.install.stubDir,e):null,i=o?nt(o):null,r=t.install.format==="toml"?co(i?{ONLYMCP_STUB_DIRS:i}:void 0):lo();return{id:t.id,name:t.name,configPath:n,format:t.install.format,stubDir:o,stubRoot:i,snippet:r}})}function fo(e,t,n){let o={};if(Q(e)){let r=tt(e,"utf8").trim();if(r)try{o=JSON.parse(r)}catch{throw new Error(`${e} contains invalid JSON. Nothing written.`)}}let i=o.mcpServers??{};o.mcpServers={...i,[t]:n},ro(e,`${JSON.stringify(o,null,2)}
8
+ `,"utf8")}function ho(e,t){return Q(e)&&tt(e,"utf8").includes("[mcp_servers.onlymcp]")?"already-present":(io(e,`
9
+ ${t}`),"written")}function rt(e,t){let n=go(e);if(t.all){if(t.client)return{kind:"conflicting-options"};let r=n.filter(p=>Q(p.configPath)),s=n.filter(p=>!Q(p.configPath));return r.length===0?{kind:"none-present-for-all",targets:n}:{kind:"all",present:r,skipped:s}}if(!t.client)return{kind:"missing-client",targets:n};let o=uo(t.client),i=o?n.find(r=>r.id===o):void 0;return i?{kind:"single",target:i}:{kind:"unknown-client",targets:n}}function st(e){Qe(nt(e.configPath),{recursive:!0});let t=e.format==="toml"?ho(e.configPath,e.snippet):(()=>{let n=JSON.parse(e.snippet),o=Object.entries(n.mcpServers)[0];if(!o)throw new Error(`${e.name}: empty mcpServers snippet.`);return fo(e.configPath,o[0],o[1]),"written"})();return e.stubDir&&Qe(e.stubDir,{recursive:!0}),t}import{access as wo,mkdir as xe,readFile as So,rm as dt,writeFile as te}from"node:fs/promises";import{dirname as Co,join as B}from"node:path";function W(e){if(!e.startsWith(`---
11
10
  `))return null;let t=e.indexOf(`
12
- ---`,3);return t<0?null:e.slice(4,t)}function O(e,t){if(!/^[a-zA-Z0-9_-]+$/.test(t))return;let n=new RegExp(`^${t}:[ \\t]*(.*)$`,"m").exec(e);if(!n)return;let r=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return r.length>0?r:void 0}function st(e){let t=W(e);if(t===null)return null;let n=O(t,"description");if(!n)return null;let o=O(t,"tools"),r=o?o.replace(/^\[(.*)\]$/,"$1").split(",").map(s=>s.trim()).filter(s=>s.length>0):[],i=O(t,"model");return i?{description:n,model:i,tools:r}:{description:n,tools:r}}function at(e){let t=W(e);return(t===null?void 0:O(t,"description"))??""}function lt(e){let t=W(e);return t===null?!1:O(t,"x-onlymcp-stub")==="true"}function ct(e){if(!e.startsWith(`---
11
+ ---`,3);return t<0?null:e.slice(4,t)}function O(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 at(e){let t=W(e);if(t===null)return null;let n=O(t,"description");if(!n)return null;let o=O(t,"tools"),i=o?o.replace(/^\[(.*)\]$/,"$1").split(",").map(s=>s.trim()).filter(s=>s.length>0):[],r=O(t,"model");return r?{description:n,model:r,tools:i}:{description:n,tools:i}}function lt(e){let t=W(e);return(t===null?void 0:O(t,"description"))??""}function ct(e){let t=W(e);return t===null?!1:O(t,"x-onlymcp-stub")==="true"}function pt(e){if(!e.startsWith(`---
13
12
  `))return e;let t=e.indexOf(`
14
13
  ---`,3);if(t<0)return e;let n=e.indexOf(`
15
- `,t+4);return n<0?"":e.slice(n+1)}import{readFile as yo}from"node:fs/promises";var Ce=()=>!1;function bo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vo(e){let t=e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(bo).join(".*")}$`));return n=>t.some(o=>o.test(n))}async function ee(e=Y()){try{return vo(await yo(e,"utf8"))}catch(t){if(t.code==="ENOENT")return Ce;throw t}}var ko=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function M(e){if(e.length===0||e.length>200||e==="SKILL.md")return!1;let t=e.split("/");return t.length>8?!1:t.every(n=>ko.test(n)&&n!==".."&&n!==".")}var xo=/^[a-z0-9]+(-[a-z0-9]+)*$/,$o=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,$e="x-onlymcp-stub";function ne(e){return e.replace(/:/g,"-")}function oe(e){return(e??"").replace(/[\r\n]+/g," ").trim()}async function Ae(e,t){let n;try{n=await So(e,"utf8")}catch{return!0}let o=W(n);if(o===null||O(o,$e)!=="true")return!1;let r=O(o,"x-onlymcp-name");return r===void 0||r===t}async function dt(e,t){return await wo(e).then(()=>!0,()=>!1)&&await Ae(e,t)}async function re(e,t,n={}){let o=n.ignore??Ce,[{skills:r},{agents:i}]=await Promise.all([e.listSkills(),e.listAgents()]),s=0,p=0,a=[],l=[],c=0;for(let m of r){if(!$o.test(m.name))continue;let b=B(t,"skills",ne(m.name)),v=B(b,"SKILL.md");if(o(m.name)||o(ne(m.name))){l.push(m.name),await dt(v,m.name)&&(await pt(b,{recursive:!0,force:!0}),c+=1);continue}if(!await Ae(v,m.name)){a.push(`skills/${ne(m.name)}`);continue}await xe(b,{recursive:!0}),await te(v,`---
14
+ `,t+4);return n<0?"":e.slice(n+1)}import{readFile as yo}from"node:fs/promises";var Ce=()=>!1;function bo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vo(e){let t=e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(bo).join(".*")}$`));return n=>t.some(o=>o.test(n))}async function ee(e=Y()){try{return vo(await yo(e,"utf8"))}catch(t){if(t.code==="ENOENT")return Ce;throw t}}var ko=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function M(e){if(e.length===0||e.length>200||e==="SKILL.md")return!1;let t=e.split("/");return t.length>8?!1:t.every(n=>ko.test(n)&&n!==".."&&n!==".")}var xo=/^[a-z0-9]+(-[a-z0-9]+)*$/,$o=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,$e="x-onlymcp-stub";function ne(e){return e.replace(/:/g,"-")}function oe(e){return(e??"").replace(/[\r\n]+/g," ").trim()}async function Ae(e,t){let n;try{n=await So(e,"utf8")}catch{return!0}let o=W(n);if(o===null||O(o,$e)!=="true")return!1;let i=O(o,"x-onlymcp-name");return i===void 0||i===t}async function mt(e,t){return await wo(e).then(()=>!0,()=>!1)&&await Ae(e,t)}async function ie(e,t,n={}){let o=n.ignore??Ce,[{skills:i},{agents:r}]=await Promise.all([e.listSkills(),e.listAgents()]),s=0,p=0,a=[],l=[],c=0;for(let m of i){if(!$o.test(m.name))continue;let b=B(t,"skills",ne(m.name)),v=B(b,"SKILL.md");if(o(m.name)||o(ne(m.name))){l.push(m.name),await mt(v,m.name)&&(await dt(b,{recursive:!0,force:!0}),c+=1);continue}if(!await Ae(v,m.name)){a.push(`skills/${ne(m.name)}`);continue}await xe(b,{recursive:!0}),await te(v,`---
16
15
  name: ${ne(m.name)}
17
16
  description: ${oe(m.description)||"Synchronisiert ueber OnlyMCP. Inhalt wird bei Bedarf geladen."}
18
17
  ${$e}: true
@@ -20,50 +19,56 @@ x-onlymcp-name: ${m.name}
20
19
  ---
21
20
 
22
21
  Call \`get_skill({ name: "${m.name}" })\` on the OnlyMCP server and follow whatever comes back.
23
- `,"utf8"),p+=1;try{let f=await e.getSkill(m.name);for(let k of f.files??[]){if(!M(k.path))continue;let ue=await e.getSkillFile(m.name,k.path),fe=B(b,...k.path.split("/"));await xe(Co(fe),{recursive:!0}),ue.encoding==="base64"?await te(fe,Buffer.from(ue.content,"base64")):await te(fe,ue.content,"utf8"),s+=1}}catch{}}await xe(B(t,"agents"),{recursive:!0});let h=0;for(let m of i){if(!xo.test(m.name))continue;let b=B(t,"agents",`${m.name}.md`);if(o(m.name)){l.push(m.name),await dt(b,m.name)&&(await pt(b),c+=1);continue}if(!await Ae(b,m.name)){a.push(`agents/${m.name}.md`);continue}let v=oe(m.description),f=m.model?oe(m.model):"",k=m.tools.map(oe).join(", ");await te(b,`---
22
+ `,"utf8"),p+=1;try{let g=await e.getSkill(m.name);for(let k of g.files??[]){if(!M(k.path))continue;let ue=await e.getSkillFile(m.name,k.path),ge=B(b,...k.path.split("/"));await xe(Co(ge),{recursive:!0}),ue.encoding==="base64"?await te(ge,Buffer.from(ue.content,"base64")):await te(ge,ue.content,"utf8"),s+=1}}catch{}}await xe(B(t,"agents"),{recursive:!0});let h=0;for(let m of r){if(!xo.test(m.name))continue;let b=B(t,"agents",`${m.name}.md`);if(o(m.name)){l.push(m.name),await mt(b,m.name)&&(await dt(b),c+=1);continue}if(!await Ae(b,m.name)){a.push(`agents/${m.name}.md`);continue}let v=oe(m.description),g=m.model?oe(m.model):"",k=m.tools.map(oe).join(", ");await te(b,`---
24
23
  name: ${m.name}
25
24
  description: ${v}
26
- ${f?`model: ${f}
25
+ ${g?`model: ${g}
27
26
  `:""}tools: ${k}
28
27
  ${$e}: true
29
28
  x-onlymcp-name: ${m.name}
30
29
  ---
31
30
 
32
31
  Call \`get_agent_definition({ name: "${m.name}" })\` on the OnlyMCP server and follow whatever comes back.
33
- `,"utf8"),h+=1}return{skills:p,agents:h,files:s,kept:a,ignored:l,removed:c}}import{Server as rr}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as ir}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as sr,ListToolsRequestSchema as ar}from"@modelcontextprotocol/sdk/types.js";var Ao="https://only-mcp.com";function mt(e=process.env.ONLYMCP_API_URL){if(e===void 0)return Ao;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 ut=["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(" "),To=["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 ft(e,t,n,o){if(n.length===0)return"";let r=[];for(let p of n){let a=n.length-r.length-1,l=a>0?` (+${a} more, call ${t})`:"",c=`
32
+ `,"utf8"),h+=1}return{skills:p,agents:h,files:s,kept:a,ignored:l,removed:c}}import{Server as ri}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as si}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as ai,ListToolsRequestSchema as li}from"@modelcontextprotocol/sdk/types.js";var Ao="https://only-mcp.com";function ut(e=process.env.ONLYMCP_API_URL){if(e===void 0)return Ao;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 gt=["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(" "),To=["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 ft(e,t,n,o){if(n.length===0)return"";let i=[];for(let p of n){let a=n.length-i.length-1,l=a>0?` (+${a} more, call ${t})`:"",c=`
34
33
 
35
- ${e}: ${[...r,p].join(", ")}${l}`;if(o+c.length>1800)break;r.push(p)}if(r.length===0)return`
34
+ ${e}: ${[...i,p].join(", ")}${l}`;if(o+c.length>1800)break;i.push(p)}if(i.length===0)return`
36
35
 
37
- ${e}: call ${t}`;let i=n.length-r.length,s=i>0?` (+${i} more, call ${t})`:"";return`
36
+ ${e}: call ${t}`;let r=n.length-i.length,s=r>0?` (+${r} more, call ${t})`:"";return`
38
37
 
39
- ${e}: ${r.join(", ")}${s}`}function Te(e,t,n={}){let o=n.brainvault===!1?ut:`${ut} ${To}`,r=t.length>0?26:0;return o+=ft("Skills","list_skills",e,o.length+r),o+=ft("Agents","list_agents",t,o.length),o}import{z as or}from"zod";import{z as gt}from"zod";var Po=gt.object({name:gt.string().min(1).max(64)});function ht(e,t){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:Po,async handler(n){let o=`agent:${n.name}`,r=await t.get(o);if(r!==null)return{content:[{type:"text",text:r}]};try{let i=await e.getAgent(n.name,{use:!0});return await t.set(o,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof u?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Pe}from"zod";var Io=Pe.object({name:Pe.string().min(1).max(64),path:Pe.string().min(1).max(200)});function yt(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:Io,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 u?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as bt}from"zod";var _o=bt.object({name:bt.string().min(1).max(64)});function vt(e,t){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:_o,async handler(n){let o=`skill:${n.name}`,r=await t.get(o);if(r!==null)return{content:[{type:"text",text:r}]};try{let i=await e.getSkill(n.name);return await t.set(o,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof u?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Eo}from"zod";var kt=Eo.object({});function wt(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:kt,async handler(){try{let{skills:t}=await e.listSkills();return{content:[{type:"text",text:t.map(n=>n.name).join(`
40
- `)}]}}catch(t){return{content:[{type:"text",text:t instanceof u?t.code:"errors.UNKNOWN"}],isError:!0}}}}}function St(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:kt,async handler(){try{let{agents:t}=await e.listAgents();return{content:[{type:"text",text:t.map(o=>`${o.name}: ${o.description}`).join(`
41
- `)}]}}catch(t){return{content:[{type:"text",text:t instanceof u?t.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Ct}from"zod";var Oo=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function C(e){return Oo.test(e)&&!e.split("/").includes("..")}var No=Ct.object({path:Ct.string().min(3).max(256)});function xt(e){let t=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache.",inputSchema:No,async handler(n){if(!C(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let o=t.get(n.path);return o||(o=e.readMemory(n.path).then(r=>r.content),t.set(n.path,o),o.finally(()=>t.delete(n.path))),{content:[{type:"text",text:await o}]}}catch(o){return{content:[{type:"text",text:o instanceof u?o.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as Mo}from"node:os";import{z as Ie}from"zod";var Lo=Ie.object({path:Ie.string().min(3).max(256),content:Ie.string().max(1e6)});function $t(e){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through).",inputSchema:Lo,async handler(t){if(!C(t.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await e.writeMemory(t.path,t.content,Mo()),o=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(o+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:o}]}}catch(n){return{content:[{type:"text",text:n instanceof u?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as x}from"zod";var L=e=>({content:[{type:"text",text:e}]}),z=e=>({content:[{type:"text",text:e}],isError:!0});function ie(e){return e instanceof u?e.code:"errors.UNKNOWN"}var Ro=x.object({query:x.string().min(1).max(200),types:x.string().max(64).optional(),limit:x.number().int().min(1).max(50).optional()});function Tt(e){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each.",inputSchema:Ro,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});return n.length===0?L(`Nothing found for ${t.query}`):L(n.map(o=>`${o.kind} ${o.path??o.name}${o.scope==="team"?" (team)":""}
38
+ ${e}: ${i.join(", ")}${s}`}function Te(e,t,n={}){let o=n.brainvault===!1?gt:`${gt} ${To}`,i=t.length>0?26:0;return o+=ft("Skills","list_skills",e,o.length+i),o+=ft("Agents","list_agents",t,o.length),o}import{z as ii}from"zod";import{z as ht}from"zod";var Po=ht.object({name:ht.string().min(1).max(64)}),Pe=e=>e.replace(/[\r\n]+/g," ").trim();function Io(e){let t=e.model?`model: ${Pe(e.model)}
39
+ `:"";return`---
40
+ name: ${e.name}
41
+ description: ${Pe(e.description??"")}
42
+ ${t}tools: ${(e.tools??[]).map(Pe).join(", ")}
43
+ ---
44
+ ${e.body}`}function yt(e,t){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:Po,async handler(n){let o=`agent:${n.name}`,i=await t.get(o);if(i!==null)return{content:[{type:"text",text:i}]};try{let r=await e.getAgent(n.name,{use:!0}),s=Io(r);return await t.set(o,s),{content:[{type:"text",text:s}]}}catch(r){return{content:[{type:"text",text:r instanceof u?r.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Ie}from"zod";var _o=Ie.object({name:Ie.string().min(1).max(64),path:Ie.string().min(1).max(200)});function bt(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:_o,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 u?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as vt}from"zod";var Eo=vt.object({name:vt.string().min(1).max(64)});function kt(e,t){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:Eo,async handler(n){let o=`skill:${n.name}`,i=await t.get(o);if(i!==null)return{content:[{type:"text",text:i}]};try{let r=await e.getSkill(n.name);return await t.set(o,r.body),{content:[{type:"text",text:r.body}]}}catch(r){return{content:[{type:"text",text:r instanceof u?r.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Oo}from"zod";var wt=Oo.object({});function St(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:wt,async handler(){try{let{skills:t}=await e.listSkills();return{content:[{type:"text",text:t.map(n=>n.name).join(`
45
+ `)}]}}catch(t){return{content:[{type:"text",text:t instanceof u?t.code:"errors.UNKNOWN"}],isError:!0}}}}}function Ct(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:wt,async handler(){try{let{agents:t}=await e.listAgents();return{content:[{type:"text",text:t.map(o=>`${o.name}: ${o.description}`).join(`
46
+ `)}]}}catch(t){return{content:[{type:"text",text:t instanceof u?t.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as xt}from"zod";var No=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function C(e){return No.test(e)&&!e.split("/").includes("..")}var Mo=xt.object({path:xt.string().min(3).max(256)});function $t(e){let t=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache.",inputSchema:Mo,async handler(n){if(!C(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let o=t.get(n.path);return o||(o=e.readMemory(n.path).then(i=>i.content),t.set(n.path,o),o.finally(()=>t.delete(n.path))),{content:[{type:"text",text:await o}]}}catch(o){return{content:[{type:"text",text:o instanceof u?o.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as Lo}from"node:os";import{z as _e}from"zod";var Ro=_e.object({path:_e.string().min(3).max(256),content:_e.string().max(1e6)});function At(e){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through).",inputSchema:Ro,async handler(t){if(!C(t.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await e.writeMemory(t.path,t.content,Lo()),o=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(o+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:o}]}}catch(n){return{content:[{type:"text",text:n instanceof u?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as x}from"zod";var L=e=>({content:[{type:"text",text:e}]}),z=e=>({content:[{type:"text",text:e}],isError:!0});function re(e){return e instanceof u?e.code:"errors.UNKNOWN"}var Uo=x.object({query:x.string().min(1).max(200),types:x.string().max(64).optional(),limit:x.number().int().min(1).max(50).optional()});function Pt(e){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each.",inputSchema:Uo,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});return n.length===0?L(`Nothing found for ${t.query}`):L(n.map(o=>`${o.kind} ${o.path??o.name}${o.scope==="team"?" (team)":""}
42
47
  ${o.snippet}`).join(`
43
- `))}catch(n){return z(ie(n))}}}}var Uo=x.object({scope:x.string().max(96).optional()});function Pt(e){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it.",inputSchema:Uo,async handler(t){try{let{nodes:n}=await e.memoryTree(t.scope??"all");return n.length===0?L("(empty)"):L(n.map(o=>{let r=o.path.split("/").length-1,i=o.kind==="folder"?`${o.name}/`:o.name;return`${" ".repeat(r)}${i}${o.scope==="team"?" (team)":""}`}).join(`
44
- `))}catch(n){return z(ie(n))}}}}var Do=x.object({from:x.string().min(3).max(256),to:x.string().min(3).max(256),updateLinks:x.boolean().optional()});function At(e){return`${e} ${e===1?"file":"files"}`}function It(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:Do,async handler(t){if(!C(t.from)||!C(t.to))return z("errors.INVALID_PATH");let n=t.updateLinks??!0;try{let o=await e.moveMemory(t.from,t.to,n);return L(`${o.from} moved to ${o.to}`+(n?`, links updated in ${At(o.rewritten)}, ${At(o.skipped)} left unchanged`:""))}catch(o){return z(ie(o))}}}}var jo=x.object({path:x.string().min(3).max(256)});function _t(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:jo,async handler(t){if(!C(t.path))return z("errors.INVALID_PATH");try{let n=await e.readMemory(t.path),{resolved:o,unresolved:r}=n.links;return o.length===0&&r.length===0?L(`${t.path} does not link to anything.`):L([o.length>0?`Resolved: ${o.join(", ")}`:"",r.length>0?`Open (no file with this name yet): ${r.join(", ")}`:""].filter(i=>i!=="").join(`
45
- `))}catch(n){return z(ie(n))}}}}import{z as g}from"zod";var zo=e=>({content:[{type:"text",text:e}]}),Et=e=>({content:[{type:"text",text:e}],isError:!0});async function F(e){try{return zo(await e())}catch(t){if(t instanceof u){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return Et(`${t.code}${n}`)}return Et("errors.UNKNOWN")}}var K=g.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function se(e,t){let{connections:n}=await e.listConnections(),o=n.filter(r=>r.slug===t);return o.find(r=>r.scope==="personal")??o[0]??null}function _e(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})
48
+ `))}catch(n){return z(re(n))}}}}var Do=x.object({scope:x.string().max(96).optional()});function It(e){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it.",inputSchema:Do,async handler(t){try{let{nodes:n}=await e.memoryTree(t.scope??"all");return n.length===0?L("(empty)"):L(n.map(o=>{let i=o.path.split("/").length-1,r=o.kind==="folder"?`${o.name}/`:o.name;return`${" ".repeat(i)}${r}${o.scope==="team"?" (team)":""}`}).join(`
49
+ `))}catch(n){return z(re(n))}}}}var jo=x.object({from:x.string().min(3).max(256),to:x.string().min(3).max(256),updateLinks:x.boolean().optional()});function Tt(e){return`${e} ${e===1?"file":"files"}`}function _t(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:jo,async handler(t){if(!C(t.from)||!C(t.to))return z("errors.INVALID_PATH");let n=t.updateLinks??!0;try{let o=await e.moveMemory(t.from,t.to,n);return L(`${o.from} moved to ${o.to}`+(n?`, links updated in ${Tt(o.rewritten)}, ${Tt(o.skipped)} left unchanged`:""))}catch(o){return z(re(o))}}}}var zo=x.object({path:x.string().min(3).max(256)});function Et(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:zo,async handler(t){if(!C(t.path))return z("errors.INVALID_PATH");try{let n=await e.readMemory(t.path),{resolved:o,unresolved:i}=n.links;return o.length===0&&i.length===0?L(`${t.path} does not link to anything.`):L([o.length>0?`Resolved: ${o.join(", ")}`:"",i.length>0?`Open (no file with this name yet): ${i.join(", ")}`:""].filter(r=>r!=="").join(`
50
+ `))}catch(n){return z(re(n))}}}}import{z as f}from"zod";var Fo=e=>({content:[{type:"text",text:e}]}),Ot=e=>({content:[{type:"text",text:e}],isError:!0});async function F(e){try{return Fo(await e())}catch(t){if(t instanceof u){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return Ot(`${t.code}${n}`)}return Ot("errors.UNKNOWN")}}var K=f.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function se(e,t){let{connections:n}=await e.listConnections(),o=n.filter(i=>i.slug===t);return o.find(i=>i.scope==="personal")??o[0]??null}function Ee(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})
46
51
  ${e.url}${e.statusError?`
47
- last error: ${e.statusError}`:""}`}var Fo=g.object({});function Ot(e){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:Fo,handler:()=>F(async()=>{let{connections:t}=await e.listConnections();return t.length===0?"No MCP servers are connected yet. Add one with connection_create.":t.map(_e).join(`
48
- `)})}}var Go=g.object({name:g.string().min(1).max(80),slug:K,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 Nt(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:Go,handler:t=>F(async()=>{let{connection:n}=await e.createConnection(t);return`Connected.
49
- ${_e(n)}
52
+ last error: ${e.statusError}`:""}`}var Go=f.object({});function Nt(e){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:Go,handler:()=>F(async()=>{let{connections:t}=await e.listConnections();return t.length===0?"No MCP servers are connected yet. Add one with connection_create.":t.map(Ee).join(`
53
+ `)})}}var Ho=f.object({name:f.string().min(1).max(80),slug:K,url:f.string().url().max(2e3),transport:f.enum(["http","sse"]).default("http"),authType:f.enum(["none","bearer","header"]).default("none"),authHeaderName:f.string().max(80).optional(),secret:f.string().max(4e3).optional(),teamId:f.string().max(64).optional()});function Mt(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:Ho,handler:t=>F(async()=>{let{connection:n}=await e.createConnection(t);return`Connected.
54
+ ${Ee(n)}
50
55
 
51
- Its tools are now available as "${n.slug}__<tool>".`})}}var Ho=g.object({slug:K,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 Mt(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:Ho,handler:t=>F(async()=>{let n=await se(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{slug:o,...r}=t,{connection:i}=await e.updateConnection(n.id,r);return`Updated.
52
- ${_e(i)}`})}}var Wo=g.object({slug:K});function Lt(e){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:Wo,handler:t=>F(async()=>{let n=await se(e,t.slug);return n?(await e.deleteConnection(n.id),`Disconnected ${t.slug}.`):`Connection not found: ${t.slug}`})}}var Bo=g.object({slug:K});function Rt(e){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:Bo,handler:t=>F(async()=>{let n=await se(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:o}=await e.listCapabilities(n.id);return o.length===0?`${t.slug} has nothing on record yet. Its status is "${n.status}".`:o.map(r=>`${r.enabled?"[on] ":"[off]"} ${r.kind} ${r.name}${r.exposedAs?` -> ${r.exposedAs}`:""}${r.description?` \u2014 ${r.description}`:""}`).join(`
53
- `)})}}var Ko=g.object({slug:K,tool:g.string().min(1).max(200),enabled:g.boolean()});function Ut(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:Ko,handler:t=>F(async()=>{let n=await se(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:o}=await e.listCapabilities(n.id),r=o.find(i=>i.kind==="tool"&&i.name===t.tool);return r?(await e.toggleCapability(n.id,r.id,t.enabled),`${t.slug}__${r.name} is now ${t.enabled?"on":"off"}.`):`${t.slug} offers no tool called ${t.tool}.`})}}import{z as y}from"zod";var Vo=e=>({content:[{type:"text",text:e}]}),V=e=>({content:[{type:"text",text:e}],isError:!0});async function P(e){try{return Vo(await e())}catch(t){if(t instanceof u){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return V(`${t.code}${n}`)}return V("errors.UNKNOWN")}}var R=y.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),Jo=y.object({name:R,body:y.string().max(2e5)});function Dt(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:Jo,handler:t=>P(async()=>{let n=await e.putSkill(t.name,t.body);return`${n.name} ${n.updatedAt}`})}}var Yo=y.object({name:R});function jt(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:Yo,handler:t=>P(async()=>(await e.deleteSkill(t.name),`Deleted skill ${t.name}`))}}var qo=y.object({skill:R});function zt(e){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:qo,handler:t=>P(async()=>{let{files:n}=await e.getSkill(t.skill);return n.length===0?`${t.skill} has no companion files.`:n.map(o=>`${o.path} (${o.size} bytes, ${o.encoding})`).join(`
54
- `)})}}var Zo=y.object({skill:R,path:y.string().min(1).max(256),content:y.string().max(3e6),encoding:y.enum(["utf8","base64"]).default("utf8")});function Ft(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:Zo,handler:t=>M(t.path)?P(async()=>{let n=await e.putSkillFile(t.skill,t.path,t.content,t.encoding);return`${t.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(V("errors.INVALID_PATH"))}}var Xo=y.object({skill:R,path:y.string().min(1).max(256)});function Gt(e){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:Xo,handler:t=>M(t.path)?P(async()=>(await e.deleteSkillFile(t.skill,t.path),`Deleted ${t.skill}/${t.path}`)):Promise.resolve(V("errors.INVALID_PATH"))}}var Qo=y.object({name:R,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 Ht(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:Qo,handler:t=>P(async()=>{let n=await e.getAgent(t.name).catch(()=>null),o=await e.putAgent(t.name,{description:t.description,body:t.body,model:t.model??n?.model??void 0,tools:t.tools??n?.tools??[]});return`${o.name} ${o.updatedAt}`})}}var er=y.object({name:R});function Wt(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:er,handler:t=>P(async()=>(await e.deleteAgent(t.name),`Deleted agent ${t.name}`))}}var tr=y.object({});function Bt(e){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:tr,handler:()=>P(async()=>{let{files:t}=await e.listMemory();return t.length===0?"(none)":t.map(n=>n.path+(n.scope==="team"?` (team${n.teamName?`: ${n.teamName}`:""})`:"")).sort().join(`
55
- `)})}}var nr=y.object({path:y.string().min(3).max(256)});function Kt(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:nr,handler:t=>C(t.path)?P(async()=>(await e.deleteMemory(t.path),`Deleted ${t.path}`)):Promise.resolve(V("errors.INVALID_PATH"))}}function Vt(e,t){return[xt(e),$t(e),Bt(e),Kt(e),Tt(e),Pt(e),It(e),_t(e),wt(e),vt(e,t),Dt(e),jt(e),zt(e),yt(e),Ft(e),Gt(e),St(e),ht(e,t),Ht(e),Wt(e),Ot(e),Nt(e),Mt(e),Lt(e),Rt(e),Ut(e)]}function Jt(e){return e.map(t=>{let n=ve[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:or.toJSONSchema(t.inputSchema),annotations:n.annotations}})}async function Yt(){let e=mt(),t=new T(e,()=>A.read()),n=new j,o=Vt(t,n),r=await(async()=>{try{let[{skills:s},{agents:p},a]=await Promise.all([t.listSkills(),t.listAgents(),t.getMe().catch(()=>({brainvaultMode:!0}))]);return Te(s.map(l=>l.name),p.map(l=>l.name),{brainvault:a.brainvaultMode!==!1})}catch{return Te([],[])}})(),i=new rr(be(e,D),{capabilities:{tools:{}},instructions:r});i.setRequestHandler(ar,async()=>({tools:Jt(o)})),i.setRequestHandler(sr,async s=>{let p=o.find(l=>l.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}}),ee().then(s=>{for(let p of q())re(t,p,{ignore:s}).catch(()=>{})}).catch(()=>{}),await i.connect(new ir)}import{readdir as dr,readFile as mr,realpath as Xt,stat as ur}from"node:fs/promises";import{join as fr,relative as gr,resolve as hr,sep as Qt}from"node:path";var lr=[/^\.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 qt(e){return lr.some(t=>t.test(e))}var cr=[{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 pr(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 Zt(e){let t=[],n=e.split(`
56
- `);for(let o=0;o<n.length;o+=1){let r=n[o];for(let{rule:i,re:s}of cr){let p=s.exec(r);if(p){t.push({rule:i,line:o+1,excerpt:pr(r,p[0])});break}}}return t}var yr=new Set([".git","node_modules","__pycache__",".venv","venv",".pytest_cache",".mypy_cache","dist","build",".next",".cache"]),br=2*1024*1024;function vr(e){return e.subarray(0,8192).includes(0)}async function U(e,t={}){let n=t.maxBytes??br,o=await Xt(hr(e)),r=[];async function i(s){let p=await dr(s,{withFileTypes:!0});for(let a of p){let l=fr(s,a.name);if(a.isDirectory()){if(yr.has(a.name))continue;await i(l);continue}let c;try{c=await Xt(l)}catch{continue}if(c!==o&&!c.startsWith(o+Qt))continue;let h=gr(o,c).split(Qt).join("/");if(qt(a.name)){r.push({absolute:c,relative:h,bytes:0,binary:!1,hits:[],skip:"denied-name",description:null});continue}let m=await ur(c);if(!m.isFile())continue;if(m.size>n){r.push({absolute:c,relative:h,bytes:m.size,binary:!1,hits:[],skip:"too-large",description:null});continue}let b=await mr(c),v=vr(b),f=!v&&h.toLowerCase().endsWith(".md")?b.toString("utf8"):null;r.push({absolute:c,relative:h,bytes:m.size,binary:v,hits:v?[]:Zt(b.toString("utf8")),skip:f!==null&&lt(f)?"stub":null,description:f===null?null:at(f)||null})}}return await i(o),r.sort((s,p)=>s.relative.localeCompare(p.relative)),r}import{basename as kr}from"node:path";var wr=/^[a-z0-9]+(-[a-z0-9]+)*$/,Sr=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,en=/^[a-z0-9][a-z0-9._-]*$/i;function Cr(e){let t=e.split("/"),n=t.indexOf("skills");return n>=4&&t[n-4]==="cache"&&n+1<t.length-1?{prefix:t.slice(0,n+2).join("/"),name:`${t[n-2]}:${t[n+1]}`,plugin:t[n-2],path:t.slice(n+2).join("/")}:t.length<2?null:{prefix:t[0],name:t[0],plugin:null,path:t.slice(1).join("/")}}function ae(e){return e.skip===null&&e.hits.length===0}function le(e){return e.skip??(e.hits.length>0?"flagged":"unusable")}function xr(e,t={}){let n=[],o=[],r=[],i=new Map,s=t.root?kr(t.root.replace(/[/\\]+$/,"")):"",p=en.test(s)?{key:s,kind:"directory",label:s}:null;for(let a of e){let l=Cr(a.relative);if(!l){o.push({relative:a.relative,reason:"not-in-a-skill-folder"});continue}let c=i.get(l.prefix);c?c.entries.push(a):i.set(l.prefix,{at:l,entries:[a]})}for(let[a,{at:l,entries:c}]of i){let h=l.name;if(!Sr.test(h)){o.push({relative:a,reason:"invalid-name"});continue}let m=c.find(f=>f.relative===`${a}/SKILL.md`);if(!m){o.push({relative:a,reason:"no-skill-md"});continue}if(!ae(m)){o.push({relative:`${a}/SKILL.md`,reason:le(m)});continue}let b=[];for(let f of c){if(f===m)continue;if(!ae(f)){o.push({relative:f.relative,reason:le(f)});continue}let k=f.relative.slice(a.length+1);if(!M(k)){o.push({relative:f.relative,reason:"invalid-path"});continue}b.push({path:k,absolute:f.absolute,bytes:f.bytes,binary:f.binary})}b.sort((f,k)=>f.path.localeCompare(k.path));let v=m.description??"";v||r.push(h),n.push({name:h,source:m.absolute,sourcePath:m.relative,description:v,collection:l.plugin?en.test(l.plugin)?{key:l.plugin,kind:"plugin",label:l.plugin}:null:p,bytes:m.bytes,files:b})}return n.sort((a,l)=>a.name.localeCompare(l.name)),r.sort(),{plans:n,skipped:o,noDescription:r}}function $r(e){let t=[],n=[];for(let o of e){if(o.relative.includes("/")){n.push({relative:o.relative,reason:"not-at-top-level"});continue}if(!o.relative.endsWith(".md")){n.push({relative:o.relative,reason:"not-markdown"});continue}let r=o.relative.slice(0,-3);if(!wr.test(r)){n.push({relative:o.relative,reason:"invalid-name"});continue}if(!ae(o)){n.push({relative:o.relative,reason:le(o)});continue}t.push({name:r,source:o.absolute,bytes:o.bytes})}return t.sort((o,r)=>o.name.localeCompare(r.name)),{plans:t,skipped:n}}function Ar(e){let t=[],n=[];for(let o of e){if(!C(o.relative)){n.push({relative:o.relative,reason:"invalid-path"});continue}if(!ae(o)){n.push({relative:o.relative,reason:le(o)});continue}t.push({path:o.relative,source:o.absolute,bytes:o.bytes})}return t.sort((o,r)=>o.path.localeCompare(r.path)),{plans:t,skipped:n}}function Ee(e,t={}){let n=xr(e.skills??[],{root:t.skillsRoot}),o=$r(e.agents??[]),r=Ar(e.memory??[]),i=[...e.skills??[],...e.agents??[],...e.memory??[]];return{skills:n.plans,agents:o.plans,memory:r.plans,flagged:i.filter(s=>s.skip===null&&s.hits.length>0),skipped:[...n.skipped,...o.skipped,...r.skipped],noDescription:n.noDescription}}import{readFile as ce}from"node:fs/promises";import{hostname as Tr}from"node:os";function pe(e){return e instanceof u?e.code:e instanceof Error?e.message:String(e)}function Oe(e){return e.skills.length+e.skills.reduce((t,n)=>t+n.files.length,0)+e.agents.length+e.memory.length}async function tn(e,t,n){let o={skills:0,skillFiles:0,agents:0,memory:0,failures:[]},r=Oe(t),i=0,s=a=>n(i+=1,r,a);for(let a of t.skills){try{await e.putSkill(a.name,await ce(a.source,"utf8"),{...a.description?{description:a.description}:{},sourcePath:a.sourcePath,...a.collection?{collection:a.collection}:{}}),o.skills+=1}catch(l){o.failures.push({what:`skill ${a.name}`,code:pe(l)}),i+=a.files.length,s(a.name);continue}s(a.name);for(let l of a.files){try{let c=await ce(l.absolute);await e.putSkillFile(a.name,l.path,l.binary?c.toString("base64"):c.toString("utf8"),l.binary?"base64":"utf8"),o.skillFiles+=1}catch(c){o.failures.push({what:`${a.name}/${l.path}`,code:pe(c)})}s(`${a.name}/${l.path}`)}}for(let a of t.agents){try{let l=await ce(a.source,"utf8"),c=st(l);if(!c){o.failures.push({what:`agent ${a.name}`,code:"no-frontmatter"}),s(a.name);continue}await e.putAgent(a.name,{...c,body:ct(l)}),o.agents+=1}catch(l){o.failures.push({what:`agent ${a.name}`,code:pe(l)})}s(a.name)}let p=Tr();for(let a of t.memory){try{await e.writeMemory(a.path,await ce(a.source,"utf8"),p),o.memory+=1}catch(l){o.failures.push({what:a.path,code:pe(l)})}s(a.path)}return o}function nn(e){return e.skills.length===0&&e.agents.length===0&&e.memory.length===0}function on(e){return e.skills.length+e.agents.length+e.memory.length}function Ne(e){return e.scope==="personal"&&e.isOwn&&e.archivedAt===null}async function rn(e,t,n){let o={skills:[],agents:[],memory:[]};if(n.skills){let r=new Set(t.skills.map(s=>s.name)),{skills:i}=await e.listSkills();o.skills=i.filter(s=>Ne(s)&&!r.has(s.name)).map(s=>s.name)}if(n.agents){let r=new Set(t.agents.map(s=>s.name)),{agents:i}=await e.listAgents();o.agents=i.filter(s=>Ne(s)&&!r.has(s.name)).map(s=>s.name)}if(n.memory){let r=new Set(t.memory.map(s=>s.path)),{files:i}=await e.listMemory();o.memory=i.filter(s=>Ne(s)&&!r.has(s.path)).map(s=>s.path)}return o.skills.sort(),o.agents.sort(),o.memory.sort(),o}function Pr(e){return e instanceof u?e.code:e instanceof Error?e.message:String(e)}async function sn(e,t){let n={deleted:0,failures:[]},o=async(r,i,s)=>{for(let p of r)try{await s(p),n.deleted+=1}catch(a){n.failures.push({what:i(p),code:Pr(a)})}};return await o(t.skills,r=>`skill ${r}`,r=>e.deleteSkill(r)),await o(t.agents,r=>`agent ${r}`,r=>e.deleteAgent(r)),await o(t.memory,r=>r,r=>e.deleteMemory(r)),n}import{mkdir as an,writeFile as Ir}from"node:fs/promises";import{dirname as _r,resolve as ln,sep as Er}from"node:path";async function cn(e,t){let n=ln(t);await an(n,{recursive:!0});let o={written:0,refused:[],collisions:[],failures:[]},{files:r}=await e.listMemory(),i=[...r].sort((p,a)=>p.scope===a.scope?p.path.localeCompare(a.path):p.scope==="personal"?-1:1),s=new Set;for(let p of i){if(!C(p.path)){o.refused.push(p.path);continue}let a=ln(n,...p.path.split("/"));if(!a.startsWith(n+Er)){o.refused.push(p.path);continue}if(s.has(a)){o.collisions.push(p.path);continue}try{let l=await e.readMemory(p.path);await an(_r(a),{recursive:!0}),await Ir(a,l.content,"utf8"),s.add(a),o.written+=1}catch(l){o.failures.push({what:p.path,code:l instanceof Error?l.message:String(l)})}}return o}import{mkdir as pn,writeFile as Or}from"node:fs/promises";import{dirname as Nr,resolve as dn,sep as Mr}from"node:path";import{unzipSync as Lr}from"fflate";async function mn(e,t){let n=dn(t);await pn(n,{recursive:!0});let o={written:0,refused:[],failed:[]},r=Lr(e);for(let[i,s]of Object.entries(r)){if(i.endsWith("/"))continue;let p=i.split("/");if(i.startsWith("/")||/^[a-zA-Z]:/.test(i)||i.includes("\\")||p.some(c=>c===""||c==="."||c==="..")){o.refused.push(i);continue}let l=dn(n,...p);if(!l.startsWith(n+Mr)){o.refused.push(i);continue}try{await pn(Nr(l),{recursive:!0}),await Or(l,s),o.written+=1}catch(c){o.failed.push({path:i,reason:c instanceof Error?c.message:String(c)})}}return o}var I=process.env.ONLYMCP_API_URL??"https://only-mcp.com",_=new Ur().name("onlymcp").version(D);function Br(e,t){try{let n=new URL(e);return(n.protocol==="https:"||n.protocol==="http:")&&n.origin===t}catch{return!1}}_.command("login").description("Connect this device to OnlyMCP").action(async()=>{Ue("OnlyMCP"),d.info(`This device will register itself as: ${await he()}`);let t=await(await fetch(`${I}/api/auth/device/code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:"onlymcp-cli"})})).json();d.info(`Code: ${t.user_code}`),d.info(t.verification_uri),console.log(await jr.toString(t.verification_uri_complete,{type:"terminal",small:!0})),Br(t.verification_uri_complete,new URL(I).origin)&&await Dr(t.verification_uri_complete).catch(()=>{});let n=me();n.start("Waiting for confirmation");let o=await qe(I,t.device_code,t.interval??5);A.save(o),n.stop("Connected");let r=new T(I,()=>A.read()),i=await yn(r),s=bn(i);s&&d.info(s),G(`${i.skills} skills, ${i.agents} agents, ${i.files} files ready`)});async function yn(e){let t=await ee(),n={skills:0,agents:0,files:0,kept:[],ignored:new Set,removed:0};for(let o of q()){let r=await re(e,o,{ignore:t});n.skills+=r.skills,n.agents+=r.agents,n.files+=r.files;for(let i of r.kept)n.kept.push(`${o}/${i}`);for(let i of r.ignored)n.ignored.add(i);n.removed+=r.removed}return n}function bn(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 ${Y()}${t}`}async function Re(e,t,n){try{await e.reportRun(t,n)}catch{}}async function Kr(e){try{return await new T(I,()=>e).signOut(),null}catch(t){return t instanceof u&&t.status>0?`HTTP ${t.status}`:t instanceof Error?t.message:String(t)}}_.command("logout").description("End this device's session, then remove its login and cache").action(async()=>{let e=A.read(),t=e?await Kr(e):null;if(A.clear(),await new j().clear(),t){d.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.`),d.success("Logged out on this device");return}d.success("Logged out")});_.command("status").description("Show whether this device is logged in").action(()=>{d.info(A.read()?"logged in":"not logged in")});_.command("sync").description("Rewrite the stub files").option("--memory <dir>","Also write memory as files into this folder").action(async e=>{let t=new T(I,()=>A.read()),n=await yn(t);d.success(`${n.skills} skills, ${n.agents} agents, ${n.files} files`);let o=bn(n);o&&d.info(o),n.kept.length>0&&d.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(`
57
- `));let r=n.skills+n.agents+n.files;if(!e.memory){await Re(t,"sync",r);return}let i=await cn(t,e.memory);d.success(`${i.written} memory files to ${e.memory}`),i.collisions.length>0&&d.warn(["Team files with a path an existing file of yours already has",...i.collisions.map(s=>` ${s}`)].join(`
58
- `)),i.refused.length>0&&d.warn(["Paths refused",...i.refused.map(s=>` ${s}`)].join(`
59
- `)),i.failures.length>0&&(d.error([`${i.failures.length} failed`,...i.failures.map(s=>` ${s.what} ${s.code}`)].join(`
60
- `)),process.exitCode=1),i.failures.length===0&&await Re(t,"sync",r+i.written)});_.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??hn(),n=rt(t,e);function o(r){if(e.print){d.info(`${r.name} -> ${r.configPath}`),console.log(r.snippet);return}try{it(r)==="already-present"?d.info(`${r.name} is already set up: ${r.configPath}`):d.success(`${r.name} set up: ${r.configPath}`),r.id==="claude-code"&&d.info(nt)}catch(i){d.error(i instanceof Error?i.message:String(i)),process.exitCode=1}}switch(n.kind){case"conflicting-options":d.error("Pass either --client <id> or --all, not both."),process.exitCode=2;return;case"missing-client":d.info(`Known clients: ${n.targets.map(r=>r.id).join(", ")}`),d.info("Pass --client <id>, or --all."),process.exitCode=2;return;case"unknown-client":d.error(`Unknown client. Known: ${n.targets.map(r=>r.id).join(", ")}`),process.exitCode=1;return;case"none-present-for-all":d.error("No known client is set up on this machine yet."),d.info(`Pass --client <id> to write its config anyway. Known: ${n.targets.map(r=>r.id).join(", ")}.`),process.exitCode=2;return;case"single":o(n.target);return;case"all":for(let r of n.present)o(r);n.skipped.length>0&&d.info(`Skipped, not set up on this machine: ${n.skipped.map(r=>r.id).join(", ")}`);return}});function Le(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function de(e){return e.reduce((t,n)=>t+n.bytes,0)}function Vr(e,t){let n=e.skills.reduce((i,s)=>i+s.files.length,0),o=e.skills.filter(i=>i.files.length>0).length,r=e.skills.reduce((i,s)=>i+de(s.files),0);if(t.skills&&d.message(`Skills ${String(e.skills.length).padStart(4)} from ${t.skills}
61
- ${String(n).padStart(4)} more files across ${o} skills ${Le(de(e.skills)+r)}`),t.agents&&d.message(`Agents ${String(e.agents.length).padStart(4)} from ${t.agents} ${Le(de(e.agents))}`),t.memory&&d.message(`Memory ${String(e.memory.length).padStart(4)} from ${t.memory} ${Le(de(e.memory))}`),e.skipped.length>0){let i=new Map;for(let s of e.skipped)i.set(s.reason,(i.get(s.reason)??0)+1);d.message(["Skipped",...[...i].map(([s,p])=>` ${String(p).padStart(4)} ${s}`)].join(`
62
- `))}e.noDescription.length>0&&d.warn(["Missing a description in the SKILL.md header",...e.noDescription.map(i=>` ${i}`)].join(`
63
- `)),e.flagged.length>0&&d.warn(["Held back over possible credentials (none of it left this machine)",...e.flagged.flatMap(i=>[` ${i.relative}`,...i.hits.map(s=>` line ${s.line} rule ${s.rule} ${s.excerpt}`)])].join(`
64
- `))}_.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??hn(),n=!!(e.skills||e.agents||e.memory),o={skills:n?e.skills:gn(t,".claude","skills"),agents:n?e.agents:gn(t,".claude","agents"),memory:e.memory};Ue("OnlyMCP Import");let r=me();r.start("Reading the folders");let i;try{let[a,l,c]=await Promise.all([o.skills&&$(o.skills)?U(o.skills):Promise.resolve([]),o.agents&&$(o.agents)?U(o.agents):Promise.resolve([]),o.memory&&$(o.memory)?U(o.memory):Promise.resolve([])]);i=Ee({skills:a,agents:l,memory:c},{skillsRoot:o.skills})}catch(a){r.stop("Aborted"),d.error(a instanceof Error?a.message:String(a)),process.exitCode=1;return}r.stop("Read"),Vr(i,{skills:o.skills&&$(o.skills)?o.skills:void 0,agents:o.agents&&$(o.agents)?o.agents:void 0,memory:o.memory&&$(o.memory)?o.memory:void 0});let s=Oe(i);if(s===0&&!e.prune){G("Nothing to do.");return}if(e.dryRun&&!e.prune){G("Nothing uploaded (--dry-run).");return}let p=new T(I,()=>A.read());try{let a=await p.getMe();d.info(`Target ${I} as ${a.email} plan ${a.plan.name}`)}catch(a){d.error(`Not logged in, or the server is unreachable (${a instanceof Error?a.message:String(a)}).`),d.info("First: npx onlymcp login"),process.exitCode=1;return}if(s>0&&!e.yes&&!e.dryRun){if(!process.stdin.isTTY){d.error("No terminal for the prompt. Run --dry-run first, then --yes."),process.exitCode=1;return}let a=await fn({message:`Upload ${s} entries?`,initialValue:!1});if(Me(a)||!a){un("Cancelled. Nothing uploaded.");return}if(i.flagged.length>0){let l=await Rr({message:"Send the held-back files anyway?",options:i.flagged.map(c=>({value:c.relative,label:c.relative})),required:!1,initialValues:[]});if(Me(l)){un("Cancelled. Nothing uploaded.");return}if(l.length>0){let c=new Set(l),h=f=>f.map(k=>c.has(k.relative)?{...k,hits:[]}:k),[m,b,v]=await Promise.all([o.skills&&$(o.skills)?U(o.skills):Promise.resolve([]),o.agents&&$(o.agents)?U(o.agents):Promise.resolve([]),o.memory&&$(o.memory)?U(o.memory):Promise.resolve([])]);i=Ee({skills:h(m),agents:h(b),memory:h(v)},{skillsRoot:o.skills})}}}if(s>0&&!e.dryRun){let a=me();a.start("Uploading");let l=await tn(p,i,(c,h,m)=>{a.message(`${c}/${h} ${m}`)});a.stop("Done"),d.success(`${l.skills} skills, ${l.skillFiles} skill files, ${l.agents} agents, ${l.memory} memory files`),l.failures.length>0?(d.error([`${l.failures.length} failed`,...l.failures.map(c=>` ${c.what} ${c.code}`)].join(`
65
- `)),process.exitCode=1):await Re(p,"import",l.skills+l.skillFiles+l.agents+l.memory)}if(e.prune){let a={skills:!!(o.skills&&$(o.skills)),agents:!!(o.agents&&$(o.agents)),memory:!!(o.memory&&$(o.memory))},l=await rn(p,i,a);if(nn(l))d.info("Nothing to delete: the account holds nothing the source does not know.");else if(d.warn(["Would delete (only your own, nothing from a team, nothing archived)",...l.skills.map(c=>` Skill ${c}`),...l.agents.map(c=>` Agent ${c}`),...l.memory.map(c=>` Memory ${c}`)].join(`
66
- `)),e.dryRun)d.info("Nothing deleted (--dry-run).");else if(!process.stdin.isTTY)d.error("No terminal for the prompt. Nothing deleted."),process.exitCode=1;else{let c=await fn({message:`Delete ${on(l)} entries in the account?`,initialValue:!1});if(Me(c)||!c)d.info("Nothing deleted.");else{let h=await sn(p,l);d.success(`${h.deleted} deleted`),h.failures.length>0&&(d.error([`${h.failures.length} failed`,...h.failures.map(m=>` ${m.what} ${m.code}`)].join(`
67
- `)),process.exitCode=1)}}}G(e.dryRun?"Nothing changed (--dry-run).":"Then: npx onlymcp sync on every device.")});_.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){d.error("Either --out <folder> or --zip <file>, not both and not neither."),process.exitCode=1;return}Ue("OnlyMCP Export");let t=new T(I,()=>A.read()),n=me();n.start("Fetching the archive");let o;try{o=await t.exportArchive({scope:e.scope,types:e.types?.split(",").map(s=>s.trim()).filter(s=>s!=="")})}catch(s){n.stop("Aborted"),d.error(s instanceof Error?s.message:String(s)),d.info("Not logged in? First: npx onlymcp login"),process.exitCode=1;return}if(e.zip){Fr(Wr(e.zip),{recursive:!0}),await Gr(Hr.fromWeb(o.body),zr(e.zip)),n.stop("Done"),G(`Archive: ${e.zip}`);return}let r=new Uint8Array(await o.arrayBuffer()),i=await mn(r,e.out);n.stop("Done"),d.success(`${i.written} files in ${e.out}`),i.refused.length>0&&d.warn(["Not written, path in the archive is not allowed",...i.refused.map(s=>` ${s}`)].join(`
68
- `)),i.failed.length>0&&(d.warn(["Not written, the filename doesn't work on this system",...i.failed.map(s=>` ${s.path} ${s.reason}`),"With --zip <file> the archive stays unchanged."].join(`
69
- `)),process.exitCode=1),G(`Restore: npx onlymcp import --skills ${e.out}/skills --agents ${e.out}/agents --memory ${e.out}/memory`)});_.command("mcp").description("Run the stdio MCP server, the process an MCP client starts").action(Yt);await _.parseAsync();
56
+ Its tools are now available as "${n.slug}__<tool>".`})}}var Wo=f.object({slug:K,name:f.string().min(1).max(80).optional(),url:f.string().url().max(2e3).optional(),transport:f.enum(["http","sse"]).optional(),authType:f.enum(["none","bearer","header"]).optional(),authHeaderName:f.string().max(80).optional(),secret:f.string().max(4e3).optional(),enabled:f.boolean().optional()});function Lt(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:Wo,handler:t=>F(async()=>{let n=await se(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{slug:o,...i}=t,{connection:r}=await e.updateConnection(n.id,i);return`Updated.
57
+ ${Ee(r)}`})}}var Bo=f.object({slug:K});function Rt(e){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:Bo,handler:t=>F(async()=>{let n=await se(e,t.slug);return n?(await e.deleteConnection(n.id),`Disconnected ${t.slug}.`):`Connection not found: ${t.slug}`})}}var Ko=f.object({slug:K});function Ut(e){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:Ko,handler:t=>F(async()=>{let n=await se(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:o}=await e.listCapabilities(n.id);return o.length===0?`${t.slug} has nothing on record yet. Its status is "${n.status}".`:o.map(i=>`${i.enabled?"[on] ":"[off]"} ${i.kind} ${i.name}${i.exposedAs?` -> ${i.exposedAs}`:""}${i.description?` \u2014 ${i.description}`:""}`).join(`
58
+ `)})}}var Vo=f.object({slug:K,tool:f.string().min(1).max(200),enabled:f.boolean()});function Dt(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:Vo,handler:t=>F(async()=>{let n=await se(e,t.slug);if(!n)return`Connection not found: ${t.slug}`;let{capabilities:o}=await e.listCapabilities(n.id),i=o.find(r=>r.kind==="tool"&&r.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 y}from"zod";var Jo=e=>({content:[{type:"text",text:e}]}),V=e=>({content:[{type:"text",text:e}],isError:!0});async function P(e){try{return Jo(await e())}catch(t){if(t instanceof u){let n=Object.keys(t.params).length?` ${JSON.stringify(t.params)}`:"";return V(`${t.code}${n}`)}return V("errors.UNKNOWN")}}var R=y.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),Yo=y.object({name:R,body:y.string().max(2e5)});function jt(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:Yo,handler:t=>P(async()=>{let n=await e.putSkill(t.name,t.body);return`${n.name} ${n.updatedAt}`})}}var qo=y.object({name:R});function zt(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:qo,handler:t=>P(async()=>(await e.deleteSkill(t.name),`Deleted skill ${t.name}`))}}var Zo=y.object({skill:R});function Ft(e){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:Zo,handler:t=>P(async()=>{let{files:n}=await e.getSkill(t.skill);return n.length===0?`${t.skill} has no companion files.`:n.map(o=>`${o.path} (${o.size} bytes, ${o.encoding})`).join(`
59
+ `)})}}var Xo=y.object({skill:R,path:y.string().min(1).max(256),content:y.string().max(3e6),encoding:y.enum(["utf8","base64"]).default("utf8")});function Gt(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:Xo,handler:t=>M(t.path)?P(async()=>{let n=await e.putSkillFile(t.skill,t.path,t.content,t.encoding);return`${t.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(V("errors.INVALID_PATH"))}}var Qo=y.object({skill:R,path:y.string().min(1).max(256)});function Ht(e){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:Qo,handler:t=>M(t.path)?P(async()=>(await e.deleteSkillFile(t.skill,t.path),`Deleted ${t.skill}/${t.path}`)):Promise.resolve(V("errors.INVALID_PATH"))}}var ei=y.object({name:R,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 Wt(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:ei,handler:t=>P(async()=>{let n=await e.getAgent(t.name).catch(()=>null),o=await e.putAgent(t.name,{description:t.description,body:t.body,model:t.model??n?.model??void 0,tools:t.tools??n?.tools??[]});return`${o.name} ${o.updatedAt}`})}}var ti=y.object({name:R});function Bt(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:ti,handler:t=>P(async()=>(await e.deleteAgent(t.name),`Deleted agent ${t.name}`))}}var ni=y.object({});function Kt(e){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:ni,handler:()=>P(async()=>{let{files:t}=await e.listMemory();return t.length===0?"(none)":t.map(n=>n.path+(n.scope==="team"?` (team${n.teamName?`: ${n.teamName}`:""})`:"")).sort().join(`
60
+ `)})}}var oi=y.object({path:y.string().min(3).max(256)});function Vt(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:oi,handler:t=>C(t.path)?P(async()=>(await e.deleteMemory(t.path),`Deleted ${t.path}`)):Promise.resolve(V("errors.INVALID_PATH"))}}function Jt(e,t){return[$t(e),At(e),Kt(e),Vt(e),Pt(e),It(e),_t(e),Et(e),St(e),kt(e,t),jt(e),zt(e),Ft(e),bt(e),Gt(e),Ht(e),Ct(e),yt(e,t),Wt(e),Bt(e),Nt(e),Mt(e),Lt(e),Rt(e),Ut(e),Dt(e)]}function Yt(e){return e.map(t=>{let n=ve[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:ii.toJSONSchema(t.inputSchema),annotations:n.annotations}})}async function qt(){let e=ut(),t=new T(e,()=>A.read()),n=new j,o=Jt(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 Te(s.map(l=>l.name),p.map(l=>l.name),{brainvault:a.brainvaultMode!==!1})}catch{return Te([],[])}})(),r=new ri(be(e,D),{capabilities:{tools:{}},instructions:i});r.setRequestHandler(li,async()=>({tools:Yt(o)})),r.setRequestHandler(ai,async s=>{let p=o.find(l=>l.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}}),ee().then(s=>{for(let p of q())ie(t,p,{ignore:s}).catch(()=>{})}).catch(()=>{}),await r.connect(new si)}import{readdir as mi,readFile as ui,realpath as Qt,stat as gi}from"node:fs/promises";import{join as fi,relative as hi,resolve as yi,sep as en}from"node:path";var ci=[/^\.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 Zt(e){return ci.some(t=>t.test(e))}var pi=[{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 di(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(`
61
+ `);for(let o=0;o<n.length;o+=1){let i=n[o];for(let{rule:r,re:s}of pi){let p=s.exec(i);if(p){t.push({rule:r,line:o+1,excerpt:di(i,p[0])});break}}}return t}var bi=new Set([".git","node_modules","__pycache__",".venv","venv",".pytest_cache",".mypy_cache","dist","build",".next",".cache"]),vi=2*1024*1024;function ki(e){return e.subarray(0,8192).includes(0)}async function U(e,t={}){let n=t.maxBytes??vi,o=await Qt(yi(e)),i=[];async function r(s){let p=await mi(s,{withFileTypes:!0});for(let a of p){let l=fi(s,a.name);if(a.isDirectory()){if(bi.has(a.name))continue;await r(l);continue}let c;try{c=await Qt(l)}catch{continue}if(c!==o&&!c.startsWith(o+en))continue;let h=hi(o,c).split(en).join("/");if(Zt(a.name)){i.push({absolute:c,relative:h,bytes:0,binary:!1,hits:[],skip:"denied-name",description:null});continue}let m=await gi(c);if(!m.isFile())continue;if(m.size>n){i.push({absolute:c,relative:h,bytes:m.size,binary:!1,hits:[],skip:"too-large",description:null});continue}let b=await ui(c),v=ki(b),g=!v&&h.toLowerCase().endsWith(".md")?b.toString("utf8"):null;i.push({absolute:c,relative:h,bytes:m.size,binary:v,hits:v?[]:Xt(b.toString("utf8")),skip:g!==null&&ct(g)?"stub":null,description:g===null?null:lt(g)||null})}}return await r(o),i.sort((s,p)=>s.relative.localeCompare(p.relative)),i}import{basename as wi}from"node:path";var Si=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ci=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,tn=/^[a-z0-9][a-z0-9._-]*$/i;function xi(e){let t=e.split("/"),n=t.indexOf("skills");return n>=4&&t[n-4]==="cache"&&n+1<t.length-1?{prefix:t.slice(0,n+2).join("/"),name:`${t[n-2]}:${t[n+1]}`,plugin:t[n-2],path:t.slice(n+2).join("/")}:t.length<2?null:{prefix:t[0],name:t[0],plugin:null,path:t.slice(1).join("/")}}function ae(e){return e.skip===null&&e.hits.length===0}function le(e){return e.skip??(e.hits.length>0?"flagged":"unusable")}function $i(e,t={}){let n=[],o=[],i=[],r=new Map,s=t.root?wi(t.root.replace(/[/\\]+$/,"")):"",p=tn.test(s)?{key:s,kind:"directory",label:s}:null;for(let a of e){let l=xi(a.relative);if(!l){o.push({relative:a.relative,reason:"not-in-a-skill-folder"});continue}let c=r.get(l.prefix);c?c.entries.push(a):r.set(l.prefix,{at:l,entries:[a]})}for(let[a,{at:l,entries:c}]of r){let h=l.name;if(!Ci.test(h)){o.push({relative:a,reason:"invalid-name"});continue}let m=c.find(g=>g.relative===`${a}/SKILL.md`);if(!m){o.push({relative:a,reason:"no-skill-md"});continue}if(!ae(m)){o.push({relative:`${a}/SKILL.md`,reason:le(m)});continue}let b=[];for(let g of c){if(g===m)continue;if(!ae(g)){o.push({relative:g.relative,reason:le(g)});continue}let k=g.relative.slice(a.length+1);if(!M(k)){o.push({relative:g.relative,reason:"invalid-path"});continue}b.push({path:k,absolute:g.absolute,bytes:g.bytes,binary:g.binary})}b.sort((g,k)=>g.path.localeCompare(k.path));let v=m.description??"";v||i.push(h),n.push({name:h,source:m.absolute,sourcePath:m.relative,description:v,collection:l.plugin?tn.test(l.plugin)?{key:l.plugin,kind:"plugin",label:l.plugin}:null:p,bytes:m.bytes,files:b})}return n.sort((a,l)=>a.name.localeCompare(l.name)),i.sort(),{plans:n,skipped:o,noDescription:i}}function Ai(e){let t=[],n=[];for(let o of e){if(o.relative.includes("/")){n.push({relative:o.relative,reason:"not-at-top-level"});continue}if(!o.relative.endsWith(".md")){n.push({relative:o.relative,reason:"not-markdown"});continue}let i=o.relative.slice(0,-3);if(!Si.test(i)){n.push({relative:o.relative,reason:"invalid-name"});continue}if(!ae(o)){n.push({relative:o.relative,reason:le(o)});continue}t.push({name:i,source:o.absolute,bytes:o.bytes})}return t.sort((o,i)=>o.name.localeCompare(i.name)),{plans:t,skipped:n}}function Ti(e){let t=[],n=[];for(let o of e){if(!C(o.relative)){n.push({relative:o.relative,reason:"invalid-path"});continue}if(!ae(o)){n.push({relative:o.relative,reason:le(o)});continue}t.push({path:o.relative,source:o.absolute,bytes:o.bytes})}return t.sort((o,i)=>o.path.localeCompare(i.path)),{plans:t,skipped:n}}function Oe(e,t={}){let n=$i(e.skills??[],{root:t.skillsRoot}),o=Ai(e.agents??[]),i=Ti(e.memory??[]),r=[...e.skills??[],...e.agents??[],...e.memory??[]];return{skills:n.plans,agents:o.plans,memory:i.plans,flagged:r.filter(s=>s.skip===null&&s.hits.length>0),skipped:[...n.skipped,...o.skipped,...i.skipped],noDescription:n.noDescription}}import{readFile as ce}from"node:fs/promises";import{hostname as Pi}from"node:os";function pe(e){return e instanceof u?e.code:e instanceof Error?e.message:String(e)}function Ne(e){return e.skills.length+e.skills.reduce((t,n)=>t+n.files.length,0)+e.agents.length+e.memory.length}async function nn(e,t,n){let o={skills:0,skillFiles:0,agents:0,memory:0,failures:[]},i=Ne(t),r=0,s=a=>n(r+=1,i,a);for(let a of t.skills){try{await e.putSkill(a.name,await ce(a.source,"utf8"),{...a.description?{description:a.description}:{},sourcePath:a.sourcePath,...a.collection?{collection:a.collection}:{}}),o.skills+=1}catch(l){o.failures.push({what:`skill ${a.name}`,code:pe(l)}),r+=a.files.length,s(a.name);continue}s(a.name);for(let l of a.files){try{let c=await ce(l.absolute);await e.putSkillFile(a.name,l.path,l.binary?c.toString("base64"):c.toString("utf8"),l.binary?"base64":"utf8"),o.skillFiles+=1}catch(c){o.failures.push({what:`${a.name}/${l.path}`,code:pe(c)})}s(`${a.name}/${l.path}`)}}for(let a of t.agents){try{let l=await ce(a.source,"utf8"),c=at(l);if(!c){o.failures.push({what:`agent ${a.name}`,code:"no-frontmatter"}),s(a.name);continue}await e.putAgent(a.name,{...c,body:pt(l)}),o.agents+=1}catch(l){o.failures.push({what:`agent ${a.name}`,code:pe(l)})}s(a.name)}let p=Pi();for(let a of t.memory){try{await e.writeMemory(a.path,await ce(a.source,"utf8"),p),o.memory+=1}catch(l){o.failures.push({what:a.path,code:pe(l)})}s(a.path)}return o}function on(e){return e.skills.length===0&&e.agents.length===0&&e.memory.length===0}function rn(e){return e.skills.length+e.agents.length+e.memory.length}function Me(e){return e.scope==="personal"&&e.isOwn&&e.archivedAt===null}async function sn(e,t,n){let o={skills:[],agents:[],memory:[]};if(n.skills){let i=new Set(t.skills.map(s=>s.name)),{skills:r}=await e.listSkills();o.skills=r.filter(s=>Me(s)&&!i.has(s.name)).map(s=>s.name)}if(n.agents){let i=new Set(t.agents.map(s=>s.name)),{agents:r}=await e.listAgents();o.agents=r.filter(s=>Me(s)&&!i.has(s.name)).map(s=>s.name)}if(n.memory){let i=new Set(t.memory.map(s=>s.path)),{files:r}=await e.listMemory();o.memory=r.filter(s=>Me(s)&&!i.has(s.path)).map(s=>s.path)}return o.skills.sort(),o.agents.sort(),o.memory.sort(),o}function Ii(e){return e instanceof u?e.code:e instanceof Error?e.message:String(e)}async function an(e,t){let n={deleted:0,failures:[]},o=async(i,r,s)=>{for(let p of i)try{await s(p),n.deleted+=1}catch(a){n.failures.push({what:r(p),code:Ii(a)})}};return await o(t.skills,i=>`skill ${i}`,i=>e.deleteSkill(i)),await o(t.agents,i=>`agent ${i}`,i=>e.deleteAgent(i)),await o(t.memory,i=>i,i=>e.deleteMemory(i)),n}import{mkdir as ln,writeFile as _i}from"node:fs/promises";import{dirname as Ei,resolve as cn,sep as Oi}from"node:path";async function pn(e,t){let n=cn(t);await ln(n,{recursive:!0});let o={written:0,refused:[],collisions:[],failures:[]},{files:i}=await e.listMemory(),r=[...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 r){if(!C(p.path)){o.refused.push(p.path);continue}let a=cn(n,...p.path.split("/"));if(!a.startsWith(n+Oi)){o.refused.push(p.path);continue}if(s.has(a)){o.collisions.push(p.path);continue}try{let l=await e.readMemory(p.path);await ln(Ei(a),{recursive:!0}),await _i(a,l.content,"utf8"),s.add(a),o.written+=1}catch(l){o.failures.push({what:p.path,code:l instanceof Error?l.message:String(l)})}}return o}import{mkdir as dn,writeFile as Ni}from"node:fs/promises";import{dirname as Mi,resolve as mn,sep as Li}from"node:path";import{unzipSync as Ri}from"fflate";async function un(e,t){let n=mn(t);await dn(n,{recursive:!0});let o={written:0,refused:[],failed:[]},i=Ri(e);for(let[r,s]of Object.entries(i)){if(r.endsWith("/"))continue;let p=r.split("/");if(r.startsWith("/")||/^[a-zA-Z]:/.test(r)||r.includes("\\")||p.some(c=>c===""||c==="."||c==="..")){o.refused.push(r);continue}let l=mn(n,...p);if(!l.startsWith(n+Li)){o.refused.push(r);continue}try{await dn(Mi(l),{recursive:!0}),await Ni(l,s),o.written+=1}catch(c){o.failed.push({path:r,reason:c instanceof Error?c.message:String(c)})}}return o}var I=process.env.ONLYMCP_API_URL??"https://only-mcp.com",_=new Di().name("onlymcp").version(D);function Ki(e,t){try{let n=new URL(e);return(n.protocol==="https:"||n.protocol==="http:")&&n.origin===t}catch{return!1}}_.command("login").description("Connect this device to OnlyMCP").action(async()=>{De("OnlyMCP"),d.info(`This device will register itself as: ${await he()}`);let t=await(await fetch(`${I}/api/auth/device/code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:"onlymcp-cli"})})).json();d.info(`Code: ${t.user_code}`),d.info(t.verification_uri),console.log(await zi.toString(t.verification_uri_complete,{type:"terminal",small:!0})),Ki(t.verification_uri_complete,new URL(I).origin)&&await ji(t.verification_uri_complete).catch(()=>{});let n=me();n.start("Waiting for confirmation");let o=await Ze(I,t.device_code,t.interval??5);A.save(o),n.stop("Connected");let i=new T(I,()=>A.read()),r=await bn(i),s=vn(r);s&&d.info(s),G(`${r.skills} skills, ${r.agents} agents, ${r.files} files ready`)});async function bn(e){let t=await ee(),n={skills:0,agents:0,files:0,kept:[],ignored:new Set,removed:0};for(let o of q()){let i=await ie(e,o,{ignore:t});n.skills+=i.skills,n.agents+=i.agents,n.files+=i.files;for(let r of i.kept)n.kept.push(`${o}/${r}`);for(let r of i.ignored)n.ignored.add(r);n.removed+=i.removed}return n}function vn(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 ${Y()}${t}`}async function Ue(e,t,n){try{await e.reportRun(t,n)}catch{}}async function Vi(e){try{return await new T(I,()=>e).signOut(),null}catch(t){return t instanceof u&&t.status>0?`HTTP ${t.status}`:t instanceof Error?t.message:String(t)}}_.command("logout").description("End this device's session, then remove its login and cache").action(async()=>{let e=A.read(),t=e?await Vi(e):null;if(A.clear(),await new j().clear(),t){d.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.`),d.success("Logged out on this device");return}d.success("Logged out")});_.command("status").description("Show whether this device is logged in").action(()=>{d.info(A.read()?"logged in":"not logged in")});_.command("sync").description("Rewrite the stub files").option("--memory <dir>","Also write memory as files into this folder").action(async e=>{let t=new T(I,()=>A.read()),n=await bn(t);d.success(`${n.skills} skills, ${n.agents} agents, ${n.files} files`);let o=vn(n);o&&d.info(o),n.kept.length>0&&d.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(`
62
+ `));let i=n.skills+n.agents+n.files;if(!e.memory){await Ue(t,"sync",i);return}let r=await pn(t,e.memory);d.success(`${r.written} memory files to ${e.memory}`),r.collisions.length>0&&d.warn(["Team files with a path an existing file of yours already has",...r.collisions.map(s=>` ${s}`)].join(`
63
+ `)),r.refused.length>0&&d.warn(["Paths refused",...r.refused.map(s=>` ${s}`)].join(`
64
+ `)),r.failures.length>0&&(d.error([`${r.failures.length} failed`,...r.failures.map(s=>` ${s.what} ${s.code}`)].join(`
65
+ `)),process.exitCode=1),r.failures.length===0&&await Ue(t,"sync",i+r.written)});_.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??yn(),n=rt(t,e);function o(i){if(e.print){d.info(`${i.name} -> ${i.configPath}`),console.log(i.snippet);return}try{st(i)==="already-present"?d.info(`${i.name} is already set up: ${i.configPath}`):d.success(`${i.name} set up: ${i.configPath}`),i.id==="claude-code"&&d.info(ot)}catch(r){d.error(r instanceof Error?r.message:String(r)),process.exitCode=1}}switch(n.kind){case"conflicting-options":d.error("Pass either --client <id> or --all, not both."),process.exitCode=2;return;case"missing-client":d.info(`Known clients: ${n.targets.map(i=>i.id).join(", ")}`),d.info("Pass --client <id>, or --all."),process.exitCode=2;return;case"unknown-client":d.error(`Unknown client. Known: ${n.targets.map(i=>i.id).join(", ")}`),process.exitCode=1;return;case"none-present-for-all":d.error("No known client is set up on this machine yet."),d.info(`Pass --client <id> to write its config anyway. Known: ${n.targets.map(i=>i.id).join(", ")}.`),process.exitCode=2;return;case"single":o(n.target);return;case"all":for(let i of n.present)o(i);n.skipped.length>0&&d.info(`Skipped, not set up on this machine: ${n.skipped.map(i=>i.id).join(", ")}`);return}});function Re(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function de(e){return e.reduce((t,n)=>t+n.bytes,0)}function Ji(e,t){let n=e.skills.reduce((r,s)=>r+s.files.length,0),o=e.skills.filter(r=>r.files.length>0).length,i=e.skills.reduce((r,s)=>r+de(s.files),0);if(t.skills&&d.message(`Skills ${String(e.skills.length).padStart(4)} from ${t.skills}
66
+ ${String(n).padStart(4)} more files across ${o} skills ${Re(de(e.skills)+i)}`),t.agents&&d.message(`Agents ${String(e.agents.length).padStart(4)} from ${t.agents} ${Re(de(e.agents))}`),t.memory&&d.message(`Memory ${String(e.memory.length).padStart(4)} from ${t.memory} ${Re(de(e.memory))}`),e.skipped.length>0){let r=new Map;for(let s of e.skipped)r.set(s.reason,(r.get(s.reason)??0)+1);d.message(["Skipped",...[...r].map(([s,p])=>` ${String(p).padStart(4)} ${s}`)].join(`
67
+ `))}e.noDescription.length>0&&d.warn(["Missing a description in the SKILL.md header",...e.noDescription.map(r=>` ${r}`)].join(`
68
+ `)),e.flagged.length>0&&d.warn(["Held back over possible credentials (none of it left this machine)",...e.flagged.flatMap(r=>[` ${r.relative}`,...r.hits.map(s=>` line ${s.line} rule ${s.rule} ${s.excerpt}`)])].join(`
69
+ `))}_.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??yn(),n=!!(e.skills||e.agents||e.memory),o={skills:n?e.skills:hn(t,".claude","skills"),agents:n?e.agents:hn(t,".claude","agents"),memory:e.memory};De("OnlyMCP Import");let i=me();i.start("Reading the folders");let r;try{let[a,l,c]=await Promise.all([o.skills&&$(o.skills)?U(o.skills):Promise.resolve([]),o.agents&&$(o.agents)?U(o.agents):Promise.resolve([]),o.memory&&$(o.memory)?U(o.memory):Promise.resolve([])]);r=Oe({skills:a,agents:l,memory:c},{skillsRoot:o.skills})}catch(a){i.stop("Aborted"),d.error(a instanceof Error?a.message:String(a)),process.exitCode=1;return}i.stop("Read"),Ji(r,{skills:o.skills&&$(o.skills)?o.skills:void 0,agents:o.agents&&$(o.agents)?o.agents:void 0,memory:o.memory&&$(o.memory)?o.memory:void 0});let s=Ne(r);if(s===0&&!e.prune){G("Nothing to do.");return}if(e.dryRun&&!e.prune){G("Nothing uploaded (--dry-run).");return}let p=new T(I,()=>A.read());try{let a=await p.getMe();d.info(`Target ${I} as ${a.email} plan ${a.plan.name}`)}catch(a){d.error(`Not logged in, or the server is unreachable (${a instanceof Error?a.message:String(a)}).`),d.info("First: npx onlymcp login"),process.exitCode=1;return}if(s>0&&!e.yes&&!e.dryRun){if(!process.stdin.isTTY){d.error("No terminal for the prompt. Run --dry-run first, then --yes."),process.exitCode=1;return}let a=await fn({message:`Upload ${s} entries?`,initialValue:!1});if(Le(a)||!a){gn("Cancelled. Nothing uploaded.");return}if(r.flagged.length>0){let l=await Ui({message:"Send the held-back files anyway?",options:r.flagged.map(c=>({value:c.relative,label:c.relative})),required:!1,initialValues:[]});if(Le(l)){gn("Cancelled. Nothing uploaded.");return}if(l.length>0){let c=new Set(l),h=g=>g.map(k=>c.has(k.relative)?{...k,hits:[]}:k),[m,b,v]=await Promise.all([o.skills&&$(o.skills)?U(o.skills):Promise.resolve([]),o.agents&&$(o.agents)?U(o.agents):Promise.resolve([]),o.memory&&$(o.memory)?U(o.memory):Promise.resolve([])]);r=Oe({skills:h(m),agents:h(b),memory:h(v)},{skillsRoot:o.skills})}}}if(s>0&&!e.dryRun){let a=me();a.start("Uploading");let l=await nn(p,r,(c,h,m)=>{a.message(`${c}/${h} ${m}`)});a.stop("Done"),d.success(`${l.skills} skills, ${l.skillFiles} skill files, ${l.agents} agents, ${l.memory} memory files`),l.failures.length>0?(d.error([`${l.failures.length} failed`,...l.failures.map(c=>` ${c.what} ${c.code}`)].join(`
70
+ `)),process.exitCode=1):await Ue(p,"import",l.skills+l.skillFiles+l.agents+l.memory)}if(e.prune){let a={skills:!!(o.skills&&$(o.skills)),agents:!!(o.agents&&$(o.agents)),memory:!!(o.memory&&$(o.memory))},l=await sn(p,r,a);if(on(l))d.info("Nothing to delete: the account holds nothing the source does not know.");else if(d.warn(["Would delete (only your own, nothing from a team, nothing archived)",...l.skills.map(c=>` Skill ${c}`),...l.agents.map(c=>` Agent ${c}`),...l.memory.map(c=>` Memory ${c}`)].join(`
71
+ `)),e.dryRun)d.info("Nothing deleted (--dry-run).");else if(!process.stdin.isTTY)d.error("No terminal for the prompt. Nothing deleted."),process.exitCode=1;else{let c=await fn({message:`Delete ${rn(l)} entries in the account?`,initialValue:!1});if(Le(c)||!c)d.info("Nothing deleted.");else{let h=await an(p,l);d.success(`${h.deleted} deleted`),h.failures.length>0&&(d.error([`${h.failures.length} failed`,...h.failures.map(m=>` ${m.what} ${m.code}`)].join(`
72
+ `)),process.exitCode=1)}}}G(e.dryRun?"Nothing changed (--dry-run).":"Then: npx onlymcp sync on every device.")});_.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){d.error("Either --out <folder> or --zip <file>, not both and not neither."),process.exitCode=1;return}De("OnlyMCP Export");let t=new T(I,()=>A.read()),n=me();n.start("Fetching the archive");let o;try{o=await t.exportArchive({scope:e.scope,types:e.types?.split(",").map(s=>s.trim()).filter(s=>s!=="")})}catch(s){n.stop("Aborted"),d.error(s instanceof Error?s.message:String(s)),d.info("Not logged in? First: npx onlymcp login"),process.exitCode=1;return}if(e.zip){Gi(Bi(e.zip),{recursive:!0}),await Hi(Wi.fromWeb(o.body),Fi(e.zip)),n.stop("Done"),G(`Archive: ${e.zip}`);return}let i=new Uint8Array(await o.arrayBuffer()),r=await un(i,e.out);n.stop("Done"),d.success(`${r.written} files in ${e.out}`),r.refused.length>0&&d.warn(["Not written, path in the archive is not allowed",...r.refused.map(s=>` ${s}`)].join(`
73
+ `)),r.failed.length>0&&(d.warn(["Not written, the filename doesn't work on this system",...r.failed.map(s=>` ${s.path} ${s.reason}`),"With --zip <file> the archive stays unchanged."].join(`
74
+ `)),process.exitCode=1),G(`Restore: npx onlymcp import --skills ${e.out}/skills --agents ${e.out}/agents --memory ${e.out}/memory`)});_.command("mcp").description("Run the stdio MCP server, the process an MCP client starts").action(qt);await _.parseAsync();
package/dist/bin/mcp.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import{Server as xn}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Sn}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as wn,ListToolsRequestSchema as kn}from"@modelcontextprotocol/sdk/types.js";import{hostname as _t}from"node:os";import{execFile as xt}from"node:child_process";import{hostname as St}from"node:os";import{readFile as wt}from"node:fs/promises";import{promisify as kt}from"node:util";import{randomUUID as pe}from"node:crypto";import{link as dt,mkdir as pt,readFile as mt,rename as ut,rm as ht,writeFile as me}from"node:fs/promises";import{basename as gt,dirname as he,join as ft}from"node:path";import{existsSync as ct}from"node:fs";import{homedir as se}from"node:os";import{join as C}from"node:path";function E(){return process.env.ONLYMCP_HOME??C(se(),".claude","onlymcp")}function ie(){return process.env.ONLYMCP_HOME??se()}function ae(){return C(E(),"device-id")}function le(){return C(E(),"cache")}function ce(){return C(E(),"stub-ignore")}function de(){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[C(ie(),".claude"),C(ie(),".codex")])ct(e)&&!t.includes(e)&&t.push(e);return t.length>0?t:[C(E(),"plugin")]}var yt=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,ue;function ge(){return ue??=bt(),ue}async function B(t){try{let e=(await mt(t,"utf8")).trim().toLowerCase();return yt.test(e)?e:null}catch{return null}}async function bt(){let t=ae(),e=await B(t);if(e)return e;try{return await pt(he(t),{recursive:!0}),await Ct(t)}catch{return null}}var vt=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function Ct(t){let e=pe(),n=ft(he(t),`.${gt(t)}.${process.pid}.${pe()}.tmp`);try{await me(n,`${e}
3
- `,{flag:"wx",mode:384});try{return await dt(n,t),e}catch(r){let i=r.code;if(i!=="EEXIST"&&!vt.has(i??""))throw r;if(i!=="EEXIST")try{return await me(t,`${e}
4
- `,{flag:"wx",mode:384}),e}catch(d){if(d.code!=="EEXIST")throw d}}let o=await B(t);return o||(await ut(n,t),await B(t)??e)}finally{await ht(n,{force:!0}).catch(()=>{})}}var M="0.20.0";var At=kt(xt),Tt=`onlymcp-cli/${M} (${process.platform} ${process.arch}; node ${process.versions.node})`,fe=200;async function ye(t,e){let n;try{return await Promise.race([t,new Promise(o=>{n=setTimeout(()=>o(null),e),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function $t(){try{if(process.platform==="linux"){let t=wt("/sys/class/dmi/id/product_version","utf8"),n=(await ye(t,fe))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let t=At("sysctl",["-n","hw.model"]);return(await ye(t,fe))?.stdout.trim()||null}}catch{}return null}async function It(){let t="unknown";try{t=St()||"unknown"}catch{}let e=await $t();return(e&&e!==t?`${t} (${e})`:t).slice(0,60)}var be=null;async function V(){be??=await It();let t=await ge();return{"user-agent":Tt,"x-onlymcp-device":be,...t?{"x-onlymcp-device-id":t}:{}}}var a=class extends Error{constructor(n,o={},r=0){super(n);this.code=n;this.params=o;this.status=r;this.name="ApiError"}code;params;status},P=class{constructor(e,n){this.baseUrl=e;this.token=n}baseUrl;token;async call(e,n={}){let o=this.token();if(!o)throw new a("errors.NOT_LOGGED_IN");let r=await fetch(`${this.baseUrl}${e}`,{...n,headers:{...await V(),...n.headers??{},authorization:`Bearer ${o}`,"content-type":"application/json"}});if(r.status===204)return;let i=await r.json().catch(()=>({}));if(!r.ok)throw new a(i.code??"errors.UNKNOWN",i.params??{},r.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){return this.call(`/api/skills/${encodeURIComponent(e)}`)}putSkill(e,n,o={}){return this.call(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({body:n,...o})})}skillFileUrl(e,n){let o=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(e)}/files/${o}`}getSkillFile(e,n){return this.call(this.skillFileUrl(e,n))}putSkillFile(e,n,o,r="utf8"){return this.call(this.skillFileUrl(e,n),{method:"PUT",body:JSON.stringify({content:o,encoding:r})})}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}={}){return this.call(`/api/agents/${encodeURIComponent(e)}${n?"?use=1":""}`)}readMemory(e){return this.call(this.memoryUrl(e))}writeMemory(e,n,o){return this.call(this.memoryUrl(e),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:o})})}memoryUrl(e){return`/api/memory/${e.split("/").map(encodeURIComponent).join("/")}`}listMemory(){return this.call("/api/memory")}searchContent(e,n={}){let o=new URLSearchParams({q:e});return n.types?.length&&o.set("types",n.types.join(",")),n.limit&&o.set("limit",String(n.limit)),this.call(`/api/search?${o.toString()}`)}memoryTree(e="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(e)}`)}moveMemory(e,n,o=!0,r=_t()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:e,to:n,updateLinks:o,deviceLabel:r})})}async exportArchive(e={}){let n=this.token();if(!n)throw new a("errors.NOT_LOGGED_IN");let o=new URLSearchParams;e.scope&&o.set("scope",e.scope),e.types?.length&&o.set("types",e.types.join(","));let r=o.size>0?`?${o.toString()}`:"",i=await fetch(`${this.baseUrl}/api/export${r}`,{headers:{...await V(),authorization:`Bearer ${n}`}});if(!i.ok){let d=await i.json().catch(()=>({}));throw new a(d.code??"errors.UNKNOWN",d.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")}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,o){return this.call(`/api/mcp-connections/${e}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:o})})}};var Ot="https://only-mcp.com";function ve(t=process.env.ONLYMCP_API_URL){if(t===void 0)return Ot;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 Nt}from"@napi-rs/keyring";function Lt(t,e){let n=()=>new Nt(t,e);return{save(o){n().setPassword(o)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var Ce=Lt("onlymcp","session-token");import U from"cacache";var Et=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),R=class{constructor(e=le()){this.dir=e}dir;async get(e){try{let n=await U.get(this.dir,e),o=n.metadata;return!o||o.expiresAt<=Date.now()?(await U.rm.entry(this.dir,e),null):n.data.toString("utf8")}catch{return null}}async set(e,n,o=Et){await U.put(this.dir,e,n,{metadata:{expiresAt:Date.now()+o*1e3}})}async clear(){await U.rm.all(this.dir)}};var xe=["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(" "),Mt=["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 Se(t,e,n,o){if(n.length===0)return"";let r=[];for(let u of n){let g=n.length-r.length-1,f=g>0?` (+${g} more, call ${e})`:"",A=`
2
+ import{Server as wn}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as kn}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as An,ListToolsRequestSchema as Tn}from"@modelcontextprotocol/sdk/types.js";import{hostname as Ot}from"node:os";import{execFile as xt}from"node:child_process";import{hostname as wt}from"node:os";import{readFile as kt}from"node:fs/promises";import{promisify as At}from"node:util";import{randomUUID as me}from"node:crypto";import{link as pt,mkdir as mt,readFile as ut,rename as ht,rm as gt,writeFile as ue}from"node:fs/promises";import{basename as ft,dirname as ge,join as yt}from"node:path";import{existsSync as dt}from"node:fs";import{homedir as ae}from"node:os";import{join as C}from"node:path";function E(){return process.env.ONLYMCP_HOME??C(ae(),".claude","onlymcp")}function se(){return process.env.ONLYMCP_HOME??ae()}function le(){return C(E(),"device-id")}function ce(){return C(E(),"cache")}function de(){return C(E(),"stub-ignore")}function pe(){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[C(se(),".claude"),C(se(),".codex")])dt(e)&&!t.includes(e)&&t.push(e);return t.length>0?t:[C(E(),"plugin")]}var bt=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,he;function fe(){return he??=vt(),he}async function B(t){try{let e=(await ut(t,"utf8")).trim().toLowerCase();return bt.test(e)?e:null}catch{return null}}async function vt(){let t=le(),e=await B(t);if(e)return e;try{return await mt(ge(t),{recursive:!0}),await St(t)}catch{return null}}var Ct=new Set(["EPERM","ENOTSUP","EOPNOTSUPP","ENOSYS","EXDEV"]);async function St(t){let e=me(),n=yt(ge(t),`.${ft(t)}.${process.pid}.${me()}.tmp`);try{await ue(n,`${e}
3
+ `,{flag:"wx",mode:384});try{return await pt(n,t),e}catch(r){let i=r.code;if(i!=="EEXIST"&&!Ct.has(i??""))throw r;if(i!=="EEXIST")try{return await ue(t,`${e}
4
+ `,{flag:"wx",mode:384}),e}catch(c){if(c.code!=="EEXIST")throw c}}let o=await B(t);return o||(await ht(n,t),await B(t)??e)}finally{await gt(n,{force:!0}).catch(()=>{})}}var M="0.21.2";var Tt=At(xt),$t=`onlymcp-cli/${M} (${process.platform} ${process.arch}; node ${process.versions.node})`,ye=200;async function be(t,e){let n;try{return await Promise.race([t,new Promise(o=>{n=setTimeout(()=>o(null),e),n.unref?.()})])}catch{return null}finally{n&&clearTimeout(n)}}async function It(){try{if(process.platform==="linux"){let t=kt("/sys/class/dmi/id/product_version","utf8"),n=(await be(t,ye))?.trim();return!n||/^(to be filled|default string|system version|none|n\/a)/i.test(n)?null:n}if(process.platform==="darwin"){let t=Tt("sysctl",["-n","hw.model"]);return(await be(t,ye))?.stdout.trim()||null}}catch{}return null}async function _t(){let t="unknown";try{t=wt()||"unknown"}catch{}let e=await It();return(e&&e!==t?`${t} (${e})`:t).slice(0,60)}var ve=null;async function V(){ve??=await _t();let t=await fe();return{"user-agent":$t,"x-onlymcp-device":ve,...t?{"x-onlymcp-device-id":t}:{}}}var a=class extends Error{constructor(n,o={},r=0){super(n);this.code=n;this.params=o;this.status=r;this.name="ApiError"}code;params;status},P=class{constructor(e,n){this.baseUrl=e;this.token=n}baseUrl;token;async call(e,n={}){let o=this.token();if(!o)throw new a("errors.NOT_LOGGED_IN");let r=await fetch(`${this.baseUrl}${e}`,{...n,headers:{...await V(),...n.headers??{},authorization:`Bearer ${o}`,"content-type":"application/json"}});if(r.status===204)return;let i=await r.json().catch(()=>({}));if(!r.ok)throw new a(i.code??"errors.UNKNOWN",i.params??{},r.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){return this.call(`/api/skills/${encodeURIComponent(e)}`)}putSkill(e,n,o={}){return this.call(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({body:n,...o})})}skillFileUrl(e,n){let o=n.split("/").map(encodeURIComponent).join("/");return`/api/skills/${encodeURIComponent(e)}/files/${o}`}getSkillFile(e,n){return this.call(this.skillFileUrl(e,n))}putSkillFile(e,n,o,r="utf8"){return this.call(this.skillFileUrl(e,n),{method:"PUT",body:JSON.stringify({content:o,encoding:r})})}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}={}){return this.call(`/api/agents/${encodeURIComponent(e)}${n?"?use=1":""}`)}readMemory(e){return this.call(this.memoryUrl(e))}writeMemory(e,n,o){return this.call(this.memoryUrl(e),{method:"PUT",body:JSON.stringify({content:n,deviceLabel:o})})}memoryUrl(e){return`/api/memory/${e.split("/").map(encodeURIComponent).join("/")}`}listMemory(){return this.call("/api/memory")}searchContent(e,n={}){let o=new URLSearchParams({q:e});return n.types?.length&&o.set("types",n.types.join(",")),n.limit&&o.set("limit",String(n.limit)),this.call(`/api/search?${o.toString()}`)}memoryTree(e="all"){return this.call(`/api/memory/tree?scope=${encodeURIComponent(e)}`)}moveMemory(e,n,o=!0,r=Ot()){return this.call("/api/memory/move",{method:"POST",body:JSON.stringify({from:e,to:n,updateLinks:o,deviceLabel:r})})}async exportArchive(e={}){let n=this.token();if(!n)throw new a("errors.NOT_LOGGED_IN");let o=new URLSearchParams;e.scope&&o.set("scope",e.scope),e.types?.length&&o.set("types",e.types.join(","));let r=o.size>0?`?${o.toString()}`:"",i=await fetch(`${this.baseUrl}/api/export${r}`,{headers:{...await V(),authorization:`Bearer ${n}`}});if(!i.ok){let c=await i.json().catch(()=>({}));throw new a(c.code??"errors.UNKNOWN",c.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")}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,o){return this.call(`/api/mcp-connections/${e}/capabilities/${n}`,{method:"PATCH",body:JSON.stringify({enabled:o})})}};var Nt="https://only-mcp.com";function Ce(t=process.env.ONLYMCP_API_URL){if(t===void 0)return Nt;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 Lt}from"@napi-rs/keyring";function Et(t,e){let n=()=>new Lt(t,e);return{save(o){n().setPassword(o)},read(){try{return n().getPassword()}catch{return null}},clear(){try{n().deletePassword()}catch{}}}}var Se=Et("onlymcp","session-token");import U from"cacache";var Mt=Number(process.env.ONLYMCP_TTL_SECONDS??360*60),R=class{constructor(e=ce()){this.dir=e}dir;async get(e){try{let n=await U.get(this.dir,e),o=n.metadata;return!o||o.expiresAt<=Date.now()?(await U.rm.entry(this.dir,e),null):n.data.toString("utf8")}catch{return null}}async set(e,n,o=Mt){await U.put(this.dir,e,n,{metadata:{expiresAt:Date.now()+o*1e3}})}async clear(){await U.rm.all(this.dir)}};var xe=["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(" "),Pt=["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 we(t,e,n,o){if(n.length===0)return"";let r=[];for(let u of n){let g=n.length-r.length-1,f=g>0?` (+${g} more, call ${e})`:"",A=`
5
5
 
6
6
  ${t}: ${[...r,u].join(", ")}${f}`;if(o+A.length>1800)break;r.push(u)}if(r.length===0)return`
7
7
 
8
- ${t}: call ${e}`;let i=n.length-r.length,d=i>0?` (+${i} more, call ${e})`:"";return`
8
+ ${t}: call ${e}`;let i=n.length-r.length,c=i>0?` (+${i} more, call ${e})`:"";return`
9
9
 
10
- ${t}: ${r.join(", ")}${d}`}function K(t,e,n={}){let o=n.brainvault===!1?xe:`${xe} ${Mt}`,r=e.length>0?26:0;return o+=Se("Skills","list_skills",t,o.length+r),o+=Se("Agents","list_agents",e,o.length),o}function J(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 o=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:e,websiteUrl:o,icons:[{src:`${o}/brand/connector-512.png`,mimeType:"image/png"},{src:`${o}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}import{access as zt,mkdir as X,readFile as jt,rm as Ae,writeFile as D}from"node:fs/promises";import{dirname as Gt,join as _}from"node:path";function we(t){if(!t.startsWith(`---
10
+ ${t}: ${r.join(", ")}${c}`}function K(t,e,n={}){let o=n.brainvault===!1?xe:`${xe} ${Pt}`,r=e.length>0?26:0;return o+=we("Skills","list_skills",t,o.length+r),o+=we("Agents","list_agents",e,o.length),o}function J(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 o=n.origin;return{name:"onlymcp",title:"OnlyMCP",version:e,websiteUrl:o,icons:[{src:`${o}/brand/connector-512.png`,mimeType:"image/png"},{src:`${o}/brand/favicon.svg`,mimeType:"image/svg+xml"}]}}import{access as jt,mkdir as X,readFile as Gt,rm as Te,writeFile as D}from"node:fs/promises";import{dirname as Ft,join as _}from"node:path";function ke(t){if(!t.startsWith(`---
11
11
  `))return null;let e=t.indexOf(`
12
- ---`,3);return e<0?null:t.slice(4,e)}function q(t,e){if(!/^[a-zA-Z0-9_-]+$/.test(e))return;let n=new RegExp(`^${e}:[ \\t]*(.*)$`,"m").exec(t);if(!n)return;let r=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return r.length>0?r:void 0}import{readFile as Pt}from"node:fs/promises";var Y=()=>!1;function Ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rt(t){let e=t.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(Ut).join(".*")}$`));return n=>e.some(o=>o.test(n))}async function ke(t=ce()){try{return Rt(await Pt(t,"utf8"))}catch(e){if(e.code==="ENOENT")return Y;throw e}}var Dt=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function I(t){if(t.length===0||t.length>200||t==="SKILL.md")return!1;let e=t.split("/");return e.length>8?!1:e.every(n=>Dt.test(n)&&n!==".."&&n!==".")}var Ft=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ht=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,Z="x-onlymcp-stub";function z(t){return t.replace(/:/g,"-")}function j(t){return(t??"").replace(/[\r\n]+/g," ").trim()}async function Q(t,e){let n;try{n=await jt(t,"utf8")}catch{return!0}let o=we(n);if(o===null||q(o,Z)!=="true")return!1;let r=q(o,"x-onlymcp-name");return r===void 0||r===e}async function Te(t,e){return await zt(t).then(()=>!0,()=>!1)&&await Q(t,e)}async function $e(t,e,n={}){let o=n.ignore??Y,[{skills:r},{agents:i}]=await Promise.all([t.listSkills(),t.listAgents()]),d=0,u=0,g=[],f=[],A=0;for(let s of r){if(!Ht.test(s.name))continue;let b=_(e,"skills",z(s.name)),T=_(b,"SKILL.md");if(o(s.name)||o(z(s.name))){f.push(s.name),await Te(T,s.name)&&(await Ae(b,{recursive:!0,force:!0}),A+=1);continue}if(!await Q(T,s.name)){g.push(`skills/${z(s.name)}`);continue}await X(b,{recursive:!0}),await D(T,`---
12
+ ---`,3);return e<0?null:t.slice(4,e)}function Y(t,e){if(!/^[a-zA-Z0-9_-]+$/.test(e))return;let n=new RegExp(`^${e}:[ \\t]*(.*)$`,"m").exec(t);if(!n)return;let r=n[1].trim().replace(/^(['"])(.*)\1$/,"$2").trim();return r.length>0?r:void 0}import{readFile as Ut}from"node:fs/promises";var q=()=>!1;function Rt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dt(t){let e=t.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>new RegExp(`^${n.split("*").map(Rt).join(".*")}$`));return n=>e.some(o=>o.test(n))}async function Ae(t=de()){try{return Dt(await Ut(t,"utf8"))}catch(e){if(e.code==="ENOENT")return q;throw e}}var zt=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function I(t){if(t.length===0||t.length>200||t==="SKILL.md")return!1;let e=t.split("/");return e.length>8?!1:e.every(n=>zt.test(n)&&n!==".."&&n!==".")}var Ht=/^[a-z0-9]+(-[a-z0-9]+)*$/,Wt=/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/,Z="x-onlymcp-stub";function z(t){return t.replace(/:/g,"-")}function j(t){return(t??"").replace(/[\r\n]+/g," ").trim()}async function Q(t,e){let n;try{n=await Gt(t,"utf8")}catch{return!0}let o=ke(n);if(o===null||Y(o,Z)!=="true")return!1;let r=Y(o,"x-onlymcp-name");return r===void 0||r===e}async function $e(t,e){return await jt(t).then(()=>!0,()=>!1)&&await Q(t,e)}async function Ie(t,e,n={}){let o=n.ignore??q,[{skills:r},{agents:i}]=await Promise.all([t.listSkills(),t.listAgents()]),c=0,u=0,g=[],f=[],A=0;for(let s of r){if(!Wt.test(s.name))continue;let b=_(e,"skills",z(s.name)),T=_(b,"SKILL.md");if(o(s.name)||o(z(s.name))){f.push(s.name),await $e(T,s.name)&&(await Te(b,{recursive:!0,force:!0}),A+=1);continue}if(!await Q(T,s.name)){g.push(`skills/${z(s.name)}`);continue}await X(b,{recursive:!0}),await D(T,`---
13
13
  name: ${z(s.name)}
14
14
  description: ${j(s.description)||"Synchronisiert ueber OnlyMCP. Inhalt wird bei Bedarf geladen."}
15
15
  ${Z}: true
@@ -17,7 +17,7 @@ x-onlymcp-name: ${s.name}
17
17
  ---
18
18
 
19
19
  Call \`get_skill({ name: "${s.name}" })\` on the OnlyMCP server and follow whatever comes back.
20
- `,"utf8"),u+=1;try{let L=await t.getSkill(s.name);for(let $ of L.files??[]){if(!I($.path))continue;let H=await t.getSkillFile(s.name,$.path),W=_(b,...$.path.split("/"));await X(Gt(W),{recursive:!0}),H.encoding==="base64"?await D(W,Buffer.from(H.content,"base64")):await D(W,H.content,"utf8"),d+=1}}catch{}}await X(_(e,"agents"),{recursive:!0});let re=0;for(let s of i){if(!Ft.test(s.name))continue;let b=_(e,"agents",`${s.name}.md`);if(o(s.name)){f.push(s.name),await Te(b,s.name)&&(await Ae(b),A+=1);continue}if(!await Q(b,s.name)){g.push(`agents/${s.name}.md`);continue}let T=j(s.description),L=s.model?j(s.model):"",$=s.tools.map(j).join(", ");await D(b,`---
20
+ `,"utf8"),u+=1;try{let L=await t.getSkill(s.name);for(let $ of L.files??[]){if(!I($.path))continue;let H=await t.getSkillFile(s.name,$.path),W=_(b,...$.path.split("/"));await X(Ft(W),{recursive:!0}),H.encoding==="base64"?await D(W,Buffer.from(H.content,"base64")):await D(W,H.content,"utf8"),c+=1}}catch{}}await X(_(e,"agents"),{recursive:!0});let ie=0;for(let s of i){if(!Ht.test(s.name))continue;let b=_(e,"agents",`${s.name}.md`);if(o(s.name)){f.push(s.name),await $e(b,s.name)&&(await Te(b),A+=1);continue}if(!await Q(b,s.name)){g.push(`agents/${s.name}.md`);continue}let T=j(s.description),L=s.model?j(s.model):"",$=s.tools.map(j).join(", ");await D(b,`---
21
21
  name: ${s.name}
22
22
  description: ${T}
23
23
  ${L?`model: ${L}
@@ -27,20 +27,26 @@ x-onlymcp-name: ${s.name}
27
27
  ---
28
28
 
29
29
  Call \`get_agent_definition({ name: "${s.name}" })\` on the OnlyMCP server and follow whatever comes back.
30
- `,"utf8"),re+=1}return{skills:u,agents:re,files:d,kept:g,ignored:f,removed:A}}import{z as Cn}from"zod";var p=t=>({title:t,annotations:{readOnlyHint:!0,openWorldHint:!1}}),m=(t,e)=>({title:t,annotations:{readOnlyHint:!1,destructiveHint:e.destructive,idempotentHint:e.idempotent,openWorldHint:e.openWorld??!1}}),ee={list_memory:p("List memory files"),memory_read:p("Read a memory file"),memory_write:m("Write a memory file",{destructive:!0,idempotent:!0}),memory_delete:m("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:p("Search memory"),memory_tree:p("Show the memory tree"),memory_move:m("Move a memory file or folder",{destructive:!1,idempotent:!1}),memory_links:p("Show memory links"),list_skills:p("List skills"),get_skill:p("Load a skill"),skill_write:m("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:m("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:p("List skill files"),get_skill_file:p("Read a skill file"),skill_file_write:m("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:m("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:p("List agents"),get_agent_definition:p("Load an agent definition"),agent_write:m("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:m("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:p("List connections"),connection_create:m("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:m("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:m("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:p("List a connection's tools"),connection_tool_toggle:m("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:p("Show a connection tool's schema"),connection_call:m("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0})};import{z as Ie}from"zod";var Wt=Ie.object({name:Ie.string().min(1).max(64)});function _e(t,e){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:Wt,async handler(n){let o=`agent:${n.name}`,r=await e.get(o);if(r!==null)return{content:[{type:"text",text:r}]};try{let i=await t.getAgent(n.name,{use:!0});return await e.set(o,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof a?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as te}from"zod";var Bt=te.object({name:te.string().min(1).max(64),path:te.string().min(1).max(200)});function Oe(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:Bt,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 a?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Ne}from"zod";var Vt=Ne.object({name:Ne.string().min(1).max(64)});function Le(t,e){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:Vt,async handler(n){let o=`skill:${n.name}`,r=await e.get(o);if(r!==null)return{content:[{type:"text",text:r}]};try{let i=await t.getSkill(n.name);return await e.set(o,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof a?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Kt}from"zod";var Ee=Kt.object({});function Me(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:Ee,async handler(){try{let{skills:e}=await t.listSkills();return{content:[{type:"text",text:e.map(n=>n.name).join(`
31
- `)}]}}catch(e){return{content:[{type:"text",text:e instanceof a?e.code:"errors.UNKNOWN"}],isError:!0}}}}}function Pe(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:Ee,async handler(){try{let{agents:e}=await t.listAgents();return{content:[{type:"text",text:e.map(o=>`${o.name}: ${o.description}`).join(`
32
- `)}]}}catch(e){return{content:[{type:"text",text:e instanceof a?e.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Ue}from"zod";var Jt=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function y(t){return Jt.test(t)&&!t.split("/").includes("..")}var qt=Ue.object({path:Ue.string().min(3).max(256)});function Re(t){let e=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache.",inputSchema:qt,async handler(n){if(!y(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let o=e.get(n.path);return o||(o=t.readMemory(n.path).then(r=>r.content),e.set(n.path,o),o.finally(()=>e.delete(n.path))),{content:[{type:"text",text:await o}]}}catch(o){return{content:[{type:"text",text:o instanceof a?o.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as Yt}from"node:os";import{z as ne}from"zod";var Xt=ne.object({path:ne.string().min(3).max(256),content:ne.string().max(1e6)});function De(t){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through).",inputSchema:Xt,async handler(e){if(!y(e.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await t.writeMemory(e.path,e.content,Yt()),o=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(o+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:o}]}}catch(n){return{content:[{type:"text",text:n instanceof a?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as h}from"zod";var x=t=>({content:[{type:"text",text:t}]}),w=t=>({content:[{type:"text",text:t}],isError:!0});function G(t){return t instanceof a?t.code:"errors.UNKNOWN"}var Zt=h.object({query:h.string().min(1).max(200),types:h.string().max(64).optional(),limit:h.number().int().min(1).max(50).optional()});function je(t){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each.",inputSchema:Zt,async handler(e){try{let{hits:n}=await t.searchContent(e.query,{types:e.types?.split(",").map(o=>o.trim()).filter(o=>o!==""),limit:e.limit});return n.length===0?x(`Nothing found for ${e.query}`):x(n.map(o=>`${o.kind} ${o.path??o.name}${o.scope==="team"?" (team)":""}
30
+ `,"utf8"),ie+=1}return{skills:u,agents:ie,files:c,kept:g,ignored:f,removed:A}}import{z as xn}from"zod";var p=t=>({title:t,annotations:{title:t,readOnlyHint:!0,openWorldHint:!1}}),m=(t,e)=>({title:t,annotations:{title:t,readOnlyHint:!1,destructiveHint:e.destructive,idempotentHint:e.idempotent,openWorldHint:e.openWorld??!1}}),ee={list_memory:p("List memory files"),memory_read:p("Read a memory file"),memory_write:m("Write a memory file",{destructive:!0,idempotent:!0}),memory_delete:m("Delete a memory file",{destructive:!0,idempotent:!1}),memory_search:p("Search memory"),memory_tree:p("Show the memory tree"),memory_move:m("Move a memory file or folder",{destructive:!1,idempotent:!1}),memory_links:p("Show memory links"),list_skills:p("List skills"),get_skill:p("Load a skill"),skill_write:m("Write a skill",{destructive:!0,idempotent:!0}),skill_delete:m("Delete a skill",{destructive:!0,idempotent:!1}),list_skill_files:p("List skill files"),get_skill_file:p("Read a skill file"),skill_file_write:m("Write a skill file",{destructive:!0,idempotent:!0}),skill_file_delete:m("Delete a skill file",{destructive:!0,idempotent:!1}),list_agents:p("List agents"),get_agent_definition:p("Load an agent definition"),agent_write:m("Write an agent",{destructive:!0,idempotent:!0}),agent_delete:m("Delete an agent",{destructive:!0,idempotent:!1}),list_connections:p("List connections"),connection_create:m("Add a connection",{destructive:!1,idempotent:!1,openWorld:!0}),connection_update:m("Update a connection",{destructive:!1,idempotent:!0}),connection_delete:m("Delete a connection",{destructive:!0,idempotent:!1}),connection_tools:p("List a connection's tools"),connection_tool_toggle:m("Switch a connection tool on or off",{destructive:!1,idempotent:!0}),connection_tool_schema:p("Show a connection tool's schema"),connection_call:m("Call a connection tool",{destructive:!0,idempotent:!1,openWorld:!0})};import{z as _e}from"zod";var Bt=_e.object({name:_e.string().min(1).max(64)}),te=t=>t.replace(/[\r\n]+/g," ").trim();function Vt(t){let e=t.model?`model: ${te(t.model)}
31
+ `:"";return`---
32
+ name: ${t.name}
33
+ description: ${te(t.description??"")}
34
+ ${e}tools: ${(t.tools??[]).map(te).join(", ")}
35
+ ---
36
+ ${t.body}`}function Oe(t,e){return{name:"get_agent_definition",description:"Delivers an agent's system prompt from the OnlyMCP cloud.",inputSchema:Bt,async handler(n){let o=`agent:${n.name}`,r=await e.get(o);if(r!==null)return{content:[{type:"text",text:r}]};try{let i=await t.getAgent(n.name,{use:!0}),c=Vt(i);return await e.set(o,c),{content:[{type:"text",text:c}]}}catch(i){return{content:[{type:"text",text:i instanceof a?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as ne}from"zod";var Kt=ne.object({name:ne.string().min(1).max(64),path:ne.string().min(1).max(200)});function Ne(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:Kt,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 a?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Le}from"zod";var Jt=Le.object({name:Le.string().min(1).max(64)});function Ee(t,e){return{name:"get_skill",description:"Delivers a skill's full content from the OnlyMCP cloud. Called from the stub files.",inputSchema:Jt,async handler(n){let o=`skill:${n.name}`,r=await e.get(o);if(r!==null)return{content:[{type:"text",text:r}]};try{let i=await t.getSkill(n.name);return await e.set(o,i.body),{content:[{type:"text",text:i.body}]}}catch(i){return{content:[{type:"text",text:i instanceof a?i.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Yt}from"zod";var Me=Yt.object({});function Pe(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:Me,async handler(){try{let{skills:e}=await t.listSkills();return{content:[{type:"text",text:e.map(n=>n.name).join(`
37
+ `)}]}}catch(e){return{content:[{type:"text",text:e instanceof a?e.code:"errors.UNKNOWN"}],isError:!0}}}}}function Ue(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:Me,async handler(){try{let{agents:e}=await t.listAgents();return{content:[{type:"text",text:e.map(o=>`${o.name}: ${o.description}`).join(`
38
+ `)}]}}catch(e){return{content:[{type:"text",text:e instanceof a?e.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as Re}from"zod";var qt=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*\.md$/i;function y(t){return qt.test(t)&&!t.split("/").includes("..")}var Xt=Re.object({path:Re.string().min(3).max(256)});function De(t){let e=new Map;return{name:"memory_read",description:"Reads a memory file live from the OnlyMCP cloud. No disk cache.",inputSchema:Xt,async handler(n){if(!y(n.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let o=e.get(n.path);return o||(o=t.readMemory(n.path).then(r=>r.content),e.set(n.path,o),o.finally(()=>e.delete(n.path))),{content:[{type:"text",text:await o}]}}catch(o){return{content:[{type:"text",text:o instanceof a?o.code:"errors.UNKNOWN"}],isError:!0}}}}}import{hostname as Zt}from"node:os";import{z as oe}from"zod";var Qt=oe.object({path:oe.string().min(3).max(256),content:oe.string().max(1e6)});function ze(t){return{name:"memory_write",description:"Writes a memory file live into the OnlyMCP cloud (write-through).",inputSchema:Qt,async handler(e){if(!y(e.path))return{content:[{type:"text",text:"errors.INVALID_PATH"}],isError:!0};try{let n=await t.writeMemory(e.path,e.content,Zt()),o=n.warning?`${n.path} ${n.updatedAt} ${n.warning.code} ${JSON.stringify(n.warning.params)}`:`${n.path} ${n.updatedAt}`;return n.routedTo&&(o+=` (created in team ${n.routedTo.teamName})`),{content:[{type:"text",text:o}]}}catch(n){return{content:[{type:"text",text:n instanceof a?n.code:"errors.UNKNOWN"}],isError:!0}}}}}import{z as h}from"zod";var S=t=>({content:[{type:"text",text:t}]}),w=t=>({content:[{type:"text",text:t}],isError:!0});function G(t){return t instanceof a?t.code:"errors.UNKNOWN"}var en=h.object({query:h.string().min(1).max(200),types:h.string().max(64).optional(),limit:h.number().int().min(1).max(50).optional()});function Ge(t){return{name:"memory_search",description:"Full-text search across memory, skills and agents. Delivers the best hits with a short snippet each.",inputSchema:en,async handler(e){try{let{hits:n}=await t.searchContent(e.query,{types:e.types?.split(",").map(o=>o.trim()).filter(o=>o!==""),limit:e.limit});return n.length===0?S(`Nothing found for ${e.query}`):S(n.map(o=>`${o.kind} ${o.path??o.name}${o.scope==="team"?" (team)":""}
33
39
  ${o.snippet}`).join(`
34
- `))}catch(n){return w(G(n))}}}}var Qt=h.object({scope:h.string().max(96).optional()});function Ge(t){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it.",inputSchema:Qt,async handler(e){try{let{nodes:n}=await t.memoryTree(e.scope??"all");return n.length===0?x("(empty)"):x(n.map(o=>{let r=o.path.split("/").length-1,i=o.kind==="folder"?`${o.name}/`:o.name;return`${" ".repeat(r)}${i}${o.scope==="team"?" (team)":""}`}).join(`
35
- `))}catch(n){return w(G(n))}}}}var en=h.object({from:h.string().min(3).max(256),to:h.string().min(3).max(256),updateLinks:h.boolean().optional()});function ze(t){return`${t} ${t===1?"file":"files"}`}function Fe(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:en,async handler(e){if(!y(e.from)||!y(e.to))return w("errors.INVALID_PATH");let n=e.updateLinks??!0;try{let o=await t.moveMemory(e.from,e.to,n);return x(`${o.from} moved to ${o.to}`+(n?`, links updated in ${ze(o.rewritten)}, ${ze(o.skipped)} left unchanged`:""))}catch(o){return w(G(o))}}}}var tn=h.object({path:h.string().min(3).max(256)});function He(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:tn,async handler(e){if(!y(e.path))return w("errors.INVALID_PATH");try{let n=await t.readMemory(e.path),{resolved:o,unresolved:r}=n.links;return o.length===0&&r.length===0?x(`${e.path} does not link to anything.`):x([o.length>0?`Resolved: ${o.join(", ")}`:"",r.length>0?`Open (no file with this name yet): ${r.join(", ")}`:""].filter(i=>i!=="").join(`
36
- `))}catch(n){return w(G(n))}}}}import{z as l}from"zod";var nn=t=>({content:[{type:"text",text:t}]}),We=t=>({content:[{type:"text",text:t}],isError:!0});async function k(t){try{return nn(await t())}catch(e){if(e instanceof a){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return We(`${e.code}${n}`)}return We("errors.UNKNOWN")}}var O=l.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function F(t,e){let{connections:n}=await t.listConnections(),o=n.filter(r=>r.slug===e);return o.find(r=>r.scope==="personal")??o[0]??null}function oe(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})
40
+ `))}catch(n){return w(G(n))}}}}var tn=h.object({scope:h.string().max(96).optional()});function Fe(t){return{name:"memory_tree",description:"This account's folder structure: every folder, empty ones included, and the files in it.",inputSchema:tn,async handler(e){try{let{nodes:n}=await t.memoryTree(e.scope??"all");return n.length===0?S("(empty)"):S(n.map(o=>{let r=o.path.split("/").length-1,i=o.kind==="folder"?`${o.name}/`:o.name;return`${" ".repeat(r)}${i}${o.scope==="team"?" (team)":""}`}).join(`
41
+ `))}catch(n){return w(G(n))}}}}var nn=h.object({from:h.string().min(3).max(256),to:h.string().min(3).max(256),updateLinks:h.boolean().optional()});function je(t){return`${t} ${t===1?"file":"files"}`}function He(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:nn,async handler(e){if(!y(e.from)||!y(e.to))return w("errors.INVALID_PATH");let n=e.updateLinks??!0;try{let o=await t.moveMemory(e.from,e.to,n);return S(`${o.from} moved to ${o.to}`+(n?`, links updated in ${je(o.rewritten)}, ${je(o.skipped)} left unchanged`:""))}catch(o){return w(G(o))}}}}var on=h.object({path:h.string().min(3).max(256)});function We(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:on,async handler(e){if(!y(e.path))return w("errors.INVALID_PATH");try{let n=await t.readMemory(e.path),{resolved:o,unresolved:r}=n.links;return o.length===0&&r.length===0?S(`${e.path} does not link to anything.`):S([o.length>0?`Resolved: ${o.join(", ")}`:"",r.length>0?`Open (no file with this name yet): ${r.join(", ")}`:""].filter(i=>i!=="").join(`
42
+ `))}catch(n){return w(G(n))}}}}import{z as l}from"zod";var rn=t=>({content:[{type:"text",text:t}]}),Be=t=>({content:[{type:"text",text:t}],isError:!0});async function k(t){try{return rn(await t())}catch(e){if(e instanceof a){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return Be(`${e.code}${n}`)}return Be("errors.UNKNOWN")}}var O=l.string().min(1).max(32).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_SLUG");async function F(t,e){let{connections:n}=await t.listConnections(),o=n.filter(r=>r.slug===e);return o.find(r=>r.scope==="personal")??o[0]??null}function re(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})
37
43
  ${t.url}${t.statusError?`
38
- last error: ${t.statusError}`:""}`}var on=l.object({});function Be(t){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:on,handler:()=>k(async()=>{let{connections:e}=await t.listConnections();return e.length===0?"No MCP servers are connected yet. Add one with connection_create.":e.map(oe).join(`
39
- `)})}}var rn=l.object({name:l.string().min(1).max(80),slug:O,url:l.string().url().max(2e3),transport:l.enum(["http","sse"]).default("http"),authType:l.enum(["none","bearer","header"]).default("none"),authHeaderName:l.string().max(80).optional(),secret:l.string().max(4e3).optional(),teamId:l.string().max(64).optional()});function Ve(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:rn,handler:e=>k(async()=>{let{connection:n}=await t.createConnection(e);return`Connected.
40
- ${oe(n)}
44
+ last error: ${t.statusError}`:""}`}var sn=l.object({});function Ve(t){return{name:"list_connections",description:"List the MCP servers connected through this OnlyMCP account, with the tool-name prefix each one uses.",inputSchema:sn,handler:()=>k(async()=>{let{connections:e}=await t.listConnections();return e.length===0?"No MCP servers are connected yet. Add one with connection_create.":e.map(re).join(`
45
+ `)})}}var an=l.object({name:l.string().min(1).max(80),slug:O,url:l.string().url().max(2e3),transport:l.enum(["http","sse"]).default("http"),authType:l.enum(["none","bearer","header"]).default("none"),authHeaderName:l.string().max(80).optional(),secret:l.string().max(4e3).optional(),teamId:l.string().max(64).optional()});function Ke(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:an,handler:e=>k(async()=>{let{connection:n}=await t.createConnection(e);return`Connected.
46
+ ${re(n)}
41
47
 
42
- Its tools are now available as "${n.slug}__<tool>".`})}}var sn=l.object({slug:O,name:l.string().min(1).max(80).optional(),url:l.string().url().max(2e3).optional(),transport:l.enum(["http","sse"]).optional(),authType:l.enum(["none","bearer","header"]).optional(),authHeaderName:l.string().max(80).optional(),secret:l.string().max(4e3).optional(),enabled:l.boolean().optional()});function Ke(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:sn,handler:e=>k(async()=>{let n=await F(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{slug:o,...r}=e,{connection:i}=await t.updateConnection(n.id,r);return`Updated.
43
- ${oe(i)}`})}}var an=l.object({slug:O});function Je(t){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:an,handler:e=>k(async()=>{let n=await F(t,e.slug);return n?(await t.deleteConnection(n.id),`Disconnected ${e.slug}.`):`Connection not found: ${e.slug}`})}}var ln=l.object({slug:O});function qe(t){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:ln,handler:e=>k(async()=>{let n=await F(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:o}=await t.listCapabilities(n.id);return o.length===0?`${e.slug} has nothing on record yet. Its status is "${n.status}".`:o.map(r=>`${r.enabled?"[on] ":"[off]"} ${r.kind} ${r.name}${r.exposedAs?` -> ${r.exposedAs}`:""}${r.description?` \u2014 ${r.description}`:""}`).join(`
44
- `)})}}var cn=l.object({slug:O,tool:l.string().min(1).max(200),enabled:l.boolean()});function Ye(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:cn,handler:e=>k(async()=>{let n=await F(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:o}=await t.listCapabilities(n.id),r=o.find(i=>i.kind==="tool"&&i.name===e.tool);return r?(await t.toggleCapability(n.id,r.id,e.enabled),`${e.slug}__${r.name} is now ${e.enabled?"on":"off"}.`):`${e.slug} offers no tool called ${e.tool}.`})}}import{z as c}from"zod";var dn=t=>({content:[{type:"text",text:t}]}),N=t=>({content:[{type:"text",text:t}],isError:!0});async function v(t){try{return dn(await t())}catch(e){if(e instanceof a){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return N(`${e.code}${n}`)}return N("errors.UNKNOWN")}}var S=c.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),pn=c.object({name:S,body:c.string().max(2e5)});function Xe(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:pn,handler:e=>v(async()=>{let n=await t.putSkill(e.name,e.body);return`${n.name} ${n.updatedAt}`})}}var mn=c.object({name:S});function Ze(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:mn,handler:e=>v(async()=>(await t.deleteSkill(e.name),`Deleted skill ${e.name}`))}}var un=c.object({skill:S});function Qe(t){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:un,handler:e=>v(async()=>{let{files:n}=await t.getSkill(e.skill);return n.length===0?`${e.skill} has no companion files.`:n.map(o=>`${o.path} (${o.size} bytes, ${o.encoding})`).join(`
45
- `)})}}var hn=c.object({skill:S,path:c.string().min(1).max(256),content:c.string().max(3e6),encoding:c.enum(["utf8","base64"]).default("utf8")});function et(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:hn,handler:e=>I(e.path)?v(async()=>{let n=await t.putSkillFile(e.skill,e.path,e.content,e.encoding);return`${e.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(N("errors.INVALID_PATH"))}}var gn=c.object({skill:S,path:c.string().min(1).max(256)});function tt(t){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:gn,handler:e=>I(e.path)?v(async()=>(await t.deleteSkillFile(e.skill,e.path),`Deleted ${e.skill}/${e.path}`)):Promise.resolve(N("errors.INVALID_PATH"))}}var fn=c.object({name:S,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 nt(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:fn,handler:e=>v(async()=>{let n=await t.getAgent(e.name).catch(()=>null),o=await t.putAgent(e.name,{description:e.description,body:e.body,model:e.model??n?.model??void 0,tools:e.tools??n?.tools??[]});return`${o.name} ${o.updatedAt}`})}}var yn=c.object({name:S});function ot(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:yn,handler:e=>v(async()=>(await t.deleteAgent(e.name),`Deleted agent ${e.name}`))}}var bn=c.object({});function rt(t){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:bn,handler:()=>v(async()=>{let{files:e}=await t.listMemory();return e.length===0?"(none)":e.map(n=>n.path+(n.scope==="team"?` (team${n.teamName?`: ${n.teamName}`:""})`:"")).sort().join(`
46
- `)})}}var vn=c.object({path:c.string().min(3).max(256)});function it(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:vn,handler:e=>y(e.path)?v(async()=>(await t.deleteMemory(e.path),`Deleted ${e.path}`)):Promise.resolve(N("errors.INVALID_PATH"))}}function st(t,e){return[Re(t),De(t),rt(t),it(t),je(t),Ge(t),Fe(t),He(t),Me(t),Le(t,e),Xe(t),Ze(t),Qe(t),Oe(t),et(t),tt(t),Pe(t),_e(t,e),nt(t),ot(t),Be(t),Ve(t),Ke(t),Je(t),qe(t),Ye(t)]}function at(t){return t.map(e=>{let n=ee[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:Cn.toJSONSchema(e.inputSchema),annotations:n.annotations}})}async function lt(){let t=ve(),e=new P(t,()=>Ce.read()),n=new R,o=st(e,n),r=await(async()=>{try{let[{skills:d},{agents:u},g]=await Promise.all([e.listSkills(),e.listAgents(),e.getMe().catch(()=>({brainvaultMode:!0}))]);return K(d.map(f=>f.name),u.map(f=>f.name),{brainvault:g.brainvaultMode!==!1})}catch{return K([],[])}})(),i=new xn(J(t,M),{capabilities:{tools:{}},instructions:r});i.setRequestHandler(kn,async()=>({tools:at(o)})),i.setRequestHandler(wn,async d=>{let u=o.find(f=>f.name===d.params.name);if(!u)return{content:[{type:"text",text:"errors.UNKNOWN_TOOL"}],isError:!0};let g=u.inputSchema.safeParse(d.params.arguments??{});return g.success?u.handler(g.data):{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0}}),ke().then(d=>{for(let u of de())$e(e,u,{ignore:d}).catch(()=>{})}).catch(()=>{}),await i.connect(new Sn)}await lt();
48
+ Its tools are now available as "${n.slug}__<tool>".`})}}var ln=l.object({slug:O,name:l.string().min(1).max(80).optional(),url:l.string().url().max(2e3).optional(),transport:l.enum(["http","sse"]).optional(),authType:l.enum(["none","bearer","header"]).optional(),authHeaderName:l.string().max(80).optional(),secret:l.string().max(4e3).optional(),enabled:l.boolean().optional()});function Je(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:ln,handler:e=>k(async()=>{let n=await F(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{slug:o,...r}=e,{connection:i}=await t.updateConnection(n.id,r);return`Updated.
49
+ ${re(i)}`})}}var cn=l.object({slug:O});function Ye(t){return{name:"connection_delete",description:"Disconnect a remote MCP server and forget its stored credential. Its tools disappear from the gateway.",inputSchema:cn,handler:e=>k(async()=>{let n=await F(t,e.slug);return n?(await t.deleteConnection(n.id),`Disconnected ${e.slug}.`):`Connection not found: ${e.slug}`})}}var dn=l.object({slug:O});function qe(t){return{name:"connection_tools",description:"List what one connected server offers, and whether each tool is switched on for the gateway.",inputSchema:dn,handler:e=>k(async()=>{let n=await F(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:o}=await t.listCapabilities(n.id);return o.length===0?`${e.slug} has nothing on record yet. Its status is "${n.status}".`:o.map(r=>`${r.enabled?"[on] ":"[off]"} ${r.kind} ${r.name}${r.exposedAs?` -> ${r.exposedAs}`:""}${r.description?` \u2014 ${r.description}`:""}`).join(`
50
+ `)})}}var pn=l.object({slug:O,tool:l.string().min(1).max(200),enabled:l.boolean()});function Xe(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:pn,handler:e=>k(async()=>{let n=await F(t,e.slug);if(!n)return`Connection not found: ${e.slug}`;let{capabilities:o}=await t.listCapabilities(n.id),r=o.find(i=>i.kind==="tool"&&i.name===e.tool);return r?(await t.toggleCapability(n.id,r.id,e.enabled),`${e.slug}__${r.name} is now ${e.enabled?"on":"off"}.`):`${e.slug} offers no tool called ${e.tool}.`})}}import{z as d}from"zod";var mn=t=>({content:[{type:"text",text:t}]}),N=t=>({content:[{type:"text",text:t}],isError:!0});async function v(t){try{return mn(await t())}catch(e){if(e instanceof a){let n=Object.keys(e.params).length?` ${JSON.stringify(e.params)}`:"";return N(`${e.code}${n}`)}return N("errors.UNKNOWN")}}var x=d.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"errors.INVALID_NAME"),un=d.object({name:x,body:d.string().max(2e5)});function Ze(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:un,handler:e=>v(async()=>{let n=await t.putSkill(e.name,e.body);return`${n.name} ${n.updatedAt}`})}}var hn=d.object({name:x});function Qe(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:hn,handler:e=>v(async()=>(await t.deleteSkill(e.name),`Deleted skill ${e.name}`))}}var gn=d.object({skill:x});function et(t){return{name:"list_skill_files",description:"List the companion files of one skill, with their size in bytes.",inputSchema:gn,handler:e=>v(async()=>{let{files:n}=await t.getSkill(e.skill);return n.length===0?`${e.skill} has no companion files.`:n.map(o=>`${o.path} (${o.size} bytes, ${o.encoding})`).join(`
51
+ `)})}}var fn=d.object({skill:x,path:d.string().min(1).max(256),content:d.string().max(3e6),encoding:d.enum(["utf8","base64"]).default("utf8")});function tt(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:fn,handler:e=>I(e.path)?v(async()=>{let n=await t.putSkillFile(e.skill,e.path,e.content,e.encoding);return`${e.skill}/${n.path} ${n.size} bytes`}):Promise.resolve(N("errors.INVALID_PATH"))}}var yn=d.object({skill:x,path:d.string().min(1).max(256)});function nt(t){return{name:"skill_file_delete",description:"Delete one companion file of a skill. The skill itself stays.",inputSchema:yn,handler:e=>I(e.path)?v(async()=>(await t.deleteSkillFile(e.skill,e.path),`Deleted ${e.skill}/${e.path}`)):Promise.resolve(N("errors.INVALID_PATH"))}}var bn=d.object({name:x,description:d.string().min(1).max(1e3),body:d.string().max(2e5),model:d.string().max(64).optional(),tools:d.array(d.string().max(128)).max(200).optional()});function ot(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:bn,handler:e=>v(async()=>{let n=await t.getAgent(e.name).catch(()=>null),o=await t.putAgent(e.name,{description:e.description,body:e.body,model:e.model??n?.model??void 0,tools:e.tools??n?.tools??[]});return`${o.name} ${o.updatedAt}`})}}var vn=d.object({name:x});function rt(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:vn,handler:e=>v(async()=>(await t.deleteAgent(e.name),`Deleted agent ${e.name}`))}}var Cn=d.object({});function it(t){return{name:"list_memory",description:"List the paths of every memory file in this account, private and team, sorted by path.",inputSchema:Cn,handler:()=>v(async()=>{let{files:e}=await t.listMemory();return e.length===0?"(none)":e.map(n=>n.path+(n.scope==="team"?` (team${n.teamName?`: ${n.teamName}`:""})`:"")).sort().join(`
52
+ `)})}}var Sn=d.object({path:d.string().min(3).max(256)});function st(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:Sn,handler:e=>y(e.path)?v(async()=>(await t.deleteMemory(e.path),`Deleted ${e.path}`)):Promise.resolve(N("errors.INVALID_PATH"))}}function at(t,e){return[De(t),ze(t),it(t),st(t),Ge(t),Fe(t),He(t),We(t),Pe(t),Ee(t,e),Ze(t),Qe(t),et(t),Ne(t),tt(t),nt(t),Ue(t),Oe(t,e),ot(t),rt(t),Ve(t),Ke(t),Je(t),Ye(t),qe(t),Xe(t)]}function lt(t){return t.map(e=>{let n=ee[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:xn.toJSONSchema(e.inputSchema),annotations:n.annotations}})}async function ct(){let t=Ce(),e=new P(t,()=>Se.read()),n=new R,o=at(e,n),r=await(async()=>{try{let[{skills:c},{agents:u},g]=await Promise.all([e.listSkills(),e.listAgents(),e.getMe().catch(()=>({brainvaultMode:!0}))]);return K(c.map(f=>f.name),u.map(f=>f.name),{brainvault:g.brainvaultMode!==!1})}catch{return K([],[])}})(),i=new wn(J(t,M),{capabilities:{tools:{}},instructions:r});i.setRequestHandler(Tn,async()=>({tools:lt(o)})),i.setRequestHandler(An,async c=>{let u=o.find(f=>f.name===c.params.name);if(!u)return{content:[{type:"text",text:"errors.UNKNOWN_TOOL"}],isError:!0};let g=u.inputSchema.safeParse(c.params.arguments??{});return g.success?u.handler(g.data):{content:[{type:"text",text:"errors.INVALID_ARGUMENTS"}],isError:!0}}),Ae().then(c=>{for(let u of pe())Ie(e,u,{ignore:c}).catch(()=>{})}).catch(()=>{}),await i.connect(new kn)}await ct();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onlymcp",
3
- "version": "0.20.0",
3
+ "version": "0.21.2",
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",
@@ -43,7 +43,7 @@
43
43
  "fflate": "^0.8.3",
44
44
  "open": "^11.0.1",
45
45
  "qrcode": "^1.5.4",
46
- "zod": "^4.4.3"
46
+ "zod": "^4.6.6"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/cacache": "^17.0.2",
@@ -51,6 +51,6 @@
51
51
  "@types/qrcode": "^1.5.5",
52
52
  "esbuild": "^0.28.2",
53
53
  "typescript": "^5.9.0",
54
- "vitest": "^4.1.10"
54
+ "vitest": "^4.1.12"
55
55
  }
56
56
  }