From e1a34e7645bc67949b3384e84ae9018d769f7e70 Mon Sep 17 00:00:00 2001 From: William Bezuidenhout Date: Wed, 10 Dec 2025 17:51:58 +0200 Subject: [PATCH] remove loading of tools from .api/mcp/deepsearch --- internal/mcp/mcp_request.go | 1 - internal/mcp/registry.go | 39 ++++++++----------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/internal/mcp/mcp_request.go b/internal/mcp/mcp_request.go index 980bfbe680..4edd00948a 100644 --- a/internal/mcp/mcp_request.go +++ b/internal/mcp/mcp_request.go @@ -14,7 +14,6 @@ import ( ) const MCPURLPath = ".api/mcp/v1" -const MCPDeepSearchURLPath = ".api/mcp/deepsearch" func fetchToolDefinitions(ctx context.Context, client api.Client, endpoint string) (map[string]*ToolDef, error) { resp, err := doJSONRPC(ctx, client, endpoint, "tools/list", nil) diff --git a/internal/mcp/registry.go b/internal/mcp/registry.go index d428c48e4f..0ee7314791 100644 --- a/internal/mcp/registry.go +++ b/internal/mcp/registry.go @@ -6,51 +6,29 @@ import ( "iter" "github.com/sourcegraph/src-cli/internal/api" - - "github.com/sourcegraph/sourcegraph/lib/errors" ) // ToolRegistry keeps track of tools and the endpoints they originated from type ToolRegistry struct { - tools map[string]*ToolDef - endpoints map[string]string + tools map[string]*ToolDef } func NewToolRegistry() *ToolRegistry { return &ToolRegistry{ - tools: make(map[string]*ToolDef), - endpoints: make(map[string]string), + tools: make(map[string]*ToolDef), } } -// LoadTools loads the tool definitions from the Mcp tool endpoints constants McpURLPath and McpDeepSearchURLPath +// LoadTools loads the tool definitions from the Mcp tool endpoints constants McpURLPath func (r *ToolRegistry) LoadTools(ctx context.Context, client api.Client) error { - endpoints := []string{MCPURLPath, MCPDeepSearchURLPath} - - var errs []error - for _, endpoint := range endpoints { - tools, err := fetchToolDefinitions(ctx, client, endpoint) - if err != nil { - errs = append(errs, errors.Wrapf(err, "failed to load tools from %s", endpoint)) - continue - } - r.register(endpoint, tools) - } - - if len(errs) > 0 { - return errors.Append(nil, errs...) + tools, err := fetchToolDefinitions(ctx, client, MCPURLPath) + if err != nil { + return err } + r.tools = tools return nil } -// register associates a collection of tools with the given endpoint -func (r *ToolRegistry) register(endpoint string, tools map[string]*ToolDef) { - for name, def := range tools { - r.tools[name] = def - r.endpoints[name] = endpoint - } -} - // Get returns the tool definition for the given name func (r *ToolRegistry) Get(name string) (*ToolDef, bool) { tool, ok := r.tools[name] @@ -60,8 +38,7 @@ func (r *ToolRegistry) Get(name string) (*ToolDef, bool) { // CallTool calls the given tool with the given arguments. It constructs the Tool request and decodes the Tool response func (r *ToolRegistry) CallTool(ctx context.Context, client api.Client, name string, args map[string]any) (map[string]json.RawMessage, error) { tool := r.tools[name] - endpoint := r.endpoints[name] - resp, err := doToolCall(ctx, client, endpoint, tool.RawName, args) + resp, err := doToolCall(ctx, client, MCPURLPath, tool.RawName, args) if err != nil { return nil, err }