Skip to content

Sanitize MCP server names containing whitespace#174

Merged
benbrandt merged 1 commit intozed-industries:mainfrom
zerone0x:fix/mcp-sanitize-name-whitespace
Mar 5, 2026
Merged

Sanitize MCP server names containing whitespace#174
benbrandt merged 1 commit intozed-industries:mainfrom
zerone0x:fix/mcp-sanitize-name-whitespace

Conversation

@zerone0x
Copy link
Copy Markdown
Contributor

@zerone0x zerone0x commented Mar 4, 2026

Summary

Fixes #55

When an MCP server name contains spaces (or other whitespace), Codex fails to initialize it because the server name is used as a key that must not contain whitespace.

This PR sanitizes MCP server names in the adapter layer by replacing each whitespace character with an underscore before the name is passed to Codex. The fix is applied to both HTTP and Stdio server types.

Changes

  • src/codex_agent.rs: Replace whitespace in MCP server names with underscores for both McpServer::Http and McpServer::Stdio variants.

🤖 Generated with Claude Code

Codex does not allow whitespace in MCP server names. When an MCP server
is configured with a name containing spaces or other whitespace characters,
the adapter now replaces each whitespace character with an underscore before
passing the name to Codex.

Fixes zed-industries#55

Co-Authored-By: Claude <noreply@anthropic.com>
@benbrandt benbrandt merged commit 678a99e into zed-industries:main Mar 5, 2026
10 checks passed
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.

Codex fails to initialize MCP server when name contains whitespace

2 participants