{"record":{"id":"8db361c32e04dcbd","repo":"sipeed/picoclaw","slug":"mcp-server-s-is-configured-but-not-connected","errorCode":null,"errorMessage":"MCP server '%s' is configured but not connected","messagePattern":"MCP server '(.+?)' is configured but not connected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/agent/agent_command.go","lineNumber":220,"sourceCode":"\t\t\t}\n\t\t\tif !serverCfg.Enabled {\n\t\t\t\treturn nil, fmt.Errorf(\"MCP server '%s' is configured but disabled\", resolvedName)\n\t\t\t}\n\t\t\tif !cfg.Tools.IsToolEnabled(\"mcp\") {\n\t\t\t\treturn nil, fmt.Errorf(\"MCP integration is disabled\")\n\t\t\t}\n\n\t\t\tif err := al.ensureMCPInitialized(ctx); err != nil {\n\t\t\t\tlogger.WarnCF(\"agent\", \"Failed to initialize MCP runtime for command\",\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"server\": resolvedName,\n\t\t\t\t\t\t\"error\":  err.Error(),\n\t\t\t\t\t})\n\t\t\t}\n\n\t\t\tmanager := al.mcp.getManager()\n\t\t\tif manager == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"MCP server '%s' is configured but not connected\", resolvedName)\n\t\t\t}\n\n\t\t\tconn, ok := manager.GetServer(resolvedName)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"MCP server '%s' is configured but not connected\", resolvedName)\n\t\t\t}\n\n\t\t\ttoolInfos := make([]commands.MCPToolInfo, 0, len(conn.Tools))\n\t\t\tfor _, tool := range conn.Tools {\n\t\t\t\tif tool == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tname := strings.TrimSpace(tool.Name)\n\t\t\t\tif name == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tdescription := strings.TrimSpace(tool.Description)","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/agent/agent_command.go#L202-L238","documentation":"After validation passes, ListMCPTools calls ensureMCPInitialized and then fetches the MCP manager; al.mcp.getManager() returned nil, meaning the MCP runtime never came up. Initialization failures are only logged (WarnCF), not returned, so this error surfaces one step later as 'configured but not connected' — the manager itself is absent.","triggerScenarios":"MCP init failed (no reachable servers, bad global MCP settings, runtime construction error) so the manager was never created; MCP initialized lazily and the first init attempt raced or crashed; discovery disabled with nothing started.","commonSituations":"All configured servers unreachable at startup in offline environments; bug or panic during MCP runtime construction; deferred discovery never triggered a first connect; process in a degraded state after config hot-reload.","solutions":["Check logs for the preceding 'Failed to initialize MCP runtime for command' warning — it carries the root-cause error field","Fix the underlying init failure (server URLs, auth, network) and retry the command, which re-runs ensureMCPInitialized","Restart the agent process if the manager was lost after a hot reload","Verify at least one enabled server is reachable from the host"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if al.mcp.getManager() == nil {\n    // call ensureMCPInitialized once more / surface the logged root cause before retrying\n}","typeGuard":"func mcpRuntimeReady(al *AgentLoop) bool { return al.mcp.getManager() != nil }","tryCatchPattern":"tools, err := rt.ListMCPTools(ctx, name)\nif err != nil && strings.Contains(err.Error(), \"not connected\") && al.mcp.getManager() == nil {\n    // manager missing: fix init root cause (see logs), then retry after re-init\n}","preventionTips":["Watch for the 'Failed to initialize MCP runtime' warning — it holds the root cause","Ensure at least one reachable, enabled MCP server before relying on MCP commands","Restart the process after MCP config repairs"],"tags":["mcp","runtime","initialization","connectivity"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}