fix: accept both 'tool' and 'tool_name' on /v1/mcp/execute#1285
Merged
jundot merged 1 commit intoMay 19, 2026
Merged
Conversation
Various MCP clients send either `tool` or `tool_name` to specify the tool to invoke. omlx accepted `tool_name` only and rejected `tool`, breaking parity with the spec drift seen across clients. Accept both field names with `tool_name` taking precedence when both are present. Fixes jundot#1113
Owner
|
Thanks! Clean use of |
jundot
added a commit
that referenced
this pull request
May 19, 2026
Follow-up to #1285. Adds the three cases the PR body promised but did not land: tool_name happy path, tool_name precedence when both fields are present, and 422 when neither is supplied.
cfbraun
added a commit
to cfbraun/omlx
that referenced
this pull request
May 22, 2026
omlx/api/mcp_routes.py was wired into server.py at module init but had zero direct test coverage — test_mcp_*.py files exercised the manager and executor layers but not the FastAPI handlers, leaving the request parsing, no-manager fallbacks, and the tool/tool_name alias (upstream PR jundot#1285) unguarded. 15 tests via TestClient covering all four entry points: - set_mcp_manager_getter wiring + None propagation - GET /v1/mcp/tools: empty-list short-circuit, namespaced full_name serialization - GET /v1/mcp/servers: enum-to-string flattening, error-field passthrough - POST /v1/mcp/execute: 503 when unconfigured, success / handled-error paths, tool-vs-tool_name alias regression guard, default-arguments fallback, 422 on missing tool name The autouse fixture resets the module-global `_get_mcp_manager` callback between tests so state can't leak across cases.
cfbraun
added a commit
to cfbraun/omlx
that referenced
this pull request
May 26, 2026
omlx/api/mcp_routes.py was wired into server.py at module init but had zero direct test coverage — test_mcp_*.py files exercised the manager and executor layers but not the FastAPI handlers, leaving the request parsing, no-manager fallbacks, and the tool/tool_name alias (upstream PR jundot#1285) unguarded. 15 tests via TestClient covering all four entry points: - set_mcp_manager_getter wiring + None propagation - GET /v1/mcp/tools: empty-list short-circuit, namespaced full_name serialization - GET /v1/mcp/servers: enum-to-string flattening, error-field passthrough - POST /v1/mcp/execute: 503 when unconfigured, success / handled-error paths, tool-vs-tool_name alias regression guard, default-arguments fallback, 422 on missing tool name The autouse fixture resets the module-global `_get_mcp_manager` callback between tests so state can't leak across cases.
Contributor
Author
|
Cheers @jundot - thanks for landing the dual field-name acceptance so MCP clients on either side of the tool/tool_name split stop seeing 422s. |
1 task
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.
Summary
Two camps of MCP clients send the target tool as either
toolortool_namein the/v1/mcp/executepayload. omlx acceptedtool_nameonly, so clients sendingtoolgot a 422 even though their request was otherwise valid. Accepts both field names, withtool_nametaking precedence when both are present.Why this matters
#1113 reports the field-name drift; the workaround is a wrapper that rewrites the field, which is friction for every new client. Aligns omlx with the de-facto behavior across MCP servers.
Changes
omlx/api/openai_models.py- accept either field on the MCP execute model.tests/integration/test_server_endpoints.py- tests coveringtool-only,tool_name-only, both-present (precedence), and neither (still rejects).Testing
New integration tests + existing endpoint tests pass locally.
Fixes #1113