Tencent/WeKnora · error
failed to list resources
Error message
failed to list resources: %w
What it means
ListResources wraps errors from c.client.ListResources after initialize. The resources/list RPC failed — dropped session, JSON-RPC error (most often 'method not supported' because the server doesn't implement resources), timeout, or transport failure. The client may have been marked disconnected by checkErrorAndDisconnectIfNeeded before returning.
Solutions
- Check the server's initialize capabilities include resources before calling; treat 'not supported' as an empty result rather than an error
- Reconnect (Connect + Initialize) and retry if the session was lost
- Raise the timeout if the resource listing is slow
- Verify proxy/LB idle-timeout settings for long-lived connections
Example fix
// before
resources, err := c.ListResources(ctx)
if err != nil { return nil, err }
// after
if !c.serverSupportsResources() { // check InitializeResult capabilities
return []*types.MCPResource{}, nil
}
resources, err := c.ListResources(ctx)
if err != nil { return nil, fmt.Errorf("list resources: %w", err) } Defensive patterns
Strategy: fallback
Validate before calling
func listResourcesIfSupported(ctx context.Context, c MCPClient) ([]*types.MCPResource, error) {
resources, err := c.ListResources(ctx)
if err != nil && (errors.Is(err, ErrNotConnected) || strings.Contains(err.Error(), "failed to list resources")) {
// treat unsupported/failed resource listing as empty rather than fatal
return []*types.MCPResource{}, nil
}
return resources, err
} Type guard
func isListResourcesFailure(err error) bool {
return err != nil && strings.Contains(err.Error(), "failed to list resources")
} Try / catch
resources, err := c.ListResources(ctx)
if err != nil {
if isListResourcesFailure(err) && !c.capabilities.Resources {
log.Info("server does not support resources; skipping")
return nil, nil
}
return reconnectAndListResources(ctx, c)
} Prevention
- Check the resources capability from the initialize result before calling ListResources
- Handle tools-only servers gracefully in discovery code
- Reconnect-and-retry once on session-loss errors before surfacing the failure
When it happens
Trigger: ListResources called on an initialized client where the server does not support the resources capability, the session/connection was lost, or the context timed out during the RPC.
Common situations: Calling ListResources against a tools-only MCP server (very common — many servers implement tools but not resources); expired session on a reused long-lived client; proxy cutting idle streamable connections.
Related errors
- failed to list resources
- failed to list tools
- failed to call tool
- failed to create HTTP streamable client
- failed to create SSE client
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/1dd64e1354d06f80.
Report an issue: GitHub.
Appendix: source
Thrown at internal/mcp/client.go:455
}
}
return tools, nil
}
// ListResources retrieves the list of available resources
func (c *mcpGoClient) ListResources(ctx context.Context) ([]*types.MCPResource, error) {
if !c.initialized {
return nil, ErrNotConnected
}
req := mcp.ListResourcesRequest{}
result, err := oauthCall(ctx, c, func() (*mcp.ListResourcesResult, error) {
return c.client.ListResources(ctx, req)
})
if err != nil {
c.checkErrorAndDisconnectIfNeeded(err)
return nil, fmt.Errorf("failed to list resources: %w", err)
}
// Convert to our types
resources := make([]*types.MCPResource, len(result.Resources))
for i, resource := range result.Resources {
resources[i] = &types.MCPResource{
URI: resource.URI,
Name: resource.Name,
Description: resource.Description,
MimeType: resource.MIMEType,
}
}
return resources, nil
}
// CallTool calls a tool on the MCP service
func (c *mcpGoClient) CallTool(ctx context.Context, name string, args map[string]interface{}) (*CallToolResult, error) {View on GitHub (pinned to 988cbb0330)