Streamable MCP run normally and return results, but soon get unexpected status 400 Bad Request error

Open 💬 3 comments Opened Nov 12, 2025 by zxzxzxzzy0119

What version of Codex is running?

0.57.0

What subscription do you have?

use azure api Key, model = "gpt-5-codex" model_provider = "azure"

Which model were you using?

gpt-5-codex, azure

What platform is your computer?

windows 11 wsl

What issue are you seeing?

The configuration in config.toml is as follows:

[mcp_servers.mymcp]
url = "http://ip:port/sse"
http_headers = { "live" = "true", "user" = "tom" }

MCP can run normally and return results, but soon messages like
Reconnecting... 1/5, Reconnecting... 2/5, Reconnecting... 3/5, Reconnecting... 4/5, Reconnecting... 5/5
appear, followed by the following error:

unexpected status 400 Bad Request: {
"error": {
"message": "Invalid 'input[3].name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.",
"type": "invalid_request_error",
"param": "input[3].name",
"code": "invalid_value"
}
}

What steps can reproduce the bug?

config.toml

[mcp_servers.mymcp]
url = "http://ip:port/sse"
http_headers = { "live" = "true", "user" = "tom" }

then call mcp server in prompt

What is the expected behavior?

_No response_

Additional information

Normal Q&A、coding works fine, but this problem occurs when using the MCP server.

View original on GitHub ↗

3 Comments

zxzxzxzzy0119 · 9 months ago

0.58.0 also have this problem, error info:

■ unexpected status 400 Bad Request: { "error": { "message": "Invalid 'input[4].name': string does not match pattern. Expected a string that matches the pattern '^[a- zA-Z0-9_-]+$'.", "type": "invalid_request_error", "param": "input[4].name", "code": "invalid_value" } }

illanes00 · 7 months ago

I was able to reproduce this on a VPS with a recorded session whose transcript contains tool calls with names that include '.' (e.g. functions.exec_command, legacy container.exec). When Codex sends that history back to the OpenAI Responses API, the request fails with a 400:

'Invalid 'input[N].name': string does not match pattern '^[a-zA-Z0-9_-]+$'

I opened PR #9447 to address this by normalizing tool call names in the transcript before sending request history (and in compaction payloads too):

  • container.exec -> shell
  • strip namespace prefixes like functions. when the suffix matches a known tool
  • otherwise sanitize invalid chars to '_'

Includes unit tests + manual verification via resuming the failing session (no more input[*].name validation error).

yoavram · 7 months ago

I'm also getting a similar error, I don't know why it's happening, but it has something to do with tool/mcp:
{
"error": {
"message": "Invalid 'input[25].name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.",
"type": "invalid_request_error",
"param": "input[25].name",
"code": "invalid_value"
}
}
what should I do? I see that the PR #9447 was closed.

What version of Codex is running?

codex-cli 0.91.0

What subscription do you have?

OpenAI Edu

Which model were you using?

gpt-5.2-codex Medium

What platform is your computer?

MacOS 26.2 (25C56) Apple M4 Pro

Additional information

MCP servers
tooluniverse 1.0.16
Zotero MCP v0.1.2