@@ -12,10 +12,15 @@ import (
1212var mcpToolListJSON []byte
1313
1414type ToolDef struct {
15- Name string `json:"name"`
16- Description string `json:"description"`
17- InputSchema SchemaObject `json:"inputSchema"`
18- OutputSchema SchemaObject `json:"outputSchema"`
15+ RawName string `json:"name"`
16+ Description string `json:"description"`
17+ InputSchema Schema `json:"inputSchema"`
18+ OutputSchema Schema `json:"outputSchema"`
19+ }
20+
21+ func (m * ToolDef ) Name () string {
22+ name , _ := strings .CutPrefix (m .RawName , "sg_" )
23+ return strings .ReplaceAll (name , "_" , "-" )
1924}
2025
2126type RawSchema struct {
@@ -93,6 +98,10 @@ func loadToolDefinitions(data []byte) (map[string]*ToolDef, error) {
9398 }
9499 }
95100
101+ // make it so that can find a tool definition by it's original name (RawName) and normalized name (Name())
102+ tools [def .RawName ] = def
103+ tools [def .Name ()] = def
104+
96105 if len (decoder .errors ) > 0 {
97106 return tools , errors .Append (nil , decoder .errors ... )
98107 }
@@ -162,9 +171,3 @@ func (d *decoder) decodeProperties(props map[string]json.RawMessage) map[string]
162171 }
163172 return res
164173}
165-
166- // normalizeToolName takes mcp tool names like 'sg_keyword_search' and normalizes it to 'keyword-search"
167- func normalizeToolName (toolName string ) string {
168- toolName , _ = strings .CutPrefix (toolName , "sg_" )
169- return strings .ReplaceAll (toolName , "_" , "-" )
170- }
0 commit comments