@@ -13,12 +13,17 @@ import (
1313var mcpToolListJSON []byte
1414
1515type ToolDef struct {
16- Name string `json:"name"`
16+ RawName string `json:"name"`
1717 Description string `json:"description"`
1818 InputSchema Schema `json:"inputSchema"`
1919 OutputSchema Schema `json:"outputSchema"`
2020}
2121
22+ func (m * ToolDef ) Name () string {
23+ name , _ := strings .CutPrefix (m .RawName , "sg_" )
24+ return strings .ReplaceAll (name , "_" , "-" )
25+ }
26+
2227type RawSchema struct {
2328 Type string `json:"type"`
2429 Description string `json:"description"`
@@ -98,6 +103,10 @@ func loadToolDefinitions(data []byte) (map[string]*ToolDef, error) {
98103 }
99104 }
100105
106+ // make it so that can find a tool definition by it's original name (RawName) and normalized name (Name())
107+ tools [def .RawName ] = def
108+ tools [def .Name ()] = def
109+
101110 if len (parser .errors ) > 0 {
102111 return tools , errors .Append (nil , parser .errors ... )
103112 }
@@ -169,9 +178,3 @@ func (p *parser) parseProperties(props map[string]json.RawMessage) map[string]Sc
169178 }
170179 return res
171180}
172-
173- // normalizeToolName takes mcp tool names like 'sg_keyword_search' and normalizes it to 'keyword-search"
174- func normalizeToolName (toolName string ) string {
175- toolName , _ = strings .CutPrefix (toolName , "sg_" )
176- return strings .ReplaceAll (toolName , "_" , "-" )
177- }
0 commit comments