chore: improve mcp tool names
This commit is contained in:
parent
a2975d824a
commit
9cf934af18
1 changed files with 10 additions and 9 deletions
|
|
@ -54,8 +54,8 @@ func NewHandler(host http.Handler, baseUrl, basePath string) (http.Handler, erro
|
|||
RequestHandler: requestHandler(host),
|
||||
})
|
||||
|
||||
srv.AddTool(mcp.NewTool("evcc-docs",
|
||||
mcp.WithDescription("evcc documentation"),
|
||||
srv.AddTool(mcp.NewTool("docs",
|
||||
mcp.WithDescription("Documentation"),
|
||||
), docsTool)
|
||||
|
||||
srv.AddPrompt(mcp.NewPrompt("create-charge-plan",
|
||||
|
|
@ -77,19 +77,20 @@ func NewHandler(host http.Handler, baseUrl, basePath string) (http.Handler, erro
|
|||
|
||||
func nameFormat(log *util.Logger) func(name string) string {
|
||||
return func(name string) string {
|
||||
res := name
|
||||
res = strings.ReplaceAll(res, "_/", "/")
|
||||
// move method to the end
|
||||
parts := strings.Split(name, "_")
|
||||
res := strings.Join(parts[:len(parts)-1], "-") + "-" + parts[len(parts)-1]
|
||||
|
||||
res = strings.TrimPrefix(res, "/")
|
||||
res = strings.ReplaceAll(res, "/", "-")
|
||||
res = strings.ReplaceAll(res, "{", "with_")
|
||||
res = strings.ReplaceAll(res, "{", "_")
|
||||
res = strings.ReplaceAll(res, "}", "")
|
||||
res = strings.ReplaceAll(res, "-_", "_")
|
||||
res = strings.ToLower(res)
|
||||
|
||||
// Claude Code has a 64 character limit for tool names
|
||||
if len(res) > 64 {
|
||||
res = strings.ReplaceAll(res, "with_", "w_")
|
||||
if len(res) > 64 {
|
||||
res = res[:64]
|
||||
}
|
||||
res = res[:64]
|
||||
}
|
||||
|
||||
log.TRACE.Println("adding tool:", res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue