Multiple MCP Servers Framework
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Multiple MCP Servers Frameworkecho test message"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
š Multiple MCP Servers using FastAPI and Testing with Inspector
This project provides a framework for running multiple Model Context Protocol (MCP) servers using different transport mechanisms: FastAPI-based HTTP servers, standalone streamable-http servers, and stdio-based servers.
ā Supported MCP Transports:
stdio
streamable-http
FastAPI-mounted
It includes three main scripts:
mcp-server-with-stdio.pyā”ļø A standalone MCP server usingstdiotransport.mcp-server-with-streamable-http.pyā”ļø A standalone MCP server usingstreamable-httptransport.mcp-server-fastapi.pyā”ļø A FastAPI server hosting two MCP instances (McpServer1andMcpServer2) withstreamable-httptransport.
Each server implements a simple echo tool for testing and demonstration, and the framework supports robust logging, environment configuration, and graceful shutdown handling. The servers are compatible with the MCP Inspector for interactive testing. šµļøāāļø
š Table of Contents
šÆ Purpose
The MCP Server Framework is designed to:
Demonstrate the flexibility of MCP servers using different transports (
streamable-httpandstdio).Provide a production-ready FastAPI server hosting multiple MCP instances under a single application.
Support standalone MCP servers for simpler use cases or environments requiring
stdiocommunication.Ensure robust logging, configuration management, and graceful shutdown for all server types.
Enable easy integration with the MCP Inspector for testing and tool interaction.
Related MCP server: DDG MCP Server
šļø Project Structure
The project is organized as follows:
/
āāā src/
ā āāā mcp-server-fastapi.py # FastAPI server hosting two MCP instances
ā āāā mcp-server-with-streamable-http.py # Standalone MCP server with streamable-http
ā āāā mcp-server-with-stdio.py # Standalone MCP server with stdio
ā āāā fastapi_mcp_servers/ # MCP server implementations for FastAPI
ā ā āāā __init__.py
ā ā āāā mcp_server_1.py # First MCP server with echo1 tool
ā ā āāā mcp_server_2.py # Second MCP server with echo2 tool
ā āāā config/ # Configuration and logging utilities
ā ā āāā __init__.py
ā ā āāā app_settings.py # Environment variable and settings management
ā ā āāā logging_config.py # Logging setup with file rotation and cleanup
ā āāā util/
ā āāā mcp_server_shutdown_handler.py # Graceful shutdown handler for MCP servers
āāā .env # Environment variables (e.g., PORT, LOG_DIR)
āāā pyproject.toml # Project dependencies
āāā README.md # Project documentation⨠Features
Multiple MCP Servers:
Standalone MCP server using
stdiotransport for direct stdin/stdout communication.Standalone MCP server using
streamable-httptransport athttp://0.0.0.0:8001/mcp/.FastAPI server hosting two MCP instances at
/echo1/mcp/and/echo2/mcp/withstreamable-httptransport.
Echo Tool: A simple tool that echoes input messages, implemented across all servers for testing.
Transport Flexibility: Supports
streamable-http(recommended for HTTP-based communication) andstdio(for Inspector-driven communication).Robust Logging: Configurable logging with file rotation and console output, stored in a specified log directory.
Environment Configuration: Loads settings from a
.envfile (e.g.,PORT,LOG_DIR,API_KEY).Graceful Shutdown: Handles
SIGINTandSIGTERMsignals to ensure clean termination of MCP servers.Lifespan Management (FastAPI): Manages startup and shutdown of MCP session managers in the FastAPI server.
MCP Inspector Compatibility: All servers are compatible with the MCP Inspector for interactive tool testing.
š ļø Prerequisites
To run the project, ensure you have the following installed:
Python: Version 3.8 or higher
Node.js: Required for running the MCP Inspector
uv: A Python package manager for installing dependencies
npx: For running the MCP Inspector
Operating System: Compatible with Windows, macOS, or Linux
Recommended: a modern terminal that supports UTF-8
š¦ Required Packages
The project depends on the following Python packages:
mcp[cli]: Provides the MCP server and CLI tools.fastapi: The FastAPI framework for themcp-server-fastapi.pyscript.uvicorn: ASGI server implementation for running FastAPI.python-dotenv: For loading environment variables from a.envfile.
āļø Installation
Clone the Repository:
git clone https://github.com/ahmad-act/Multiple-MCP-Servers-Using-FastAPI-and-Testing-with-Inspector.git cd Multiple-MCP-Servers-Using-FastAPI-and-Testing-with-InspectorSet Up a Virtual Environment (optional but recommended):
uv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall Dependencies:
Install the required Python packages using
uv:uv syncAlternatively,
uv add mcp[cli] fastapi uvicorn python-dotenvConfigure Environment Variables:
Create a
.envfile in the project root with the following content:PORT=10000 LOG_DIR=logs
Usage
1ļøā£ Standalone Stdio MCP Server (mcp-server-with-stdio.py)
Starting the MCP Server
You do not need to manually run the MCP server for stdio transport. MCP Inspector runs the MCP Server for stdio transport.
Starting the MCP Inspector
The stdio server is typically launched by the MCP Inspector, not manually. Run the Inspector with the following command, adjusting the --directory path to your src/ directory:
npx @modelcontextprotocol/inspector uv --directory "<your-src-directory>" run mcp-server-with-stdio.py --debug
The Inspector will manage the server lifecycle and communicate over stdio.
Opening the MCP Inspector
Open the link http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=XXXXXXXXXXXXXXXXXX with its token in your browser:

Using the MCP Inspector
After running the above command, the Inspector will start and automatically connect to the
stdio-based server.In the Inspector UI (
http://127.0.0.1:6274), inspect the available tools (e.g.,echo).Test the
echotool:Input:
{ "message": "test" }Expected Output:
{ "echo": "Echo from MCP Server with stdio: test" }

2ļøā£ Standalone Streamable-HTTP MCP Server (mcp-server-with-streamable-http.py)
Starting the MCP Server
Open new terminal and go to the project root folder:
cd "D:\My Study\AI\GitHub ahmad-act\Multiple-MCP-Servers-Using-FastAPI-and-Testing-with-Inspector"Run the standalone MCP server:
uv run ./src/mcp-server-with-streamable-http.pyThe server will start on http://0.0.0.0:8001/mcp/.

Starting the MCP Inspector
Run the MCP Inspector:
Open new terminal and run the command:
npx @modelcontextprotocol/inspector
Opening the MCP Inspector
Open the Inspector in your browser at http://127.0.0.1:6274.
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Using the MCP Inspector
Configure the Inspector to connect to
http://0.0.0.0:8001/mcp/.

Test the
echotool:Input:
{ "message": "test" }Expected Output:
{ "echo": "Echo from MCP Server with streamable-http: test" }

3ļøā£ FastAPI-Based MCP Server (mcp-server-fastapi.py)
Starting the MCP Server
Open new terminal and go to the project root folder:
cd "D:\My Study\AI\GitHub ahmad-act\Multiple-MCP-Servers-Using-FastAPI-and-Testing-with-Inspector"Run the FastAPI server:
uv run ./src/mcp-server-fastapi.pyThe server will start on http://0.0.0.0:10000 (or the port specified in the PORT environment variable). The MCP endpoints will be available at:
http://0.0.0.0:10000/echo1/mcp/http://0.0.0.0:10000/echo2/mcp/
Starting the MCP Inspector
Run the MCP Inspector:
Open new terminal and run the command:
npx @modelcontextprotocol/inspector
Opening the MCP Inspector
Open the Inspector in your browser at http://127.0.0.1:6274.
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Using the MCP Inspector
Configure the Inspector to connect to
http://0.0.0.0:10000/echo1/mcp/forMcpServer1.

Test the
echotool:Input:
{ "message": "test" }Expected Output:
{ "echo": "Echo from MCP Server 1 using FastAPI: test" }

Configure the Inspector to connect to
http://0.0.0.0:10000/echo2/mcp/forMcpServer2.

Test the
echotool:Input:
{ "message": "test" }Expected Output:
{ "echo": "Echo from MCP Server 2 using FastAPI: test" }

š§© Workflow
Choose the Server Type:
Use
mcp-server-fastapi.pyfor a multi-MCP HTTP server.Use
mcp-server-with-streamable-http.pyfor a standalone HTTP-based MCP server.Use
mcp-server-with-stdio.pyforstdio-based communication, typically managed by the MCP Inspector.
Start the Server:
For FastAPI or streamable-http servers, run the respective script with
uv run.For the stdio server, use the MCP Inspector to launch the server.
Interact with MCP Tools: Use the MCP Inspector to connect to the server and test the
echotool.Monitor Logs: Check logs in the
logs/directory (or the directory specified inLOG_DIR) for debugging and monitoring.Graceful Shutdown: Press
Ctrl+Cor send aSIGTERMsignal to shut down HTTP-based servers gracefully. For thestdioserver, shutting down the Inspector will terminate the server.
š Logging
Logs are stored in the directory specified by the
LOG_DIRenvironment variable (default:logs/).Log files are named in the format
YYYYMM.log(e.g.,202507.logfor July 2025).Logs rotate when they reach 5 MB, with up to 5 backup files.
Old log files can be cleaned up using the
cleanup_old_logsfunction inlogging_config.py.
Example log output:
2025-07-01 13:06:00,123 - __main__ - INFO - Starting FastMCP server with streamable-http transport...
2025-07-01 13:06:00,125 - __main__ - INFO - FastMCP server initialized successfully.š Graceful Shutdown
All servers handle SIGINT (e.g., Ctrl+C) and SIGTERM signals to ensure graceful shutdown:
MCP servers are shut down cleanly.
Logs are updated with shutdown status.
The process exits with a status code of
0.
š§ Notes
Transport Options:
streamable-httpis recommended for HTTP-based communication due to its efficiency.stdiois suitable for environments where direct stdin/stdout communication is preferred, typically with the MCP Inspector.
Port Configuration:
The FastAPI server uses port
10000by default (configurable viaPORT).The streamable-http server uses port
8001(hardcoded).The stdio server does not use a network port.
MCP Inspector: Required for testing all servers. Ensure it is running to interact with MCP tools.
š ļø Troubleshooting
Server Fails to Start:
Check logs in the
logs/directory for errors.Ensure the
PORTenvironment variable is a valid integer for HTTP-based servers.Verify that port
8001(for streamable-http) or10000(for FastAPI) is not in use.
MCP Inspector Cannot Connect:
For HTTP servers, verify the server is running and the endpoint URLs are correct.
For the stdio server, ensure the Inspector command includes the correct
--directorypath.
Log Files Not Created: Ensure the
LOG_DIRdirectory exists and is writable.Dependency Issues: Run
uv syncto ensure all required packages are installed.
Available Tools
1 toolechoC
A simple echo tool
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It only calls the tool 'simple echo' without detailing what happens when invoked (e.g., returns message, no side effects). This is insufficient for an agent to understand the behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very short but lacks essential information. It is under-specified, not effectively concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema and trivial complexity, the description still fails to specify the return value or behavior. An agent would need to guess that it echoes the message.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0% and the description does not mention the 'message' parameter at all. It adds no meaning beyond what the schema provides, leaving the parameter's purpose implicit from the tool name.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The name 'echo' strongly implies repeating input, and 'simple echo tool' clarifies the basic function. However, it lacks a specific verb and resource (e.g., 'returns the provided message'), making it somewhat vague.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool or alternatives. There are no sibling tools, but the description does not specify any context or limitations.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v1.0.0- First observed
echo
TDQS
With only one tool, there is no possibility of confusion between tools.
A single tool name 'echo' is self-consistent, so the naming pattern is coherent by default.
The server is named 'Multiple MCP Servers Framework', yet provides only one trivial echo tool, which is a severe mismatch between name and functionality.
A single echo tool provides no meaningful coverage for any domain; the tool surface is severely incomplete for the implied purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
MCP server for progressive tool usage at any scale (see https://klavis.ai)
The official MCP Server for the Mux API
Remote MCP server exposing SMI Aware tools, resources, and skills over Streamable HTTP.
Related MCP Servers
- AlicenseAqualityDmaintenanceA lightweight framework for building and running Model Context Protocol (MCP) servers using FastMCP, providing tools for development, debugging, and server management.4MIT
- -licenseNot gradedqualityNot gradedmaintenanceA basic MCP server built with FastMCP framework that provides example tools including message echoing and server information retrieval. Supports both stdio and HTTP transports for integration with various MCP clients.-
- AlicenseNot gradedqualityDmaintenanceA FastAPI MCP server that uses Server-Sent Events as a transport layer, providing echo functionality through tools, resources, and prompts.12MIT
- FlicenseNot gradedqualityDmaintenanceEnables building and running MCP servers over streamable HTTP, exposing tools to AI assistants like Cursor, with examples of mounting multiple servers in FastAPI.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ahmad-act/Multiple-MCP-Servers-Using-FastAPI-and-Testing-with-Inspector'
If you have feedback or need assistance with the MCP directory API, please join our Discord server