Add OpenAI-compatible tool name normalization for MCP tools#30
Merged
Add OpenAI-compatible tool name normalization for MCP tools#30
Conversation
…e configuration and testing Co-authored-by: pardeike <853584+pardeike@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] The codex CLI registers every MCP tool directly as an OpenAI tool. The dotted MCP name fails the API validator, and the request is rejected. The model choice is irrelevant; validation happens before sampling.
Fix: normalize names before they reach Open...
Add OpenAI-compatible tool name normalization for MCP tools
Sep 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The codex CLI registers MCP tools directly as OpenAI tools, but OpenAI's API validator rejects tool names containing dots (
.) which are commonly used in MCP tool names likeminecraft.inventory.getorgames.list. This causes validation errors before the request even reaches the model, making it impossible to use GABS tools through OpenAI-compatible clients.Solution
Added configurable tool name normalization that automatically converts MCP tool names to OpenAI-compatible format while preserving the original names for reference.
Key Features
Smart Normalization Algorithm:
minecraft.inventory.get→minecraft_inventory_getgame.player@stats#get!→game_player_stats_gettool_prefix if needed)Configurable via GABS config:
{ "toolNormalization": { "enableOpenAINormalization": true, "maxToolNameLength": 64, "preserveOriginalName": true } }Original Name Preservation:
_meta.originalName)Backward Compatibility:
RegisterToolWithConfig()method supports normalizationRegisterTool()method preserved for compatibilityExample Transformations
games.listgames_listminecraft.inventory.getminecraft_inventory_getrimworld.crafting.build_advanced_componentrimworld_crafting_build_advanced_componentvery.long.tool.name.that.exceeds.limitvery_long_tool_name_that_exceedsImplementation Details
internal/util/tool_normalization.gointernal/config/games.gointernal/mcp/stdio_server.gointernal/mirror/mirror.gonormalized tool name for OpenAI compatibility original=games.list normalized=games_listUsage
Enable in your GABS configuration:
{ "version": "1.0", "toolNormalization": { "enableOpenAINormalization": true }, "games": { // ... your games } }The codex CLI (and other OpenAI-compatible clients) will now receive tool names like
games_listandminecraft_inventory_getthat pass OpenAI's validation, while the original dotted names are preserved in metadata for display purposes.Fixes the core issue where MCP tools were unusable with OpenAI API due to naming restrictions.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.