mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Repoint tests and examples off removed deprecations
Replaces FastMCP.as_proxy() helper calls with create_proxy(), rewrites the mount() as_proxy=/prefix= kwarg tests to plain mount() (the params are gone), and deletes deprecation-only tests for as_proxy() and remove_tool().
This commit is contained in:
parent
e5d9d1f17d
commit
6a6fdcb2bb
11 changed files with 39 additions and 176 deletions
|
|
@ -3,7 +3,7 @@ This example demonstrates how to set up and use an in-memory FastMCP proxy.
|
|||
|
||||
It illustrates the pattern:
|
||||
1. Create an original FastMCP server with some tools.
|
||||
2. Create a proxy FastMCP server using ``FastMCP.as_proxy(original_server)``.
|
||||
2. Create a proxy FastMCP server using ``create_proxy(original_server)``.
|
||||
3. Use another Client to connect to the proxy server (in-memory) and interact with the original server's tools through the proxy.
|
||||
"""
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ from mcp.types import TextContent
|
|||
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.client import Client
|
||||
from fastmcp.server import create_proxy
|
||||
|
||||
|
||||
class EchoService:
|
||||
|
|
@ -38,9 +39,9 @@ async def main():
|
|||
# 2. Proxy Server Creation
|
||||
print("\nStep 2: Creating the Proxy Server (InMemoryProxy)...")
|
||||
print(
|
||||
f" (Using FastMCP.as_proxy to wrap '{original_server.name}' directly)"
|
||||
f" (Using create_proxy to wrap '{original_server.name}' directly)"
|
||||
)
|
||||
proxy_server = FastMCP.as_proxy(original_server, name="InMemoryProxy")
|
||||
proxy_server = create_proxy(original_server, name="InMemoryProxy")
|
||||
print(
|
||||
f" -> Proxy Server '{proxy_server.name}' created, proxying '{original_server.name}'."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ def check_app_status() -> dict[str, str]:
|
|||
|
||||
|
||||
# Mount sub-applications
|
||||
app.mount(server=weather_app, prefix="weather")
|
||||
app.mount(server=weather_app, namespace="weather")
|
||||
|
||||
app.mount(server=news_app, prefix="news")
|
||||
app.mount(server=news_app, namespace="news")
|
||||
|
||||
|
||||
async def get_server_details():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue