Skip to content

Commit dc52144

Browse files
committed
reduce duplicate read write tool loops
Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>
1 parent 33228e1 commit dc52144

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
@@ -107,22 +107,21 @@ func (t *Toolset) RegisterTools(s *server.MCPServer, prefix string) {
107107
if !t.Enabled {
108108
return
109109
}
110-
for _, tool := range t.readTools {
110+
registerToolWithPrefix := func(tool server.ServerTool) {
111111
toolToRegister := tool.Tool
112112
if prefix != "" {
113113
// Create a new tool with the prefixed name
114114
toolToRegister = createToolWithPrefixedName(tool.Tool, prefix)
115115
}
116116
s.AddTool(toolToRegister, tool.Handler)
117117
}
118+
119+
for _, tool := range t.readTools {
120+
registerToolWithPrefix(tool)
121+
}
118122
if !t.readOnly {
119123
for _, tool := range t.writeTools {
120-
toolToRegister := tool.Tool
121-
if prefix != "" {
122-
// Create a new tool with the prefixed name
123-
toolToRegister = createToolWithPrefixedName(tool.Tool, prefix)
124-
}
125-
s.AddTool(toolToRegister, tool.Handler)
124+
registerToolWithPrefix(tool)
126125
}
127126
}
128127
}

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