{"record":{"id":"42167ff547f63ec7","repo":"multica-ai/multica","slug":"add-workspace-mcp-server-w","errorCode":null,"errorMessage":"add workspace mcp server: %w","messagePattern":"add workspace mcp server: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_workspace.go","lineNumber":662,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\tif !ok {\n\t\treturn fmt.Errorf(\"one of --server-config, --server-config-stdin, or --server-config-file is required\")\n\t}\n\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar server workspaceMcpServer\n\tbody := map[string]any{\"name\": serverName, \"config\": entry}\n\tif err := client.PostJSON(ctx, \"/api/workspaces/\"+wsID+\"/mcp-servers\", body, &server); err != nil {\n\t\treturn fmt.Errorf(\"add workspace mcp server: %w\", err)\n\t}\n\n\treturn printWorkspaceMcpServers(cmd, []workspaceMcpServer{server})\n}\n\nfunc runWorkspaceMcpUpdate(cmd *cobra.Command, args []string) error {\n\tserverID := strings.TrimSpace(args[0])\n\tif serverID == \"\" {\n\t\treturn fmt.Errorf(\"server ID must not be empty\")\n\t}\n\twsID, err := resolveWorkspaceArg(cmd, args[1:])\n\tif err != nil {\n\t\treturn err\n\t}\n\tif wsID == \"\" {\n\t\treturn fmt.Errorf(\"workspace ID is required: pass an id/slug/prefix as argument or set MULTICA_WORKSPACE_ID\")\n\t}\n","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_workspace.go#L644-L680","documentation":"Wrapped failure of the HTTP POST to /api/workspaces/{id}/mcp-servers performed by `multica workspace mcp add`. The chained cause is typically a 400 for malformed/invalid config JSON, 409 for a duplicate server name, 404 for an unknown workspace, or auth/network errors.","triggerScenarios":"Registering a server whose config JSON fails server-side schema validation; re-adding a server name that already exists on the workspace; posting to a workspace the token cannot write; server unreachable.","commonSituations":"Config object missing required keys for its transport type (e.g. no `command` for stdio, no `url` for sse/streamable); duplicate registration attempts in setup scripts; secrets inline in config that the server rejects; wrong workspace slug.","solutions":["Read the wrapped error's HTTP status and body — 400 names the offending config field","For 409, either `mcp update` the existing entry or remove it first with `multica workspace mcp remove`","Validate the JSON locally (jq . server.json) before passing it","Confirm the workspace id and token permissions with `multica workspace mcp list <ws>`"],"exampleFix":"# before\nmultica workspace mcp add files acme --server-config '{\"transport\":\"stdio\"}'\n# add workspace mcp server: 400 command is required\n\n# after\nmultica workspace mcp add files acme --server-config '{\"transport\":\"stdio\",\"command\":\"npx\",\"args\":[\"-y\",\"@modelcontextprotocol/server-filesystem\",\"/data\"]}'","handlingStrategy":"try-catch","validationCode":"if !json.Valid(rawConfig) {\n    return errors.New(\"server config is not valid JSON\")\n}\nvar probe map[string]any\nif err := json.Unmarshal(rawConfig, &probe); err != nil || len(probe) == 0 {\n    return errors.New(\"server config must be a non-empty JSON object\")\n}","typeGuard":"func isValidServerConfig(v any) bool {\n    m, ok := v.(map[string]any)\n    if !ok {\n        return false\n    }\n    switch m[\"transport\"] {\n    case \"stdio\":\n        _, hasCmd := m[\"command\"]\n        return hasCmd\n    case \"sse\", \"streamable\":\n        _, hasURL := m[\"url\"]\n        return hasURL\n    }\n    return false\n}","tryCatchPattern":"if err := client.PostJSON(ctx, path, body, &server); err != nil {\n    var httpErr *apiclient.HTTPError\n    if errors.As(err, &httpErr) && httpErr.StatusCode == 409 {\n        // server name exists: route the caller to update instead\n        return fmt.Errorf(\"already registered; use `multica workspace mcp update`: %w\", err)\n    }\n    return fmt.Errorf(\"add workspace mcp server: %w\", err)\n}","preventionTips":["Include transport-required keys (command for stdio, url for http/sse) in every config","List existing servers before adding to avoid duplicate-name 409s","Never put live secrets in inline JSON that lands in shell history"],"tags":["cli","http","mcp","json","api-client"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}