@@ -13,17 +13,15 @@ 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- type InputProperty struct {
23- Name string
24- Type string
25- Description string
26- ItemType string
22+ func (m * MCPToolDef ) Name () string {
23+ name , _ := strings .CutPrefix (m .RawName , "sg_" )
24+ return strings .ReplaceAll (name , "_" , "-" )
2725}
2826
2927type Schema struct {
@@ -143,12 +141,6 @@ func (p *Parser) parseProperties(props map[string]json.RawMessage) map[string]Sc
143141 return res
144142}
145143
146- // normalizeToolName takes mcp tool names like 'sg_keyword_search' and normalizes it to 'keyword-search"
147- func normalizeToolName (toolName string ) string {
148- toolName , _ = strings .CutPrefix (toolName , "sg_" )
149- return strings .ReplaceAll (toolName , "_" , "-" )
150- }
151-
152144func LoadMCPToolDefinitions (data []byte ) (map [string ]* MCPToolDef , error ) {
153145 defs := struct {
154146 Tools []struct {
@@ -167,13 +159,16 @@ func LoadMCPToolDefinitions(data []byte) (map[string]*MCPToolDef, error) {
167159 parser := & Parser {}
168160
169161 for _ , t := range defs .Tools {
170- name := normalizeToolName (t .Name )
171- tools [name ] = & MCPToolDef {
172- Name : t .Name ,
162+ def := & MCPToolDef {
163+ RawName : t .Name ,
173164 Description : t .Description ,
174165 InputSchema : parser .parseRootSchema (t .InputSchema ),
175166 OutputSchema : parser .parseRootSchema (t .OutputSchema ),
176167 }
168+
169+ // make it so that can find a tool definition by it's original name (RawName) and normalized name (Name())
170+ tools [def .RawName ] = def
171+ tools [def .Name ()] = def
177172 }
178173
179174 if len (parser .errors ) > 0 {
0 commit comments