Tencent/WeKnora · error
failed to list resources: %w
Error message
failed to list resources: %w
What it means
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.
Source
Thrown at internal/application/service/mcp_service.go:611
// Get service
service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)
if err != nil {
return nil, fmt.Errorf("failed to get MCP service: %w", err)
}
if service == nil {
return nil, fmt.Errorf("MCP service not found")
}
// Get or create client
client, err := s.mcpManager.GetOrCreateClient(ctx, service)
if err != nil {
return nil, fmt.Errorf("failed to get MCP client: %w", err)
}
// List resources
resources, err := client.ListResources(ctx)
if err != nil {
return nil, fmt.Errorf("failed to list resources: %w", err)
}
return resources, nil
}
View on GitHub (pinned to 988cbb0330)
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
Example fix
// before ctx := context.Background() resources, err := svc.GetMCPServiceResources(ctx, tenantID, serviceID) // after ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() resources, err := svc.GetMCPServiceResources(ctx, tenantID, serviceID)
Defensive patterns
Strategy: retry
Validate before calling
// confirm the server advertises resources support before listing
caps, err := client.ServerCapabilities(ctx)
if err != nil || caps.Resources == nil {
return errors.New("MCP server does not support resources")
} Type guard
func isListResourcesErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "failed to list resources")
} Try / catch
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
resources, err := svc.GetMCPServiceResources(ctx, tenantID, serviceID)
if isListResourcesErr(err) {
return retryWithBackoff(ctx, 2, call) // transient RPC failures
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to list resources: %w
- failed to list tools: %w
- failed to call tool: %w
- failed to read resource: %w
- failed to get MCP client: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/427fa53df2fcdb87.
Report an issue: GitHub.