{"record":{"id":"427fa53df2fcdb87","repo":"Tencent/WeKnora","slug":"failed-to-list-resources-w","errorCode":null,"errorMessage":"failed to list resources: %w","messagePattern":"failed to list resources: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/mcp_service.go","lineNumber":611,"sourceCode":"\t// Get service\n\tservice, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get MCP service: %w\", err)\n\t}\n\tif service == nil {\n\t\treturn nil, fmt.Errorf(\"MCP service not found\")\n\t}\n\n\t// Get or create client\n\tclient, err := s.mcpManager.GetOrCreateClient(ctx, service)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get MCP client: %w\", err)\n\t}\n\n\t// List resources\n\tresources, err := client.ListResources(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list resources: %w\", err)\n\t}\n\n\treturn resources, nil\n}\n","sourceCodeStart":593,"sourceCodeEnd":616,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/mcp_service.go#L593-L616","documentation":"An MCP client was obtained successfully, but the ListResources RPC against the MCP server failed. This is a remote-side failure (server rejected the call, timed out, or returned an MCP protocol error), wrapped with %w for cause inspection.","triggerScenarios":"GetMCPServiceResources called on a service with a live client, but client.ListResources(ctx) returns an error: server timeout, unsupported resources capability, or protocol/permission error from the MCP server.","commonSituations":"MCP server does not implement the resources capability (resources/list unsupported); server-side timeout under load; auth token expired mid-session; server version mismatch with client capabilities.","solutions":["Verify the MCP server advertises the resources capability in its initialize response","Increase the context timeout for the ListResources call if the server is slow","Inspect the wrapped error to distinguish protocol errors from transport errors","Upgrade the MCP server if its version predates resources/list support"],"exampleFix":"// before\nctx := context.Background()\nresources, err := svc.GetMCPServiceResources(ctx, tenantID, serviceID)\n// after\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\ndefer cancel()\nresources, err := svc.GetMCPServiceResources(ctx, tenantID, serviceID)","handlingStrategy":"retry","validationCode":"// confirm the server advertises resources support before listing\ncaps, err := client.ServerCapabilities(ctx)\nif err != nil || caps.Resources == nil {\n\treturn errors.New(\"MCP server does not support resources\")\n}","typeGuard":"func isListResourcesErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to list resources\")\n}","tryCatchPattern":"ctx, cancel := context.WithTimeout(ctx, 30*time.Second)\ndefer cancel()\nresources, err := svc.GetMCPServiceResources(ctx, tenantID, serviceID)\nif isListResourcesErr(err) {\n\treturn retryWithBackoff(ctx, 2, call) // transient RPC failures\n}","preventionTips":["Set generous but bounded timeouts on MCP RPC contexts","Check server capability negotiation logs when resources/list fails","Keep MCP client and server versions compatible","Handle expired auth by re-establishing the client session"],"tags":["mcp","resources","rpc"],"backgroundTag":"mcp-rpc-call-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}