Replace FastMCP.as_proxy() with create_proxy() function#2829
Conversation
The classmethod always returned FastMCPProxy (not Self), so a standalone function is more honest about what it does. Deprecates as_proxy() with a warning that forwards to the new function. New API: - create_proxy() from fastmcp.server (most users) - create_proxy_provider() from fastmcp.server.providers.proxy (advanced)
|
Warning Rate limit exceeded@jlowin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 32 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
WalkthroughThis PR adds a top-level factory function Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
docs/servers/providers/proxy.mdx (1)
196-197: Optional: Minor formatting consideration.Line 197 appears to be a blank line added after the import statement. While this doesn't affect functionality, verify that the extra whitespace is intentional for readability or if it's an artifact.
src/fastmcp/server/providers/proxy.py (2)
607-610: Consider using warning level for context mixing message.The message about context mixing in concurrent scenarios is logged at
infolevel, but this describes a potential issue that users should be aware of. Consider usinglogger.warning()instead to make it more prominent.💡 Suggested change
- logger.info( + logger.warning( "Proxy detected connected client - reusing existing session for all requests. " "This may cause context mixing in concurrent scenarios." )
622-629: Consider more specific type handling instead ofcast(Any, ...).The
cast(Any, target)on line 624 bypasses type safety completely. While the logic is correct (all remaining types are valid forProxyClient), this cast is overly broad and could hide future type issues.Consider using a more specific cast or a
# type: ignore[arg-type]comment with explanation.♻️ Suggested alternative
else: # target is not a Client, so it's compatible with ProxyClient.__init__ - base_client = ProxyClient(cast(Any, target)) + base_client = ProxyClient(target) # type: ignore[arg-type] def proxy_client_factory() -> Client: return base_client.new()
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
tests/server/providers/proxy/__init__.pyis excluded by none and included by nonetests/server/providers/proxy/test_proxy_client.pyis excluded by none and included by nonetests/server/providers/proxy/test_proxy_server.pyis excluded by none and included by nonetests/server/providers/proxy/test_stateful_proxy_client.pyis excluded by none and included by none
📒 Files selected for processing (12)
docs/development/v3-notes/v3-features.mdxdocs/integrations/claude-desktop.mdxdocs/servers/providers/mounting.mdxdocs/servers/providers/overview.mdxdocs/servers/providers/proxy.mdxdocs/servers/server.mdxsrc/fastmcp/cli/run.pysrc/fastmcp/client/transports.pysrc/fastmcp/mcp_config.pysrc/fastmcp/server/__init__.pysrc/fastmcp/server/providers/proxy.pysrc/fastmcp/server/server.py
🧰 Additional context used
📓 Path-based instructions (4)
docs/**/*.mdx
📄 CodeRabbit inference engine (docs/.cursor/rules/mintlify.mdc)
docs/**/*.mdx: Use clear, direct language appropriate for technical audiences
Write in second person ('you') for instructions and procedures in MDX documentation
Use active voice over passive voice in MDX technical documentation
Employ present tense for current states and future tense for outcomes in MDX documentation
Maintain consistent terminology throughout all MDX documentation
Keep sentences concise while providing necessary context in MDX documentation
Use parallel structure in lists, headings, and procedures in MDX documentation
Lead with the most important information using inverted pyramid structure in MDX documentation
Use progressive disclosure in MDX documentation: present basic concepts before advanced ones
Break complex procedures into numbered steps in MDX documentation
Include prerequisites and context before instructions in MDX documentation
Provide expected outcomes for each major step in MDX documentation
End sections with next steps or related information in MDX documentation
Use descriptive, keyword-rich headings for navigation and SEO in MDX documentation
Focus on user goals and outcomes rather than system features in MDX documentation
Anticipate common questions and address them proactively in MDX documentation
Include troubleshooting for likely failure points in MDX documentation
Provide multiple pathways (beginner vs advanced) but offer an opinionated path to avoid overwhelming users in MDX documentation
Always include complete, runnable code examples that users can copy and execute in MDX documentation
Show proper error handling and edge case management in MDX code examples
Use realistic data instead of placeholder values in MDX code examples
Include expected outputs and results for verification in MDX code examples
Test all code examples thoroughly before publishing in MDX documentation
Specify language and include filename when relevant in MDX code examples
Add explanatory comments for complex logic in MDX code examples
Document all API...
Files:
docs/development/v3-notes/v3-features.mdxdocs/servers/providers/overview.mdxdocs/servers/providers/mounting.mdxdocs/servers/server.mdxdocs/servers/providers/proxy.mdxdocs/integrations/claude-desktop.mdx
docs/**/*.{md,mdx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Documentation uses Mintlify framework. Files must be in docs.json to be included. Never modify docs/python-sdk/** (auto-generated)
Files:
docs/development/v3-notes/v3-features.mdxdocs/servers/providers/overview.mdxdocs/servers/providers/mounting.mdxdocs/servers/server.mdxdocs/servers/providers/proxy.mdxdocs/integrations/claude-desktop.mdx
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (AGENTS.md)
docs/**/*.{md,mdx}: Code examples in documentation must explain before showing code and make blocks fully runnable (include imports)
Documentation structure: Headers form navigation guide with logical H2/H3 hierarchy. Content should be user-focused with sections motivating features (why) before mechanics (how). Use prose over code comments for important information
Never use 'This isn't...' or 'not just...' constructions in writing - state what something IS directly. Avoid defensive writing patterns
Files:
docs/development/v3-notes/v3-features.mdxdocs/servers/providers/overview.mdxdocs/servers/providers/mounting.mdxdocs/servers/server.mdxdocs/servers/providers/proxy.mdxdocs/integrations/claude-desktop.mdx
src/fastmcp/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
src/fastmcp/**/*.py: Python ≥ 3.10 with full type annotations required
Prioritize readable, understandable code - clarity over cleverness. Avoid obfuscated or confusing patterns even if shorter
Follow existing patterns and maintain consistency in code implementation
Be intentional about re-exports - don't blindly re-export everything to parent namespaces. Core types defining a module's purpose should be exported. Specialized features can live in submodules. Only re-export to fastmcp.* for most fundamental types
Never use bare except - be specific with exception types
Files:
src/fastmcp/cli/run.pysrc/fastmcp/server/providers/proxy.pysrc/fastmcp/server/__init__.pysrc/fastmcp/client/transports.pysrc/fastmcp/mcp_config.pysrc/fastmcp/server/server.py
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: jlowin/fastmcp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-25T15:53:07.656Z
Learning: Applies to tests/**/*.py : Pass FastMCP servers directly to clients for testing without network complexity; only use HTTP transport when explicitly testing network features
📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR
Repo: jlowin/fastmcp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-25T15:53:07.656Z
Learning: Applies to tests/**/*.py : Pass FastMCP servers directly to clients for testing without network complexity; only use HTTP transport when explicitly testing network features
Applied to files:
docs/development/v3-notes/v3-features.mdxsrc/fastmcp/cli/run.pydocs/servers/server.mdxdocs/servers/providers/proxy.mdxsrc/fastmcp/server/providers/proxy.pydocs/integrations/claude-desktop.mdxsrc/fastmcp/server/__init__.pysrc/fastmcp/client/transports.pysrc/fastmcp/mcp_config.py
📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR
Repo: jlowin/fastmcp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-25T15:53:07.656Z
Learning: Applies to src/fastmcp/**/*.py : Be intentional about re-exports - don't blindly re-export everything to parent namespaces. Core types defining a module's purpose should be exported. Specialized features can live in submodules. Only re-export to fastmcp.* for most fundamental types
Applied to files:
src/fastmcp/cli/run.pydocs/integrations/claude-desktop.mdxsrc/fastmcp/server/__init__.pysrc/fastmcp/client/transports.pysrc/fastmcp/mcp_config.pysrc/fastmcp/server/server.py
📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR
Repo: jlowin/fastmcp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-25T15:53:07.656Z
Learning: Applies to src/fastmcp/**/*.py : Python ≥ 3.10 with full type annotations required
Applied to files:
src/fastmcp/cli/run.pysrc/fastmcp/server/providers/proxy.pysrc/fastmcp/server/__init__.pysrc/fastmcp/mcp_config.py
📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR
Repo: jlowin/fastmcp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-25T15:53:07.656Z
Learning: Applies to src/fastmcp/**/*.py : Follow existing patterns and maintain consistency in code implementation
Applied to files:
src/fastmcp/mcp_config.py
🧬 Code graph analysis (3)
src/fastmcp/cli/run.py (1)
src/fastmcp/server/server.py (2)
FastMCP(194-2573)create_proxy(2581-2630)
src/fastmcp/server/providers/proxy.py (3)
src/fastmcp/client/transports.py (1)
ClientTransport(85-127)src/fastmcp/client/client.py (3)
Client(129-1722)is_connected(393-395)new(397-423)src/fastmcp/server/server.py (1)
FastMCP(194-2573)
src/fastmcp/client/transports.py (1)
src/fastmcp/server/server.py (2)
FastMCP(194-2573)create_proxy(2581-2630)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: label-issue-or-pr
- GitHub Check: Run tests: Python 3.10 on windows-latest
- GitHub Check: Run tests: Python 3.10 on ubuntu-latest
- GitHub Check: Run tests with lowest-direct dependencies
- GitHub Check: Run tests: Python 3.13 on ubuntu-latest
🔇 Additional comments (26)
docs/servers/providers/overview.mdx (1)
40-40: LGTM - Documentation updated correctly.The ProxyProvider usage documentation now correctly references
create_proxy(client)instead of the deprecatedFastMCP.as_proxy(client), aligning with the new API.docs/development/v3-notes/v3-features.mdx (1)
49-56: LGTM - ProxyProvider documentation updated correctly.The documentation now accurately reflects the new
create_proxy()API, including updated imports and usage examples. The example is complete and runnable as required by the MDX guidelines.src/fastmcp/server/__init__.py (1)
2-2: LGTM - Appropriate re-export of core functionality.The
create_proxyfunction is correctly re-exported at thefastmcp.serverpackage level. This is appropriate since it's replacing the previousFastMCP.as_proxy()classmethod and is positioned as the primary API for proxy creation.Based on learnings, this re-export is justified as core functionality for the server module.
Also applies to: 6-6
src/fastmcp/cli/run.py (3)
15-15: LGTM - Import updated correctly.The import now includes
create_proxyfromfastmcp.server.server. While the public API re-exports this infastmcp.server.__init__, importing directly from the implementation module is consistent with the existing pattern forFastMCPon the same line.
48-48: LGTM - Correctly migrated to new API.The proxy creation now uses
create_proxy(client)instead of the deprecatedFastMCP.as_proxy(client).
60-60: LGTM - Correctly migrated to new API.The MCP config proxy creation now uses
create_proxy(mcp_config)instead of the deprecatedFastMCP.as_proxy(mcp_config).docs/servers/providers/mounting.mdx (1)
148-152: LGTM - Clear deprecation notice with migration path.The deprecation warning clearly communicates that the
as_proxyparameter is deprecated and directs users to the newcreate_proxy()function fromfastmcp.server. The explanation of the new default behavior is clear and follows MDX documentation guidelines.src/fastmcp/mcp_config.py (2)
102-102: LGTM: Import update aligns with new API.The import correctly references
create_proxyfromfastmcp.server, consistent with the module-level function introduced in this PR.
109-115: LGTM: Proxy creation correctly migrated to new API.The usage correctly transitions from
FastMCP.as_proxy(backend=client, ...)tocreate_proxy(client, ...), passing the client as the first positional argument and preserving all configuration parameters.docs/servers/server.mdx (3)
291-291: LGTM: Documentation correctly references the new API.The text accurately describes the new
create_proxyfunction for proxying MCP servers.
298-299: LGTM: Imports correctly updated for new API.The example imports
Clientandcreate_proxyfrom their correct modules, aligning with the new proxy creation pattern.
302-302: LGTM: Example correctly demonstrates new API usage.The example properly shows
create_proxy(backend, name="ProxyServer")with the backend passed as a positional argument.docs/integrations/claude-desktop.mdx (2)
266-272: LGTM: Basic proxy example correctly demonstrates new API.The example clearly shows
create_proxyaccepting a URL string directly, which is a convenient pattern supported by the new function signature.
283-294: LGTM: Authenticated proxy example correctly demonstrates client-based proxy creation.The example properly shows creating an authenticated client and passing it to
create_proxy, demonstrating the recommended pattern for authenticated remote proxies.src/fastmcp/client/transports.py (2)
46-46: LGTM: Import correctly adds create_proxy alongside FastMCP.The import appropriately includes both
FastMCP(still needed forFastMCPTransport) and the newcreate_proxyfunction.
1038-1044: LGTM: Proxy creation correctly updated in MCPConfigTransport.The method properly migrates to
create_proxy(client, ...), passing theProxyClientas the first positional argument and preserving all configuration parameters for tool transformations and tag filtering.docs/servers/providers/proxy.mdx (3)
39-53: LGTM: Quick Start section accurately demonstrates new proxy creation API.The section correctly shows the new pattern:
- Importing
create_proxyfromfastmcp.server- Importing
ProxyClientfromfastmcp.server.providers.proxy- Creating a proxy with
create_proxy(ProxyClient(...), name="...")The example is clear and follows best practices.
269-306: LGTM: New Advanced Usage section provides valuable patterns.The section appropriately documents advanced patterns:
- Direct FastMCPProxy usage with custom
client_factoryfor fine-grained session control- Using
create_proxy_provider()to add proxied components to existing serversBoth examples have correct imports and demonstrate legitimate use cases. The section helps users understand when to use lower-level APIs versus the convenience function.
65-254: LGTM: All examples consistently demonstrate the new API.Throughout the document, examples correctly show
create_proxyusage with various target types:
ProxyClientinstances for isolated sessions- Connected
Clientinstances for shared sessions- URL strings for direct remote connections
- Configuration dicts for multi-server proxies
The consistency and variety of examples effectively demonstrate the flexibility of the new API.
src/fastmcp/server/server.py (4)
27-27: LGTM - Type import addition.The
overloadimport is correctly added to support type annotations for the newcreate_proxy()function.
281-282: LGTM - Deprecation messaging updated.The updated deprecation messages correctly guide users to the new
create_proxy()API.Also applies to: 308-308
2547-2564: LGTM - Proper deprecation ofas_proxy().The classmethod is correctly deprecated with clear messaging and delegates to the new
create_proxy()function while maintaining backward compatibility.
2581-2630: LGTM - Well-designed module-level factory function.The
create_proxy()function provides a clean, well-documented API for proxy creation. The implementation correctly delegates to the internal_create_client_factory()helper, maintaining good separation of concerns.src/fastmcp/server/providers/proxy.py (3)
56-56: LGTM - Type import addition.The
ClientTransportimport is correctly placed underTYPE_CHECKINGto support type annotations without runtime overhead.
632-679: LGTM - Well-designed public factory function.The
create_proxy_provider()function provides a clean API for creating proxy providers. The implementation correctly delegates to_create_client_factory()and includes comprehensive documentation with examples.
694-714: LGTM - Documentation properly updated.The
FastMCPProxydocstring and examples correctly guide users to the newcreate_proxy()function while still documenting direct construction for advanced scenarios.
Test Failure AnalysisSummary: Tests are failing due to a merge conflict with . The PR removes the Root Cause: This PR branch was created before PR #2828 ("Add composable lifespans") was merged to
This creates a Suggested Solution: Rebase this PR branch on the latest
The rebased version will keep this PR's simpler Detailed AnalysisError Log ExcerptCode Comparisonmain branch (line 27): from typing import TYPE_CHECKING, Any, Generic, Literal, cast, overloadmain branch (lines 285-289): # Handle Lifespan instances (they're callable) or regular lifespan functions
if lifespan is not None:
self._lifespan: LifespanCallable[LifespanResultT] = lifespan
else:
self._lifespan = cast(LifespanCallable[LifespanResultT], default_lifespan)This PR branch (line 27): from typing import TYPE_CHECKING, Any, Generic, Literal, overload # cast removedThis PR branch (lines 284-289): self._lifespan: LifespanCallable[LifespanResultT] = lifespan or default_lifespan
self._lifespan_result: LifespanResultT | None = None
self._lifespan_result_set: bool = False
self._started: asyncio.Event = asyncio.Event()Merged result (what CI tests): # Line 27: cast import removed (from this PR)
from typing import TYPE_CHECKING, Any, Generic, Literal, overload
# Lines 285-289: Uses cast() from main, but cast not imported!
if lifespan is not None:
self._lifespan: LifespanCallable[LifespanResultT] = lifespan
else:
self._lifespan = cast(LifespanCallable[LifespanResultT], default_lifespan)Related Files
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/servers/providers/proxy.mdx (1)
150-159: Add import statement for completeness.The code example lacks the required import for
ProxyClient. As per coding guidelines, code blocks should be fully runnable with imports included.Proposed fix
Selectively disable forwarding: ```python +from fastmcp.server.providers.proxy import ProxyClient + backend = ProxyClient( "backend_server.py", sampling_handler=None, # Disable LLM sampling log_handler=None # Disable log forwarding )</details> </blockquote></details> </blockquote></details>📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/server/providers/proxy/test_proxy_server.pyis excluded by none and included by none📒 Files selected for processing (4)
docs/servers/providers/mounting.mdxdocs/servers/providers/proxy.mdxsrc/fastmcp/server/providers/proxy.pysrc/fastmcp/server/server.py🚧 Files skipped from review as they are similar to previous changes (1)
- docs/servers/providers/mounting.mdx
🧰 Additional context used
📓 Path-based instructions (4)
src/fastmcp/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
src/fastmcp/**/*.py: Python ≥ 3.10 with full type annotations required
Prioritize readable, understandable code - clarity over cleverness. Avoid obfuscated or confusing patterns even if shorter
Follow existing patterns and maintain consistency in code implementation
Be intentional about re-exports - don't blindly re-export everything to parent namespaces. Core types defining a module's purpose should be exported. Specialized features can live in submodules. Only re-export to fastmcp.* for most fundamental types
Never use bare except - be specific with exception typesFiles:
src/fastmcp/server/server.pysrc/fastmcp/server/providers/proxy.pydocs/**/*.mdx
📄 CodeRabbit inference engine (docs/.cursor/rules/mintlify.mdc)
docs/**/*.mdx: Use clear, direct language appropriate for technical audiences
Write in second person ('you') for instructions and procedures in MDX documentation
Use active voice over passive voice in MDX technical documentation
Employ present tense for current states and future tense for outcomes in MDX documentation
Maintain consistent terminology throughout all MDX documentation
Keep sentences concise while providing necessary context in MDX documentation
Use parallel structure in lists, headings, and procedures in MDX documentation
Lead with the most important information using inverted pyramid structure in MDX documentation
Use progressive disclosure in MDX documentation: present basic concepts before advanced ones
Break complex procedures into numbered steps in MDX documentation
Include prerequisites and context before instructions in MDX documentation
Provide expected outcomes for each major step in MDX documentation
End sections with next steps or related information in MDX documentation
Use descriptive, keyword-rich headings for navigation and SEO in MDX documentation
Focus on user goals and outcomes rather than system features in MDX documentation
Anticipate common questions and address them proactively in MDX documentation
Include troubleshooting for likely failure points in MDX documentation
Provide multiple pathways (beginner vs advanced) but offer an opinionated path to avoid overwhelming users in MDX documentation
Always include complete, runnable code examples that users can copy and execute in MDX documentation
Show proper error handling and edge case management in MDX code examples
Use realistic data instead of placeholder values in MDX code examples
Include expected outputs and results for verification in MDX code examples
Test all code examples thoroughly before publishing in MDX documentation
Specify language and include filename when relevant in MDX code examples
Add explanatory comments for complex logic in MDX code examples
Document all API...Files:
docs/servers/providers/proxy.mdxdocs/**/*.{md,mdx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Documentation uses Mintlify framework. Files must be in docs.json to be included. Never modify docs/python-sdk/** (auto-generated)
Files:
docs/servers/providers/proxy.mdxdocs/**/*.{md,mdx}
📄 CodeRabbit inference engine (AGENTS.md)
docs/**/*.{md,mdx}: Code examples in documentation must explain before showing code and make blocks fully runnable (include imports)
Documentation structure: Headers form navigation guide with logical H2/H3 hierarchy. Content should be user-focused with sections motivating features (why) before mechanics (how). Use prose over code comments for important information
Never use 'This isn't...' or 'not just...' constructions in writing - state what something IS directly. Avoid defensive writing patternsFiles:
docs/servers/providers/proxy.mdx🧠 Learnings (3)
📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR Repo: jlowin/fastmcp PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-12-25T15:53:07.656Z Learning: Applies to src/fastmcp/**/*.py : Be intentional about re-exports - don't blindly re-export everything to parent namespaces. Core types defining a module's purpose should be exported. Specialized features can live in submodules. Only re-export to fastmcp.* for most fundamental typesApplied to files:
src/fastmcp/server/server.py📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR Repo: jlowin/fastmcp PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-12-25T15:53:07.656Z Learning: Applies to tests/**/*.py : Pass FastMCP servers directly to clients for testing without network complexity; only use HTTP transport when explicitly testing network featuresApplied to files:
src/fastmcp/server/server.pydocs/servers/providers/proxy.mdxsrc/fastmcp/server/providers/proxy.py📚 Learning: 2025-12-25T15:53:07.656Z
Learnt from: CR Repo: jlowin/fastmcp PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-12-25T15:53:07.656Z Learning: Applies to src/fastmcp/**/*.py : Python ≥ 3.10 with full type annotations requiredApplied to files:
src/fastmcp/server/providers/proxy.py🧬 Code graph analysis (1)
src/fastmcp/server/server.py (1)
src/fastmcp/server/providers/proxy.py (2)
FastMCPProxy(637-679)_create_client_factory(584-629)⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run tests: Python 3.13 on ubuntu-latest
- GitHub Check: Run tests: Python 3.10 on ubuntu-latest
- GitHub Check: Run tests: Python 3.10 on windows-latest
- GitHub Check: Run tests with lowest-direct dependencies
🔇 Additional comments (11)
src/fastmcp/server/providers/proxy.py (3)
53-56: LGTM!The
TYPE_CHECKINGimport forClientTransportis correctly added to support the type annotation in_create_client_factorywithout causing a runtime import cycle.
645-665: LGTM!The updated docstrings correctly guide users toward
create_proxy()as the recommended approach while documentingFastMCPProxyfor advanced use cases requiring explicit session control.
584-629: Well-structured factory helper with appropriate session strategies.The three-way branching logic correctly handles:
- Connected clients → session reuse with appropriate warning
- Disconnected clients → fresh sessions via
client.new()- Other targets → ProxyClient wrapper with fresh sessions
The closures properly capture client references, type annotations are comprehensive, and the
is_connected()check is implemented correctly in the Client class.src/fastmcp/server/server.py (4)
2281-2282: LGTM!The docstring correctly directs users to use
create_proxy()explicitly before mounting when they need proxy behavior.
2304-2311: LGTM!The deprecation warning message is consistent with the docstring and provides clear migration guidance.
2547-2564: LGTM!The deprecation implementation follows the codebase's established pattern:
- Conditional warning based on
fastmcp.settings.deprecation_warnings- Correct
stacklevel=2for classmethod context- Clean delegation to
create_proxy()maintaining backward compatibility
2624-2629: LGTM!The local import correctly avoids circular dependencies, and the implementation cleanly delegates to
_create_client_factorybefore constructing the proxy.docs/servers/providers/proxy.mdx (4)
39-49: LGTM!The Quick Start example is clear, concise, and demonstrates the recommended
create_proxy()usage with the correct import path.
91-122: LGTM!The session isolation documentation clearly explains both the default fresh-session behavior and the shared-session scenario with appropriate warnings.
261-298: LGTM!The Advanced Usage section is well-structured:
- Correctly shows the import path for
FastMCPProxyandProxyClient- The new "Adding Proxied Components" subsection provides a practical example of the mounting pattern
- Follows the progressive disclosure principle from the coding guidelines
124-148: LGTM!The feature forwarding documentation clearly explains what MCP features are automatically proxied and provides a concise example.
FastMCP.as_proxy()was a classmethod that always returnedFastMCPProxy, notSelf. A standalone function better reflects what it actually does and simplifies the API.FastMCP.as_proxy()is deprecated but continues to work, forwarding tocreate_proxy().Also adds a new "Mounting External Servers" section to the docs showing how to mount npm/uvx packages and remote servers.