Repository navigation
fix(cli): forward path, stateless and log-level to SDK MCPServer servers - #5870
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e70ee99ba8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| path: str | None = None, | ||
| stateless: bool = False, | ||
| log_level: LogLevelType | None = None, | ||
| transport: TransportType | None = None, |
There was a problem hiding this comment.
Keep transport before the new optional parameters
When a caller uses the documented positional form run_v1_server_async(server, host, port, "sse") (the published signature in docs/python-sdk/fastmcp-cli-run.mdx:107-110 exposes transport as argument four), this insertion now binds "sse" to path and leaves transport as None, so the helper starts streamable HTTP instead of SSE. Keep transport in its existing positional slot and append the new options after it, or make only the new options keyword-only.
Useful? React with 👍 / 👎.
When the loaded server is the SDK's MCPServer (v1), run_command called run_v1_server_async without the parsed path, stateless and log_level options, so HTTP served /mcp statefully, SSE served /sse, and the log level was dropped. Thread the options through and map them to the SDK transport kwargs: streamable_http_path/stateless_http for HTTP, sse_path for SSE, and server.settings.log_level for the log level (the SDK has no run-time log_level kwarg; its HTTP runners read settings.log_level).
Inserting path/stateless/log_level ahead of transport broke the documented positional call run_v1_server_async(server, host, port, "sse"): "sse" bound to path and the server started Streamable HTTP instead of SSE. Move transport back to slot four, append the new options after it, and add a regression test for the documented positional form.
e70ee99 to
20b90dd
Compare
* fix: keep additionalProperties on object schemas without a type (#6127) Fixes #6124. Co-authored-by: Alperen Keleş <[email protected]> (cherry picked from commit 2a8f333) * Fix hydration of mutually recursive schema types (#6394) Fixes #6135. Supersedes #6137. Co-authored-by: wozhenbang2004 <[email protected]> Co-authored-by: Alperen Keleş <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 0d7bb12) * Isolate filesystem component construction failures (#6210) Fixes #6209. (cherry picked from commit f911b58) * fix(config): apply tool transforms before tag filters on single servers (#6214) Fixes #6196. Co-authored-by: arjunprabhulal <[email protected]> (cherry picked from commit 02c121c) * fix(tools): isolate mutable defaults in transformed tool calls (#6184) Fixes #6183. (cherry picked from commit b25a1c5) * fix(openapi): make resource templates for non-identifier path parameters readable (#6187) Fixes #6150. Co-authored-by: alpaylan <[email protected]> (cherry picked from commit 63f5718) * Keep constraints on scalar schema references (#6041) Fixes #6042. (cherry picked from commit e5176c9) * Document that a custom httpx_client_factory owns its timeout (#5923) Fixes #5922. (cherry picked from commit c9f64de) * Stop PingMiddleware erroring when the client has no back-channel (#5901) Fixes #5900. (cherry picked from commit 044a519) * Store sessionless client log levels on the connection (#5899) Fixes #5898. (cherry picked from commit c6e0c4d) * Register templated MCPMixin resources as resource templates (#5895) Fixes #5894. (cherry picked from commit 0c9f5f7) * Send the whole body when a body $ref with siblings cannot be flattened (#5893) Fixes #5892. (cherry picked from commit cad6074) * Pass the transport to the fastmcp-remote proxy so it forwards server-initiated requests (#5885) Fixes #5884. (cherry picked from commit 285dd4c) * fix(cli): forward path, stateless and log-level to SDK MCPServer servers (#5870) Fixes #5869. (cherry picked from commit 6dcec21) * fix(client): preserve a caller-provided OAuth httpx client factory when verify is set (#5849) Fixes #5848. (cherry picked from commit b7c6568) * fix(prompts): resolve postponed annotations when rendering (#5803) Fixes #5801. Co-authored-by: BlueX888 <[email protected]> (cherry picked from commit 3bf92a6) * Roll back the tool stamp when a tool registration is rejected (#5798) Fixes #5797. (cherry picked from commit d6566c5) * fix(openapi): hydrate data for wrapped non-object responses with validate_output=False (#5784) Fixes #5781. Co-authored-by: BlueX888 <[email protected]> (cherry picked from commit 6451faa) * Carry prompt argument titles through PromptArgument and proxies (#5749) Fixes #5748. (cherry picked from commit 288485c) * Relay the client's sampling result unchanged through proxies (#5747) Fixes #5746. (cherry picked from commit 19c349f) * fix(json-schema): keep x-unsupported-pattern when a format is set (#5731) Fixes #5729. (cherry picked from commit dc9849d) * fix(tasks): let async-generator tools run as background tasks (#5730) Fixes #5728. (cherry picked from commit c66e181) * Honor Code Mode search limits after BM25 ranking (#5715) Fixes #5712. Co-authored-by: BlueX888 <[email protected]> (cherry picked from commit ee71391) * Keep the client timeout from capping the HTTP read timeout (#5690) Fixes #5675. (cherry picked from commit bf95d12) * fix(auth): avoid rereading failed authorization forms (#5570) Fixes #5569. Co-authored-by: JordanAfolabiLaw <[email protected]> (cherry picked from commit e9f0443) * Fix unbounded Apps dev log retention (#5549) Fixes #5548. (cherry picked from commit 0a9a482) * Bound error-stat cardinality in ErrorHandlingMiddleware (#5537) Fixes #5536. (cherry picked from commit 089ff09) * fix(auth): preserve GitHub sessions across transient verification failures (#4881) Fixes #4854. Co-authored-by: benjohngf <[email protected]> (cherry picked from commit 3c6fbf7) * Expect the extended read timeout in the factory timeout test (#6395) Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit d8c4edf) * fix(auth): keep revocation ownership separate from user identity (#6404) Fixes #5800. Builds on #5807. Co-authored-by: BlueX888 <[email protected]> Co-authored-by: Luck <[email protected]> (cherry picked from commit cdec3a9) * Authenticate and pin the schema download in the OpenAPI performance test (#6177) Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit a66dd71) * Resolve deferred defaults by alias and keep unverified GitHub scopes out of the cache Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit e064736) * Revert "Roll back the tool stamp when a tool registration is rejected (#5798)" This reverts commit 36a1264. * Revert "Keep constraints on scalar schema references (#6041)" This reverts commit 1ffb3e6. * Revert "fix(json-schema): keep x-unsupported-pattern when a format is set (#5731)" This reverts commit 9da9835. --------- Co-authored-by: zgy <[email protected]> Co-authored-by: Alperen Keleş <[email protected]> Co-authored-by: wozhenbang2004 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: ppy <[email protected]> Co-authored-by: ayush <[email protected]> Co-authored-by: arjunprabhulal <[email protected]> Co-authored-by: Priyanshu Gupta <[email protected]> Co-authored-by: Shayan Ali <[email protected]> Co-authored-by: Asem ahmed <[email protected]> Co-authored-by: 哈基米 <[email protected]> Co-authored-by: Luck <[email protected]> Co-authored-by: Winoren <[email protected]> Co-authored-by: nosmile99 <[email protected]> Co-authored-by: Aarnav Noble <[email protected]> Co-authored-by: 一片一片 <[email protected]> Co-authored-by: Junpei Zhang <[email protected]> Co-authored-by: JordanAfolabiLaw <[email protected]> Co-authored-by: mika <[email protected]> Co-authored-by: sui-ni2 <[email protected]> Co-authored-by: benjohngf <[email protected]> Co-authored-by: Luck <[email protected]>
Closes #5869
Description
For SDK
MCPServer(v1) targets,fastmcp runaccepted--path,--statelessand--log-levelbut silently ignored them: the server ran on the SDK defaults (/mcp//sse) and stayed stateful. FastMCP-server behavior was unaffected.What changed
run_v1_server_asyncnow takespath,statelessandlog_level; the call site forwards the already-parsed values.streamable_http_path=pathandstateless_http=stateless; for SSE it passessse_path=path. Only non-None values are forwarded so SDK defaults are preserved when flags are absent.log_levelis applied through the SDK server's settings where supported; stdio has no SDK runtime lever and the limitation is documented in the function rather than faked.Contribution type
Bug fix verification
Test path:
tests/cli/test_run.py(v1 HTTP/SSE runner tests extended, plus new cases for path/stateless/log-level forwarding and defaults).Red at the base commit (implementation reverted, final tests applied): 6 failed, 57 passed, 1 skipped, all assertion failures (
assert_called_once_withmismatches;INFO != DEBUG), no collection errors.Green at the fix commit: 101 passed, 1 skipped across
tests/cli/test_run.py tests/cli/test_cli.py.Validation
uv run --isolated pytest tests/cli/test_run.py tests/cli/test_cli.py -q-> 101 passed, 1 skippeduv run --isolated pytest tests/cli --ignore=tests/cli/deploy -q-> 950 passed, 2 skipped (deploy excluded due to a pre-existing Windowsicaclshang)uv run --isolated ruff checkandruff format --checkon the changed files -> cleanuv run --isolated ty check-> All checks passedAI assistance
Tool(s) used: Claude Code
How you used it: investigated from a verified reproduction, implemented the option forwarding and the regression tests.
Checklist
uv run prek run --all-filesand all checks pass (focused checks passed)Review follow-up
Codex review noted that the new parameters were inserted before
transport, breaking the documented positional callrun_v1_server_async(server, host, port, "sse"). The signature now keepstransportin its original positional slot and appends the new options after it; a regression test pins the documented positional form.