{"record":{"id":"59bcf92c187207c2","repo":"charmbracelet/crush","slug":"failed-to-get-mcp-prompt-w","errorCode":null,"errorMessage":"failed to get MCP prompt: %w","messagePattern":"failed to get MCP prompt: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/config.go","lineNumber":348,"sourceCode":"\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\"`\n\t}{ClientID: clientID, PromptID: promptID, Args: args}), http.Header{\"Content-Type\": []string{\"application/json\"}})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get MCP prompt: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"failed to get MCP prompt: status code %d\", rsp.StatusCode)\n\t}\n\tvar result struct {\n\t\tPrompt string `json:\"prompt\"`\n\t}\n\tif err := json.NewDecoder(rsp.Body).Decode(&result); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to decode MCP prompt response: %w\", err)\n\t}\n\treturn result.Prompt, nil\n}\n","sourceCodeStart":330,"sourceCodeEnd":362,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/config.go#L330-L362","documentation":"GetMCPPrompt POSTs to /workspaces/{id}/mcp/get-prompt to render a prompt from a named MCP server with arguments. This error wraps transport failures from c.post — the request never got a response, so no status was checked.","triggerScenarios":"c.post errors: unreachable host, DNS/TLS failure, malformed workspace ID in the URL, cancelled context, or timeout while the MCP server rendered the prompt.","commonSituations":"Coder daemon down; network/VPN issues; oversized args payload failing to serialize; context cancelled by an upstream deadline.","solutions":["Check connectivity to the Coder server.","Validate workspace ID, clientID, and promptID before calling.","Inspect the wrapped error for the root cause.","Retry with a longer context timeout for slow prompt rendering."],"exampleFix":"// before\nprompt, err := client.GetMCPPrompt(ctx, id, clientID, promptID, args)\n// after\nprompt, err := client.GetMCPPrompt(ctx, id, clientID, promptID, args)\nif err != nil {\n    return \"\", fmt.Errorf(\"get prompt %s (server %s): %w\", promptID, clientID, err)\n}","handlingStrategy":"retry","validationCode":"func validateGetPromptInput(workspaceID, clientID, promptID string, args map[string]string) error {\n    if workspaceID == \"\" || clientID == \"\" || promptID == \"\" {\n        return errors.New(\"workspace ID, client ID, and prompt ID are required\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"ctx, cancel := context.WithTimeout(ctx, 30*time.Second)\ndefer cancel()\nprompt, err := client.GetMCPPrompt(ctx, id, clientID, promptID, args)\nif err != nil && isTransientNetworkError(err) {\n    prompt, err = client.GetMCPPrompt(ctx, id, clientID, promptID, args)\n}\nif err != nil {\n    return \"\", fmt.Errorf(\"get prompt %q: %w\", promptID, err)\n}","preventionTips":["Validate all IDs before the call to avoid wasted requests.","Use a generous timeout — prompt rendering can be slow.","Retry transient transport errors with backoff.","Confirm the MCP server is connected before rendering prompts."],"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"}