Skip to content

Commit be2e759

Browse files
authored
remove loading of tools from .api/mcp/deepsearch (#1239)
1 parent fcce499 commit be2e759

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

internal/mcp/mcp_request.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
)
1515

1616
const MCPURLPath = ".api/mcp/v1"
17-
const MCPDeepSearchURLPath = ".api/mcp/deepsearch"
1817

1918
func fetchToolDefinitions(ctx context.Context, client api.Client, endpoint string) (map[string]*ToolDef, error) {
2019
resp, err := doJSONRPC(ctx, client, endpoint, "tools/list", nil)

internal/mcp/registry.go

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,29 @@ import (
88
"slices"
99

1010
"github.com/sourcegraph/src-cli/internal/api"
11-
12-
"github.com/sourcegraph/sourcegraph/lib/errors"
1311
)
1412

1513
// ToolRegistry keeps track of tools and the endpoints they originated from
1614
type ToolRegistry struct {
17-
tools map[string]*ToolDef
18-
endpoints map[string]string
15+
tools map[string]*ToolDef
1916
}
2017

2118
func NewToolRegistry() *ToolRegistry {
2219
return &ToolRegistry{
23-
tools: make(map[string]*ToolDef),
24-
endpoints: make(map[string]string),
20+
tools: make(map[string]*ToolDef),
2521
}
2622
}
2723

28-
// LoadTools loads the tool definitions from the Mcp tool endpoints constants McpURLPath and McpDeepSearchURLPath
24+
// LoadTools loads the tool definitions from the Mcp tool endpoints constants McpURLPath
2925
func (r *ToolRegistry) LoadTools(ctx context.Context, client api.Client) error {
30-
endpoints := []string{MCPURLPath, MCPDeepSearchURLPath}
31-
32-
var errs []error
33-
for _, endpoint := range endpoints {
34-
tools, err := fetchToolDefinitions(ctx, client, endpoint)
35-
if err != nil {
36-
errs = append(errs, errors.Wrapf(err, "failed to load tools from %s", endpoint))
37-
continue
38-
}
39-
r.register(endpoint, tools)
40-
}
41-
42-
if len(errs) > 0 {
43-
return errors.Append(nil, errs...)
26+
tools, err := fetchToolDefinitions(ctx, client, MCPURLPath)
27+
if err != nil {
28+
return err
4429
}
30+
r.tools = tools
4531
return nil
4632
}
4733

48-
// register associates a collection of tools with the given endpoint
49-
func (r *ToolRegistry) register(endpoint string, tools map[string]*ToolDef) {
50-
for name, def := range tools {
51-
r.tools[name] = def
52-
r.endpoints[name] = endpoint
53-
}
54-
}
55-
5634
// Get returns the tool definition for the given name
5735
func (r *ToolRegistry) Get(name string) (*ToolDef, bool) {
5836
tool, ok := r.tools[name]
@@ -62,8 +40,7 @@ func (r *ToolRegistry) Get(name string) (*ToolDef, bool) {
6240
// CallTool calls the given tool with the given arguments. It constructs the Tool request and decodes the Tool response
6341
func (r *ToolRegistry) CallTool(ctx context.Context, client api.Client, name string, args map[string]any) (map[string]json.RawMessage, error) {
6442
tool := r.tools[name]
65-
endpoint := r.endpoints[name]
66-
resp, err := doToolCall(ctx, client, endpoint, tool.RawName, args)
43+
resp, err := doToolCall(ctx, client, MCPURLPath, tool.RawName, args)
6744
if err != nil {
6845
return nil, err
6946
}

0 commit comments

Comments
 (0)