Skip to content

fix: sanitize MCP names for OpenAI tool calls - #252

Open
CBOSSX wants to merge 1 commit into
Ed1s0nZ:mainfrom
CBOSSX:bugfix/openai-tool-names-20260814T073336Z
Open

fix: sanitize MCP names for OpenAI tool calls#252
CBOSSX wants to merge 1 commit into
Ed1s0nZ:mainfrom
CBOSSX:bugfix/openai-tool-names-20260814T073336Z

Conversation

@CBOSSX

@CBOSSX CBOSSX commented Aug 14, 2026

Copy link
Copy Markdown

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=1 exited 1

  • After: go test ./internal/einomcp -run TestToolInfoFromDefinitionSanitizesOpenAIToolName -count=1 exited 0

Verification

  • go test ./...
  • go vet ./internal/einomcp
  • test -z "$(gofmt -l internal/einomcp/mcp_tools.go internal/einomcp/mcp_tools_test.go)"

Scope

  • 2 files changed, +58 / -9 lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant