You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async def call_auth_test(client: Client) -> list:
response = await client.call_tool(
"items" # what is the correct api name? list_tools does not show this fastapi api.
)
The text was updated successfully, but these errors were encountered:
from fastapi import FastAPI
from fastmcp import FastMCP
fastapi_app = FastAPI(title="sub fast api")
@fastapi_app.post("/items")
def create_item(name: str, price: float):
return {"id": 1, "name": name, "price": price}
Generate an sub MCP server directly from the FastAPI app
sub_mcp_server = FastMCP.from_fastapi(fastapi_app)
Generate an main MCP server
main_mcp_server = FastMCP(name="MAINSERVER")
main_mcp_server .mount("sub", sub_mcp_server )
if name == "main":
import asyncio
asyncio.run(main_mcp_server.run_sse_async(host="localhost", port=8080, log_level="debug"))
=========client========
client = Client(SSETransport(url="http://localhost:8001/sse"))
how to call the fastapi api in the sub-server?
async def call_auth_test(client: Client) -> list:
response = await client.call_tool(
"items" # what is the correct api name? list_tools does not show this fastapi api.
)
The text was updated successfully, but these errors were encountered: