@@ -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
1614type ToolRegistry struct {
17- tools map [string ]* ToolDef
18- endpoints map [string ]string
15+ tools map [string ]* ToolDef
1916}
2017
2118func 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
2925func (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
5735func (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
6341func (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