#252
fix: sanitize MCP names for OpenAI tool calls
Summary
- Fixes: MCP tools such as fs.read and nezha::server.exec are exposed unchanged as OpenAI function names, causing a 400 response because they do not match ^[a-zA-Z0-9_-]+$.
- Root cause: toolInfoFromDefinition copied the raw MCP name into schema.ToolInfo.Name even though that field is serialized as an OpenAI function name; the bridge already retains the raw name separately for MCP invocation.
Regression evidence
-
Before:
go test ./internal/einomcp -run TestToolInfoFromDefinitionSanitizesOpenAIToolName -count=1exited1 -
After:
go test ./internal/einomcp -run TestToolInfoFromDefinitionSanitizesOpenAIToolName -count=1exited0
Verification
go test ./...go vet ./internal/einomcptest -z "$(gofmt -l internal/einomcp/mcp_tools.go internal/einomcp/mcp_tools_test.go)"
Scope
- 2 files changed, +58 / -9 lines