{"record":{"id":"fe8f1a8fbbb872aa","repo":"charmbracelet/crush","slug":"failed-to-list-mcp-prompts-w","errorCode":null,"errorMessage":"failed to list MCP prompts: %w","messagePattern":"failed to list MCP prompts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/config.go","lineNumber":327,"sourceCode":"\t}{Name: name, URI: uri}), http.Header{\"Content-Type\": []string{\"application/json\"}})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read MCP resource: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"failed to read MCP resource: status code %d\", rsp.StatusCode)\n\t}\n\tvar contents []MCPResourceContents\n\tif err := json.NewDecoder(rsp.Body).Decode(&contents); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode MCP resource: %w\", err)\n\t}\n\treturn contents, nil\n}\n\nfunc (c *Client) ListMCPPrompts(ctx context.Context, id string) ([]proto.MCPPrompt, error) {\n\trsp, err := c.get(ctx, fmt.Sprintf(\"/workspaces/%s/mcp/prompts\", id), nil, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list MCP prompts: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"failed to list MCP prompts: status code %d\", rsp.StatusCode)\n\t}\n\tvar prompts []proto.MCPPrompt\n\tif err := json.NewDecoder(rsp.Body).Decode(&prompts); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode MCP prompts: %w\", err)\n\t}\n\treturn prompts, nil\n}\n\n// GetMCPPrompt retrieves a prompt from a named MCP server.\nfunc (c *Client) GetMCPPrompt(ctx context.Context, id, clientID, promptID string, args map[string]string) (string, error) {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/mcp/get-prompt\", id), nil, jsonBody(struct {\n\t\tClientID string            `json:\"client_id\"`\n\t\tPromptID string            `json:\"prompt_id\"`\n\t\tArgs     map[string]string `json:\"args\"`","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/config.go#L309-L345","documentation":"ListMCPPrompts GETs /workspaces/{id}/mcp/prompts to enumerate prompts across configured MCP servers. This error wraps any transport failure from c.get before the status code is examined — the HTTP request itself failed.","triggerScenarios":"c.get errors: connection refused, DNS failure, TLS problems, invalid workspace ID producing a bad URL, or a cancelled/expired context.","commonSituations":"Coder server unreachable; misconfigured client URL; offline environment; test servers (see TestListMCPPrompts*) simulating network failures.","solutions":["Verify the Coder server is reachable and the base URL is correct.","Validate the workspace ID before the call.","Inspect the wrapped error for the network root cause.","Retry with a fresh, adequately long context."],"exampleFix":"// before\nprompts, err := client.ListMCPPrompts(ctx, id)\n// after\nprompts, err := client.ListMCPPrompts(ctx, id)\nif err != nil {\n    if strings.Contains(err.Error(), \"connection refused\") {\n        return nil, fmt.Errorf(\"coder server unreachable — is it running?\")\n    }\n    return nil, err\n}","handlingStrategy":"retry","validationCode":"if workspaceID == \"\" {\n    return errors.New(\"workspace ID is required to list MCP prompts\")\n}\n// optionally confirm server reachability first\nif err := pingServer(ctx); err != nil {\n    return fmt.Errorf(\"server unreachable, skipping prompt list: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"ctx, cancel := context.WithTimeout(ctx, 15*time.Second)\ndefer cancel()\nprompts, err := client.ListMCPPrompts(ctx, id)\nif err != nil && isTransientNetworkError(err) {\n    prompts, err = retryWithBackoff(3, func() ([]proto.MCPPrompt, error) {\n        return client.ListMCPPrompts(ctx, id)\n    })\n}","preventionTips":["Use short bounded contexts for list calls and retry on transient errors.","Confirm server reachability before bulk listing operations.","Keep the workspace ID validated from a prior successful call.","Log the wrapped cause to separate network issues from API issues."],"tags":["network","http-client","mcp"],"backgroundTag":"http-request-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}