onlymcp 0.21.0 → 0.22.0

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