@@ -13,12 +13,17 @@ import (
1313var mcpToolListJSON []byte
1414
1515type MCPToolDef 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 * MCPToolDef ) Name () string {
23+ name , _ := strings .CutPrefix (m .RawName , "sg_" )
24+ return strings .ReplaceAll (name , "_" , "-" )
25+ }
26+
2227type Schema struct {
2328 Schema string `json:"$schema"`
2429 SchemaObject
@@ -99,6 +104,10 @@ func loadToolDefinitions(data []byte) (map[string]*MCPToolDef, error) {
99104 }
100105 }
101106
107+ // make it so that can find a tool definition by it's original name (RawName) and normalized name (Name())
108+ tools [def .RawName ] = def
109+ tools [def .Name ()] = def
110+
102111 if len (parser .errors ) > 0 {
103112 return tools , errors .Append (nil , parser .errors ... )
104113 }
@@ -170,9 +179,3 @@ func (p *parser) parseProperties(props map[string]json.RawMessage) map[string]Sc
170179 }
171180 return res
172181}
173-
174- // normalizeToolName takes mcp tool names like 'sg_keyword_search' and normalizes it to 'keyword-search"
175- func normalizeToolName (toolName string ) string {
176- toolName , _ = strings .CutPrefix (toolName , "sg_" )
177- return strings .ReplaceAll (toolName , "_" , "-" )
178- }
0 commit comments