{"record":{"id":"4102ccf1c91130b2","repo":"sipeed/picoclaw","slug":"server-q-did-not-register-a-connection","errorCode":null,"errorMessage":"server %q did not register a connection","messagePattern":"server %q did not register a connection","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/mcp/helpers.go","lineNumber":353,"sourceCode":") (probeResult, error) {\n\tmgr := picomcp.NewManager()\n\tdefer func() { _ = mgr.Close() }()\n\n\tserver.Enabled = true\n\tmcpCfg := config.MCPConfig{\n\t\tToolConfig: config.ToolConfig{Enabled: true},\n\t\tServers: map[string]config.MCPServerConfig{\n\t\t\tname: server,\n\t\t},\n\t}\n\n\tif err := mgr.LoadFromMCPConfig(ctx, mcpCfg, workspacePath); err != nil {\n\t\treturn probeResult{}, err\n\t}\n\n\tconn, ok := mgr.GetServer(name)\n\tif !ok {\n\t\treturn probeResult{}, fmt.Errorf(\"server %q did not register a connection\", name)\n\t}\n\n\treturn probeResult{ToolCount: len(conn.Tools)}, nil\n}\n\nfunc confirmOverwrite(r io.Reader, w io.Writer, name string) (bool, error) {\n\tif _, err := fmt.Fprintf(w, \"MCP server %q already exists. Overwrite? [y/N]: \", name); err != nil {\n\t\treturn false, err\n\t}\n\n\tvar answer string\n\tif _, err := fmt.Fscanln(r, &answer); err != nil {\n\t\tif errors.Is(err, io.EOF) {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, err\n\t}\n","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/mcp/helpers.go#L335-L371","documentation":"An internal invariant in picoclaw's default server probe (used by picoclaw mcp test). The probe builds a one-server Manager config, forces server.Enabled = true, and calls LoadFromMCPConfig; that call reported success, yet Manager.GetServer(name) found no registered connection. Because the manager returns an aggregated error when the only enabled server fails to connect (pkg/mcp/manager.go:262), a plain connect failure surfaces as a different wrapped error — reaching this branch means a connection was not stored despite a successful load: an internal inconsistency, a race (manager closing mid-load), or version skew between the CLI and pkg/mcp.","triggerScenarios":"ConnectServer succeeding but the connection not being stored under the exact probe name (concurrent Close during load, registration-key mismatch); mixing picoclaw versions so manager registration semantics differ from the CLI helper's expectations.","commonSituations":"Rare. Seen when the probe's manager is torn down concurrently, after partial upgrades that leave cmd/picoclaw and pkg/mcp from different releases, or after a manager refactor that changes how servers are registered.","solutions":["Re-run picoclaw mcp test <name> once to rule out a transient race","Run picoclaw mcp show <name> to cross-check registration and check manager logs for connect/registration lines","Reinstall or upgrade picoclaw so the CLI helpers and pkg/mcp manager come from the same build","If reproducible with a minimal config, file a picoclaw bug including the server entry and logs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isNotRegisteredError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"did not register a connection\")\n}","tryCatchPattern":"result, err := serverProbe(ctx, name, server, workspace)\nif err != nil {\n  if isNotRegisteredError(err) {\n    // transient/internal: retry once with a fresh context before surfacing\n    result, err = serverProbe(ctx, name, server, workspace)\n  }\n  if err != nil {\n    return fmt.Errorf(\"probe %s: %w\", name, err)\n  }\n}","preventionTips":["Keep picoclaw in one piece: upgrade the whole binary rather than mixing versions","Do not run probes while the enclosing app is shutting down","Treat this message as a bug indicator, not a config problem — capture logs when it appears"],"tags":["mcp","internal","race","registration"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}