{"record":{"id":"e2b3f3edf56e43de","repo":"charmbracelet/crush","slug":"failed-to-enable-docker-mcp-status-code-d","errorCode":null,"errorMessage":"failed to enable docker MCP: status code %d","messagePattern":"failed to enable docker MCP: status code (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/config.go","lineNumber":271,"sourceCode":"}\n\n// MCPResourceContents holds the contents of an MCP resource.\ntype MCPResourceContents struct {\n\tURI      string `json:\"uri\"`\n\tMIMEType string `json:\"mime_type,omitempty\"`\n\tText     string `json:\"text,omitempty\"`\n\tBlob     []byte `json:\"blob,omitempty\"`\n}\n\n// EnableDockerMCP enables the Docker MCP server on the workspace.\nfunc (c *Client) EnableDockerMCP(ctx context.Context, id string) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/mcp/docker/enable\", id), nil, nil, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to enable docker MCP: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"failed to enable docker MCP: status code %d\", rsp.StatusCode)\n\t}\n\treturn nil\n}\n\n// DisableDockerMCP disables the Docker MCP server on the workspace.\nfunc (c *Client) DisableDockerMCP(ctx context.Context, id string) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/mcp/docker/disable\", id), nil, nil, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to disable docker MCP: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"failed to disable docker MCP: status code %d\", rsp.StatusCode)\n\t}\n\treturn nil\n}\n\n// RefreshMCPTools refreshes tools for a named MCP server.","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/config.go#L253-L289","documentation":"Returned by Client.EnableDockerMCP when the POST reached the server but the response status was not 200. The library treats only 200 as success for this fire-and-forget enable operation. A 404 means the route or workspace doesn't exist; 401/403 indicate auth problems; 500 indicates the server failed while enabling Docker MCP (e.g. Docker unavailable on the host).","triggerScenarios":"Calling EnableDockerMCP on a nonexistent workspace ID (404), without adequate permissions (403), against an older server lacking the /mcp/docker/enable route (404/405), or when the server-side Docker integration fails (500).","commonSituations":"Server version older than the Docker MCP feature; workspace already torn down; token lacking admin scope; host machine where Docker is not installed so the enable handler errors.","solutions":["Read the status code from the message: 404 -> verify workspace ID and server version support; 401/403 -> fix auth; 500 -> check server logs for Docker availability.","Confirm the target server exposes POST /workspaces/{id}/mcp/docker/enable.","Verify Docker is installed and running on the workspace host.","Re-authenticate if credentials expired.","Check the workspace is in a state that permits MCP changes (not suspended/deleting)."],"exampleFix":"// before\nerr := client.EnableDockerMCP(ctx, wsID) // status code 500\n// after\nerr := client.EnableDockerMCP(ctx, wsID)\nif err != nil && strings.Contains(err.Error(), \"500\") {\n    log.Printf(\"server failed to enable docker MCP; ensure Docker is running on the host\")\n    return err\n}","handlingStrategy":"validation","validationCode":"// Verify prerequisites before enabling\nws, err := client.GetWorkspace(ctx, wsID)\nif err != nil || ws == nil {\n    return fmt.Errorf(\"workspace %s not found\", wsID)\n}\n// also ensure the server supports the feature\nif !serverSupportsFeature(minServerVersionForDockerMCP) {\n    return ErrDockerMCPUnsupported\n}","typeGuard":"func isNon200(err error) (code int, ok bool) {\n    m := regexp.MustCompile(`status code (\\d+)`).FindStringSubmatch(err.Error())\n    if len(m) < 2 { return 0, false }\n    code, err2 := strconv.Atoi(m[1])\n    return code, err2 == nil\n}","tryCatchPattern":"err := client.EnableDockerMCP(ctx, wsID)\nif err != nil {\n    if code, ok := isNon200(err); ok {\n        switch {\n        case code == 404: return ErrDockerMCPRouteUnavailable\n        case code == 401 || code == 403: return ErrInsufficientPermissions\n        default: return fmt.Errorf(\"enable failed, check server logs: %w\", err)\n        }\n    }\n    return err\n}","preventionTips":["Verify the workspace exists and is active before enabling.","Check Docker is installed/running on the workspace host.","Keep server versions at or above the Docker MCP feature release.","Refresh credentials when 401/403 appears."],"tags":["http-client","http-status","mcp","docker","api-error"],"backgroundTag":"http-non-200-response","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}