Skip to content

Commit d8c7c8e

Browse files
committed
remove Name() method and use method name field
1 parent 5ba9bfb commit d8c7c8e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

internal/mcp/mcp_parse.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ import (
1313
var mcpToolListJSON []byte
1414

1515
type ToolDef struct {
16+
Name string
1617
RawName string `json:"name"`
1718
Description string `json:"description"`
1819
InputSchema Schema `json:"inputSchema"`
1920
OutputSchema Schema `json:"outputSchema"`
2021
}
2122

22-
func (m *ToolDef) Name() string {
23-
name, _ := strings.CutPrefix(m.RawName, "sg_")
24-
return strings.ReplaceAll(name, "_", "-")
25-
}
26-
2723
type RawSchema struct {
2824
Type string `json:"type"`
2925
Description string `json:"description"`
@@ -94,19 +90,21 @@ func loadToolDefinitions(data []byte) (map[string]*ToolDef, error) {
9490
parser := &parser{}
9591

9692
for _, t := range defs.Tools {
97-
name := normalizeToolName(t.Name)
98-
tools[name] = &ToolDef{
99-
Name: t.Name,
93+
// normalize the raw mcp tool name to be without the mcp identifiers
94+
rawName := t.Name
95+
name, _ := strings.CutPrefix(rawName, "sg_")
96+
name = strings.ReplaceAll(name, "_", "-")
97+
98+
tool := &ToolDef{
99+
Name: name,
100+
RawName: rawName,
100101
Description: t.Description,
101102
InputSchema: parser.parseRootSchema(t.InputSchema),
102103
OutputSchema: parser.parseRootSchema(t.OutputSchema),
103104
}
105+
tools[tool.Name] = tool
104106
}
105107

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-
110108
if len(parser.errors) > 0 {
111109
return tools, errors.Append(nil, parser.errors...)
112110
}

0 commit comments

Comments
 (0)