Skip to content

Commit 845a012

Browse files
Merge pull request #278 from null-runner/fix/tool-prefix-dispatch
fix: forward original tool name to remote MCP servers
2 parents 3d710e0 + 68410ba commit 845a012

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/gateway/capabilitites.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (g *Gateway) listCapabilities(ctx context.Context, serverNames []string, cl
159159
capabilities.Tools = append(capabilities.Tools, ToolRegistration{
160160
ServerName: serverConfig.Name,
161161
Tool: &prefixedTool,
162-
Handler: g.mcpServerToolHandler(serverConfig.Name, g.mcpServer, tool.Annotations),
162+
Handler: g.mcpServerToolHandler(serverConfig.Name, g.mcpServer, tool.Annotations, tool.Name),
163163
})
164164
}
165165
}

pkg/gateway/handlers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (g *Gateway) mcpToolHandler(tool catalog.Tool) mcp.ToolHandler {
5757
}
5858
}
5959

60-
func (g *Gateway) mcpServerToolHandler(serverName string, server *mcp.Server, annotations *mcp.ToolAnnotations) mcp.ToolHandler {
60+
func (g *Gateway) mcpServerToolHandler(serverName string, server *mcp.Server, annotations *mcp.ToolAnnotations, originalToolName string) mcp.ToolHandler {
6161
return func(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
6262
// Look up server configuration
6363
serverConfig, _, ok := g.configuration.Find(serverName)
@@ -128,7 +128,7 @@ func (g *Gateway) mcpServerToolHandler(serverName string, server *mcp.Server, an
128128
}
129129
params := &mcp.CallToolParams{
130130
Meta: req.Params.Meta,
131-
Name: req.Params.Name,
131+
Name: originalToolName,
132132
Arguments: args,
133133
}
134134

0 commit comments

Comments
 (0)