Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/enbility/eebus-go v0.7.0
github.com/enbility/ship-go v0.6.0
github.com/enbility/spine-go v0.7.0
github.com/evcc-io/openapi-mcp v0.3.2-0.20250810085124-11eaedf32359
github.com/evcc-io/openapi-mcp v0.4.0
github.com/evcc-io/rct v0.1.2-0.20250315164247-d2f41b161785
github.com/evcc-io/tesla-proxy-client v0.0.0-20240221194046-4168b3759701
github.com/fatih/structs v1.1.0
Expand Down Expand Up @@ -230,6 +230,7 @@ require (
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.26.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/term v0.33.0 // indirect
Expand All @@ -247,6 +248,7 @@ tool (
github.com/dmarkham/enumer
github.com/evcc-io/evcc/cmd/decorate
github.com/evcc-io/evcc/cmd/openapi
github.com/evcc-io/openapi-mcp/cmd/openapi-mcp
github.com/gokrazy/tools/cmd/gok
go.uber.org/mock/mockgen
)
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ github.com/evcc-io/modbus v0.0.0-20250501165638-8b6f1fbdb7ea h1:F6eyC8V8wvc3ranl
github.com/evcc-io/modbus v0.0.0-20250501165638-8b6f1fbdb7ea/go.mod h1:swrNGAVgI1r/3d/sEKE7qgujdRR9aHVPYKyc3gvpVTc=
github.com/evcc-io/ocpp-go v0.0.0-20250322092544-c0c6094051c0 h1:Qz34Pm1Wr05jjJia5g2On3zRqdZh+BLTwqHgJGsiIh4=
github.com/evcc-io/ocpp-go v0.0.0-20250322092544-c0c6094051c0/go.mod h1:2kcukDdhui4u730VfnYVWuwzDLgw+mBRGDir/QAyBhg=
github.com/evcc-io/openapi-mcp v0.3.2-0.20250810085124-11eaedf32359 h1:VrNkGZmSfBDKuAeFbg/Vz3oDN9z1Q3XQ4vS415Jr6Jw=
github.com/evcc-io/openapi-mcp v0.3.2-0.20250810085124-11eaedf32359/go.mod h1:87GSlXX1DP8ne5ELpm18vst5yiMmDFeSRG8xYL1BfzQ=
github.com/evcc-io/openapi-mcp v0.4.0 h1:tgzGsuBWj1aInD6hBbaShHHYUlul61QgGUeBC/nxNk0=
github.com/evcc-io/openapi-mcp v0.4.0/go.mod h1:87GSlXX1DP8ne5ELpm18vst5yiMmDFeSRG8xYL1BfzQ=
github.com/evcc-io/rct v0.1.2-0.20250315164247-d2f41b161785 h1:OWCBVMcPsVTffdiZN3VYaq9p4fsWlzd490J6pekaKLA=
github.com/evcc-io/rct v0.1.2-0.20250315164247-d2f41b161785/go.mod h1:n6MTBU36QOadGlxxiADu86VaT5l0eYdbmFBHF14AD/s=
github.com/evcc-io/tesla-proxy-client v0.0.0-20240221194046-4168b3759701 h1:3JplY3KS6KMDVDNAU+3+KWmSWmoHIU34qwuIpW6SiHk=
Expand Down Expand Up @@ -793,6 +793,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
go.yaml.in/yaml/v4 v4.0.0-20250730171608-926dd0b54a90 h1:PK8906uEqvjB6qgonTahH/ZBqrdIv/6mpysTotKxvL0=
go.yaml.in/yaml/v4 v4.0.0-20250730171608-926dd0b54a90/go.mod h1:CBdeces52/nUXndfQ5OY8GEQuNR9uEEOJPZj/Xq5IzU=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
33 changes: 2 additions & 31 deletions server/mcp/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"fmt"
"net/http"
"net/http/httptest"
"slices"
"strings"

"github.com/evcc-io/evcc/util"
openapi2mcp "github.com/evcc-io/openapi-mcp"
Expand Down Expand Up @@ -42,13 +40,12 @@ func NewHandler(host http.Handler, baseUrl, basePath string) (http.Handler, erro
srv := mcp.NewServer(&mcp.Implementation{Name: "evcc", Version: util.Version}, nil)

openapi2mcp.RegisterOpenAPITools(srv, ops, doc, &openapi2mcp.ToolGenOptions{
NameFormat: nameFormat(log),
TagFilter: []string{
"general",
"battery",
"loadpoints",
"tariffs",
"loadpoints",
"vehicles",
"battery",
},
RequestHandler: requestHandler(host),
})
Expand All @@ -75,32 +72,6 @@ func NewHandler(host http.Handler, baseUrl, basePath string) (http.Handler, erro
return handler, nil
}

func nameFormat(log *util.Logger) func(name string) string {
return func(name string) string {
// move method to the end
parts := strings.SplitN(name, "_", 2)
slices.Reverse(parts)

res := strings.Join(parts, "-")
res = strings.ReplaceAll(res, "/", "-")
res = strings.ReplaceAll(res, "{", "_")
res = strings.ReplaceAll(res, "}", "")
res = strings.ReplaceAll(res, "-_", "_")
res = strings.ReplaceAll(res, "--", "-")

res = strings.TrimLeft(res, "/-_")
res = strings.ToLower(res)

// Claude Code has a 64 character limit for tool names
if len(res) > 64 {
res = res[:64]
}

log.TRACE.Println("adding tool:", res)
return res
}
}

func requestHandler(handler http.Handler) func(req *http.Request) (*http.Response, error) {
return func(req *http.Request) (*http.Response, error) {
w := httptest.NewRecorder()
Expand Down
Loading
Loading