Skip to content

Commit c65be5c

Browse files
committed
simpler
Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>
1 parent dc52144 commit c65be5c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

pkg/toolsets/toolsets.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ func NewToolsetDoesNotExistError(name string) *ToolsetDoesNotExistError {
2929
return &ToolsetDoesNotExistError{Name: name}
3030
}
3131

32-
// createToolWithPrefixedName creates a new tool with the same properties as the original but with a prefixed name
33-
func createToolWithPrefixedName(original mcp.Tool, prefix string) mcp.Tool {
34-
// Create a new tool with the prefixed name and copy all properties
35-
newTool := mcp.Tool{
36-
Name: prefix + original.Name,
37-
Description: original.Description,
38-
InputSchema: original.InputSchema,
39-
Annotations: original.Annotations,
40-
}
41-
return newTool
42-
}
43-
4432
func NewServerTool(tool mcp.Tool, handler server.ToolHandlerFunc) server.ServerTool {
4533
return server.ServerTool{Tool: tool, Handler: handler}
4634
}
@@ -108,12 +96,11 @@ func (t *Toolset) RegisterTools(s *server.MCPServer, prefix string) {
10896
return
10997
}
11098
registerToolWithPrefix := func(tool server.ServerTool) {
111-
toolToRegister := tool.Tool
11299
if prefix != "" {
113100
// Create a new tool with the prefixed name
114-
toolToRegister = createToolWithPrefixedName(tool.Tool, prefix)
101+
tool.Tool.Name = prefix + tool.Tool.Name
115102
}
116-
s.AddTool(toolToRegister, tool.Handler)
103+
s.AddTool(tool.Tool, tool.Handler)
117104
}
118105

119106
for _, tool := range t.readTools {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy