The VS Code plugin talks to AgentStack backend via MCP (Model Context Protocol): POST /mcp with { steps: [{ action, params }] } (agentstack.execute).
- API key: from settings
agentstack-mcp.apiKeyor SecretStorage (agentstack.apiKey). Used in headerX-API-Keyfor all MCP requests. - Base URL:
- baseUrl:
agentstack-mcp.baseUrl(defaulthttps://agentstack.tech/mcp).
- baseUrl:
- getMcpOptions(): returns
{ baseUrl, apiKey, timeoutMs }ornullif no API key. Used by tree, commands, and chat.
- mcpClient.ts
callMcpTool(opts, toolName, args): single tool call.- POST
baseUrl/with body{ steps: [{ id: "s1", action: toolName, params: args }], options: { stopOnError: true } }. - Response:
steps[0].resultorsteps[0].error; compat path parsesresult.content[0].textas JSON{ data, error }.
- Wrappers:
fetchProjects,fetchProject,fetchProjectStats,fetchProjectUsers,updateProject,fetchAssetsList,listActiveBuffs,getBalance,getProfile,logicList,listTransactions,listSchedulerTasks,createSchedulerTask,executeSchedulerTask, etc. All usecallMcpToolwith the appropriate tool name (e.g.projects.get_projects,scheduler.list_tasks).
- MCP routes (
mcp/routes.py):- v1:
POST /mcp/toolsaccepts JSON-RPC body; ifmethod === "tools/call"→_execute_tool_internal(body, http_request). Tool name fromparams.name, resolved via_resolve_tool_name, thenMCP_TOOLS_REGISTRY[tool_name]+extract_context_from_request(http_request)for auth context. - Backend:
POST /mcp→ execute. Each step hasaction(tool name) andparams.POST /mcp/toolsaccepts JSON-RPCtools/callfor compatibility.
- v1:
- Auth context: from
extract_context_from_request(request)(API key, JWT, session). Includesuser_id,project_id,permissions_bitmap. Scheduler endpoints usepermissions_bitmapfor read/write/execute/delete. - Tool registry:
MCP_TOOLS_REGISTRYinmcp/tools.py; populated by imports inmcp/__init__.py(tools_projects, tools_remaining, tools_buffs, tools_logic, tools_assets, tools_commands, tools_auth, tools_processors). Scheduler tools:scheduler.list_tasks,scheduler.create_task,scheduler.execute_task(intools_remaining.py) call scheduler HTTP endpoints internally.
- Plugin: user expands "Scheduler" in tree →
ecosystemTreecallslistSchedulerTasks(opts, projectId). - mcpClient:
callMcpTool(opts, "scheduler.list_tasks", { project_id })→ POST to backend. - Backend: MCP route →
_execute_tool_internal→MCP_TOOLS_REGISTRY["scheduler.list_tasks"](params, context)→ tool implementation calls scheduler HTTP API withcurrent_user(permissions checked in scheduler_endpoints by bitmap). - Response flows back: MCP → plugin; tree shows task nodes or error (e.g. 403 → "Insufficient permissions...").
- 401: "Unauthorized. Set or check your API key (AgentStack: Set API Key)."
- 403: "Forbidden. Check project access or subscription…" or scheduler-specific "Insufficient permissions for scheduler in this project."
- 404: "Not found (404). If using MCP v2, ensure the backend is updated…"
- Timeout / network: message from
fetchWithTimeout(e.g. "Request timed out.").
All tool errors return { error: string }; UI shows them via vscode.window.showErrorMessage or inline in the tree.