You are not limited to serving the MCP on the same FastAPI app from which it was created.You can create an MCP server from one FastAPI app, and mount it to a different app:
Copy
from fastapi import FastAPIfrom fastapi_mcp import FastApiMCP# Your API appapi_app = FastAPI()# ... define your API endpoints on api_app ...# A separate app for the MCP servermcp_app = FastAPI()# Create MCP server from the API appmcp = FastApiMCP(api_app)# Mount the MCP server to the separate appmcp.mount_http(mcp_app)