@@ -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
1412type ToolRegistry struct {
15- tools map [string ]* ToolDef
16- endpoints map [string ]string
13+ tools map [string ]* ToolDef
1714}
1815
1916func 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
2723func (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
5533func (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
6139func (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