@@ -14,17 +14,15 @@ import (
1414var mcpToolListJSON []byte
1515
1616type MCPToolDef struct {
17- Name string `json:"name"`
17+ RawName string `json:"name"`
1818 Description string `json:"description"`
1919 InputSchema Schema `json:"inputSchema"`
2020 OutputSchema Schema `json:"outputSchema"`
2121}
2222
23- type InputProperty struct {
24- Name string
25- Type string
26- Description string
27- ItemType string
23+ func (m * MCPToolDef ) Name () string {
24+ name , _ := strings .CutPrefix (m .RawName , "sg_" )
25+ return strings .ReplaceAll (name , "_" , "-" )
2826}
2927
3028type Schema struct {
@@ -144,12 +142,6 @@ func (p *Parser) parseProperties(props map[string]json.RawMessage) map[string]Sc
144142 return res
145143}
146144
147- // normalizeToolName takes mcp tool names like 'sg_keyword_search' and normalizes it to 'keyword-search"
148- func normalizeToolName (toolName string ) string {
149- toolName , _ = strings .CutPrefix (toolName , "sg_" )
150- return strings .ReplaceAll (toolName , "_" , "-" )
151- }
152-
153145func LoadMCPToolDefinitions (data []byte ) (map [string ]* MCPToolDef , error ) {
154146 defs := struct {
155147 Tools []struct {
@@ -168,13 +160,16 @@ func LoadMCPToolDefinitions(data []byte) (map[string]*MCPToolDef, error) {
168160 parser := & Parser {}
169161
170162 for _ , t := range defs .Tools {
171- name := normalizeToolName (t .Name )
172- tools [name ] = & MCPToolDef {
173- Name : t .Name ,
163+ def := & MCPToolDef {
164+ RawName : t .Name ,
174165 Description : t .Description ,
175166 InputSchema : parser .parseRootSchema (t .InputSchema ),
176167 OutputSchema : parser .parseRootSchema (t .OutputSchema ),
177168 }
169+
170+ // make it so that can find a tool definition by it's original name (RawName) and normalized name (Name())
171+ tools [def .RawName ] = def
172+ tools [def .Name ()] = def
178173 }
179174
180175 if len (parser .errors ) > 0 {
0 commit comments