Skip to content

Commit e27f347

Browse files
committed
remove Name() method and use method name field
1 parent 31dcefd commit e27f347

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

internal/mcp/mcp_parse.go

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

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

21-
func (m *ToolDef) Name() string {
22-
name, _ := strings.CutPrefix(m.RawName, "sg_")
23-
return strings.ReplaceAll(name, "_", "-")
24-
}
25-
2622
type RawSchema struct {
2723
Type string `json:"type"`
2824
Description string `json:"description"`
@@ -89,13 +85,19 @@ func loadToolDefinitions(data []byte) (map[string]*ToolDef, error) {
8985
decoder := &decoder{}
9086

9187
for _, t := range defs.Tools {
92-
name := normalizeToolName(t.Name)
93-
tools[name] = &ToolDef{
94-
Name: t.Name,
88+
// normalize the raw mcp tool name to be without the mcp identifiers
89+
rawName := t.Name
90+
name, _ := strings.CutPrefix(rawName, "sg_")
91+
name = strings.ReplaceAll(name, "_", "-")
92+
93+
tool := &ToolDef{
94+
Name: name,
95+
RawName: rawName,
9596
Description: t.Description,
9697
InputSchema: decoder.decodeRootSchema(t.InputSchema),
9798
OutputSchema: decoder.decodeRootSchema(t.OutputSchema),
9899
}
100+
tools[tool.Name] = tool
99101
}
100102

101103
// make it so that can find a tool definition by it's original name (RawName) and normalized name (Name())

0 commit comments

Comments
 (0)