Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/servers/proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ proxy = FastMCPProxy(client_factory=create_client)

### Parameters

- **`client`**: **[DEPRECATED]** A `Client` instance. Use `client_factory` instead for explicit session management.
- **`client_factory`**: A callable that returns a `Client` instance when called. This gives you full control over session creation and reuse strategies.

### Explicit Session Management
Expand Down
32 changes: 2 additions & 30 deletions src/fastmcp/server/proxy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import inspect
import warnings
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
Expand All @@ -20,7 +19,6 @@
)
from pydantic.networks import AnyUrl

import fastmcp
from fastmcp.client.client import Client, FastMCP1Server
from fastmcp.client.elicitation import ElicitResult
from fastmcp.client.logging import LogMessage
Expand Down Expand Up @@ -461,9 +459,8 @@ class FastMCPProxy(FastMCP):

def __init__(
self,
client: Client | None = None,
*,
client_factory: ClientFactoryT | None = None,
client_factory: ClientFactoryT,
**kwargs,
):
"""
Expand All @@ -473,9 +470,6 @@ def __init__(
Use FastMCP.as_proxy() for convenience with automatic session strategy.

Args:
client: [DEPRECATED] A Client instance. Use client_factory instead for explicit
session management. When provided, a client_factory will be automatically
created that provides session isolation for backwards compatibility.
client_factory: A callable that returns a Client instance when called.
This gives you full control over session creation and reuse.
Can be either a synchronous or asynchronous function.
Expand All @@ -484,29 +478,7 @@ def __init__(

super().__init__(**kwargs)

# Handle client and client_factory parameters
if client is not None and client_factory is not None:
raise ValueError("Cannot specify both 'client' and 'client_factory'")

if client is not None:
# Deprecated in 2.10.3
if fastmcp.settings.deprecation_warnings:
warnings.warn(
"Passing 'client' to FastMCPProxy is deprecated. Use 'client_factory' instead for explicit session management. "
"For automatic session strategy, use FastMCP.as_proxy().",
DeprecationWarning,
stacklevel=2,
)

# Create a factory that provides session isolation for backwards compatibility
def deprecated_client_factory():
return client.new()

self.client_factory = deprecated_client_factory
elif client_factory is not None:
self.client_factory = client_factory
else:
raise ValueError("Must specify 'client_factory'")
self.client_factory = client_factory

# Replace the default managers with our specialized proxy managers.
self._tool_manager = ProxyToolManager(
Expand Down
107 changes: 0 additions & 107 deletions tests/deprecated/test_proxy_client.py

This file was deleted.

Loading