Skip to content

Commit 609907a

Browse files
committed
reduce duplicate read write tool loops
Signed-off-by: hungran <[email protected]>
1 parent cf1dc07 commit 609907a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pkg/toolsets/toolsets.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,21 @@ func (t *Toolset) RegisterTools(s *server.MCPServer, prefix string) {
9595
if !t.Enabled {
9696
return
9797
}
98-
for _, tool := range t.readTools {
98+
registerToolWithPrefix := func(tool server.ServerTool) {
9999
toolToRegister := tool.Tool
100100
if prefix != "" {
101101
// Create a new tool with the prefixed name
102102
toolToRegister = createToolWithPrefixedName(tool.Tool, prefix)
103103
}
104104
s.AddTool(toolToRegister, tool.Handler)
105105
}
106+
107+
for _, tool := range t.readTools {
108+
registerToolWithPrefix(tool)
109+
}
106110
if !t.readOnly {
107111
for _, tool := range t.writeTools {
108-
toolToRegister := tool.Tool
109-
if prefix != "" {
110-
// Create a new tool with the prefixed name
111-
toolToRegister = createToolWithPrefixedName(tool.Tool, prefix)
112-
}
113-
s.AddTool(toolToRegister, tool.Handler)
112+
registerToolWithPrefix(tool)
114113
}
115114
}
116115
}

0 commit comments

Comments
 (0)