@@ -12,7 +12,8 @@ import (
1212
1313// ToolRegistry keeps track of tools and the endpoints they originated from
1414type ToolRegistry struct {
15- tools map [string ]* ToolDef
15+ tools map [string ]* ToolDef
16+ endpoint string
1617}
1718
1819func NewToolRegistry () * ToolRegistry {
@@ -21,9 +22,16 @@ func NewToolRegistry() *ToolRegistry {
2122 }
2223}
2324
24- // LoadTools loads the tool definitions from the Mcp tool endpoints constants McpURLPath
25+ // LoadTools loads the tool definitions from the MCP endpoint.
26+ // It tries the new endpoint first (.api/mcp), then falls back to legacy (.api/mcp/v1).
2527func (r * ToolRegistry ) LoadTools (ctx context.Context , client api.Client ) error {
26- tools , err := fetchToolDefinitions (ctx , client , MCPURLPath )
28+ endpoint , err := resolveMCPEndpoint (ctx , client )
29+ if err != nil {
30+ return err
31+ }
32+ r .endpoint = endpoint
33+
34+ tools , err := fetchToolDefinitions (ctx , client , endpoint )
2735 if err != nil {
2836 return err
2937 }
@@ -40,7 +48,7 @@ func (r *ToolRegistry) Get(name string) (*ToolDef, bool) {
4048// CallTool calls the given tool with the given arguments. It constructs the Tool request and decodes the Tool response
4149func (r * ToolRegistry ) CallTool (ctx context.Context , client api.Client , name string , args map [string ]any ) (map [string ]json.RawMessage , error ) {
4250 tool := r .tools [name ]
43- resp , err := doToolCall (ctx , client , MCPURLPath , tool .RawName , args )
51+ resp , err := doToolCall (ctx , client , r . endpoint , tool .RawName , args )
4452 if err != nil {
4553 return nil , err
4654 }
0 commit comments