@@ -2,11 +2,13 @@ package mcp
8 "github.com/charmbracelet/crush/internal/config"
9 "github.com/charmbracelet/crush/internal/config"
9 "github.com/charmbracelet/crush/internal/csync"
10 "github.com/charmbracelet/crush/internal/csync"
11+ "github.com/modelcontextprotocol/go-sdk/jsonrpc"
10 "github.com/modelcontextprotocol/go-sdk/mcp"
12 "github.com/modelcontextprotocol/go-sdk/mcp"
@@ -81,11 +83,22 @@ func getResources(ctx context.Context, c *ClientSession) ([]*Resource, error) {
82 result, err := c.ListResources(ctx, &mcp.ListResourcesParams{})
84 result, err := c.ListResources(ctx, &mcp.ListResourcesParams{})
83 if err != nil {
85 if err != nil {
86+ // Handle "Method not found" errors from MCP servers that don't support resources/list
87+ if isMethodNotFoundError(err) {
88+ slog.Warn("MCP server does not support resources/list", "error", err)
84 return nil, err
91 return nil, err
86 return result.Resources, nil
93 return result.Resources, nil
96+// isMethodNotFoundError checks if the error is a JSON-RPC "Method not found" error.
97+func isMethodNotFoundError(err error) bool {
98+ var rpcErr *jsonrpc.Error
99+ return errors.As(err, &rpcErr) && rpcErr != nil && rpcErr.Code == jsonrpc.CodeMethodNotFound
89func updateResources(name string, resources []*Resource) int {
102func updateResources(name string, resources []*Resource) int {
90 if len(resources) == 0 {
103 if len(resources) == 0 {
91 allResources.Del(name)
104 allResources.Del(name)