Skip to content

Commit e1a34e7

Browse files
committed
remove loading of tools from .api/mcp/deepsearch
1 parent c8a9dce commit e1a34e7

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
@@ -6,51 +6,29 @@ import (
66
"iter"
77

88
"github.com/sourcegraph/src-cli/internal/api"
9-
10-
"github.com/sourcegraph/sourcegraph/lib/errors"
119
)
1210

1311
// ToolRegistry keeps track of tools and the endpoints they originated from
1412
type ToolRegistry struct {
15-
tools map[string]*ToolDef
16-
endpoints map[string]string
13+
tools map[string]*ToolDef
1714
}
1815

1916
func NewToolRegistry() *ToolRegistry {
2017
return &ToolRegistry{
21-
tools: make(map[string]*ToolDef),
22-
endpoints: make(map[string]string),
18+
tools: make(map[string]*ToolDef),
2319
}
2420
}
2521

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

46-
// register associates a collection of tools with the given endpoint
47-
func (r *ToolRegistry) register(endpoint string, tools map[string]*ToolDef) {
48-
for name, def := range tools {
49-
r.tools[name] = def
50-
r.endpoints[name] = endpoint
51-
}
52-
}
53-
5432
// Get returns the tool definition for the given name
5533
func (r *ToolRegistry) Get(name string) (*ToolDef, bool) {
5634
tool, ok := r.tools[name]
@@ -60,8 +38,7 @@ func (r *ToolRegistry) Get(name string) (*ToolDef, bool) {
6038
// CallTool calls the given tool with the given arguments. It constructs the Tool request and decodes the Tool response
6139
func (r *ToolRegistry) CallTool(ctx context.Context, client api.Client, name string, args map[string]any) (map[string]json.RawMessage, error) {
6240
tool := r.tools[name]
63-
endpoint := r.endpoints[name]
64-
resp, err := doToolCall(ctx, client, endpoint, tool.RawName, args)
41+
resp, err := doToolCall(ctx, client, MCPURLPath, tool.RawName, args)
6542
if err != nil {
6643
return nil, err
6744
}

0 commit comments

Comments
 (0)