{"record":{"id":"50e8e1e531d10ab7","repo":"multica-ai/multica","slug":"add-agent-mcp-server-w","errorCode":null,"errorMessage":"add agent mcp server: %w","messagePattern":"add agent mcp server: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent_mcp.go","lineNumber":122,"sourceCode":"\tif err := client.GetJSON(ctx, agentMcpPath(agentID), &servers); err != nil {\n\t\treturn fmt.Errorf(\"list agent mcp servers: %w\", err)\n\t}\n\treturn printWorkspaceMcpServers(cmd, servers)\n}\n\nfunc runAgentMcpAdd(cmd *cobra.Command, args []string) error {\n\tagentID, serverID := strings.TrimSpace(args[0]), strings.TrimSpace(args[1])\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar servers []workspaceMcpServer\n\tbody := map[string]any{\"server_id\": serverID}\n\tif err := client.PostJSON(ctx, agentMcpPath(agentID), body, &servers); err != nil {\n\t\treturn fmt.Errorf(\"add agent mcp server: %w\", err)\n\t}\n\treturn printWorkspaceMcpServers(cmd, servers)\n}\n\nfunc runAgentMcpEnable(cmd *cobra.Command, args []string) error {\n\treturn setAgentMcpEnabled(cmd, args, true)\n}\n\nfunc runAgentMcpDisable(cmd *cobra.Command, args []string) error {\n\treturn setAgentMcpEnabled(cmd, args, false)\n}\n\nfunc setAgentMcpEnabled(cmd *cobra.Command, args []string, enabled bool) error {\n\tagentID, serverID := strings.TrimSpace(args[0]), strings.TrimSpace(args[1])\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent_mcp.go#L104-L140","documentation":"Thrown by `multica agent mcp add <agentID> <serverID>` when POST /api/agents/{id}/mcp-servers with body {server_id} fails. Common wrapped causes: the server_id is not a known workspace MCP server, the agent ID is unknown, the server is already attached, or auth/connectivity failures.","triggerScenarios":"`multica agent mcp add <agent> <server>` where serverID does not match any workspace MCP server (typo or different workspace); adding to a deleted agent; duplicate attachment rejected by the API.","commonSituations":"Server IDs copied from another workspace; MCP server deleted after listing; agents and MCP servers managed in different environments.","solutions":["List available workspace MCP servers and re-run with an exact ID","Confirm the agent still exists: multica agent list","Check the wrapped error for duplicate-attachment rejections — the server may already be attached"],"exampleFix":"# before\nmultica agent mcp add <agent-id> srv_typo\n# after\nmultica mcp list   # or the workspace servers command\nmultica agent mcp add <agent-id> <exact-server-id>","handlingStrategy":"validation","validationCode":"# verify both IDs exist before attaching\nmultica agent get \"$AGENT_ID\" >/dev/null || exit 1\nmultica mcp list --output json | jq -e --arg s \"$SERVER_ID\" 'map(.id) | index($s)' >/dev/null || { echo \"unknown server\" >&2; exit 1; }\nmultica agent mcp add \"$AGENT_ID\" \"$SERVER_ID\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy server IDs from a live listing, never from another workspace's output","Check current attachments before adding to avoid duplicate rejections","Keep agent and MCP server provisioning in the same environment/script"],"tags":["cli","api","http","mcp","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}