FastAPI • MCP

Host multiple MCP servers on a single app

This template mounts multiple Model Context Protocol (MCP) servers under one FastAPI instance.

Available servers

  • /echo — Echo MCP server
  • /math — Math MCP server

Base URL

Each server lives at {base_URL}/<server-name>. Replace {base_URL} with your Space's origin.

How to get your {base_URL}

  1. Open your Space and click “Embed this Space”.
  2. Copy the iframe code and take the value of the src attribute.
  3. That origin (e.g. https://your-space.hf.space) is your {base_URL}.
Example

base_URL = https://your-space-name.hf.space

Echo MCP  = {base_URL}/echo
Math MCP  = {base_URL}/math

Illustration of the “Embed this Space” dialog:

Embed this Space dialog showing iframe src base URL

If the image doesn’t load yet, upload your screenshot to Multiple_mcp_fastapi_template/static/embed.png.

Quick links

Use in clients

Point your MCP client to the endpoints below:

HTTP streaming endpoints

Echo: GET {base_URL}/echo
Math: GET {base_URL}/math