import{a}from"./chunk-3THT3N7L.js";import"./chunk-DXB73IDG.js";var u={name:"ag-mcp",execute:async(s,c)=>{if(!c.bash)return{stdout:"",stderr:`ag-mcp: no bash host available
`,exitCode:1};let r=c.bash.services.mcpClient,i=s[0];if(!i)return{stdout:"",stderr:`Usage: ag-mcp <connect|list|call|disconnect> [args]
`,exitCode:1};switch(i){case"list":{let t=r.listConnections();if(t.length===0)return{stdout:`No active MCP connections.
`,stderr:"",exitCode:0};let e=`Active MCP Connections:
`;for(let n of t){e+=`- ${n.id} [${n.type}] status: ${n.status}
`;for(let o of n.tools)e+=`    - ${o.name}: ${o.description||"(no description)"}
`}return{stdout:e,stderr:"",exitCode:0}}case"connect":{let t=s[1],e=s[2],n=s[3];if(!t||!e||!n)return{stdout:"",stderr:`Usage: ag-mcp connect <stdio|http> <id> <command|url> [args...]
`,exitCode:1};try{if(t==="stdio"){let o=s.slice(4),d=await r.connectStdio(e,n,o,c);c.bash?.toolbox.registerMcpTools(e,d.tools)}else if(t==="http"){let o=await r.connectHttp(e,n,c.bash);c.bash?.toolbox.registerMcpTools(e,o.tools)}else return{stdout:"",stderr:`Unknown connection type: ${t}
`,exitCode:1};return{stdout:`Successfully connected to MCP server: ${e}
`,stderr:"",exitCode:0}}catch(o){return{stdout:"",stderr:`Connection failed: ${a(o.message)}
`,exitCode:1}}}case"call":{let t=s[1],e=s[2],n=s[3]||"{}";if(!t||!e)return{stdout:"",stderr:`Usage: ag-mcp call <id> <tool_name> [args_json]
`,exitCode:1};try{let o=JSON.parse(n),d=await r.callTool(t,e,o,c.bash);return{stdout:`${JSON.stringify(d,null,2)}
`,stderr:"",exitCode:0}}catch(o){return{stdout:"",stderr:`Tool call failed: ${a(o.message)}
`,exitCode:1}}}case"disconnect":{let t=s[1];return t?(r.disconnect(t),{stdout:`Disconnected from ${t}
`,stderr:"",exitCode:0}):{stdout:"",stderr:`Usage: ag-mcp disconnect <id>
`,exitCode:1}}default:return{stdout:"",stderr:`Unknown subcommand: ${i}
`,exitCode:1}}}};export{u as agMcp};
