MCP FastAPI Server
- other
About
What is MCP FastAPI Server?
MCP FastAPI Server is a FastAPI-based async API server that communicates with Model Context Protocol (MCP) servers. It runs locally and enables users to list available MCP servers, list tools, and invoke tools via REST API endpoints.
How to use MCP FastAPI Server?
Install Python 3.8 or higher, clone the repository, create a virtual environment, install dependencies, and configure the .env file with the MCP server URL. Start the server with uvicorn app.main:app --reload, then call the provided API endpoints using HTTP clients like curl.
Key features of MCP FastAPI Server
- Lists available MCP servers
- Lists tools available from an MCP server
- Invokes tools on an MCP server
- Provides interactive Swagger UI and ReDoc documentation
- Built with FastAPI for async performance
Use cases of MCP FastAPI Server
- Querying which MCP servers are reachable in your environment
- Discovering tools exposed by a specific MCP server
- Calling a tool on an MCP server from a REST client
- Integrating MCP capabilities into web applications or scripts
FAQ from MCP FastAPI Server
What platforms does MCP FastAPI Server run on?
It requires Python 3.8 or higher and runs on any platform that supports Python (Windows, macOS, Linux).
How do I connect to a MCP server?
Set the MCP server URL in the .env file (e.g., http://localhost:5000) before starting the API server. The server URL can also be passed in the request body for tool listing and invocation.
What is the license for MCP FastAPI Server?
MCP FastAPI Server is licensed under the MIT license.
Details
- Author
- karthikv2k
- GitHub stars
- 4
- Category
- other
- Repository
- karthikv2k/chat-mcp
MCP FastAPI Server
A FastAPI-based async API server that communicates with Model Context Protocol (MCP) servers.
Features
- List available MCP servers
- List tools available from MCP servers
- Invoke tools on MCP servers
API Endpoints
- POST /api/list-mcp-servers: List all available MCP servers
- POST /api/list-tools: List all tools available from an MCP server
- POST /api/invoke-tool: Invoke a tool on an MCP server
Prerequisites
- Python 3.8 or higher
- An accessible MCP server (local or remote)
Installation
1. Clone this repository:
git clone <repository-url>
cd mcp-fastapi-server
2. Create a virtual environment:
python -m venv venv
source venv/bin/activate # For Windows: venv\Scripts\activate
3. Install dependencies:
pip install -r requirements.txt
4. Create a .env file from the example:
cp .env.example .env
Edit the
.env file to configure your MCP server URL and other settings.
Running the Server
Start the server with:
uvicorn app.main:app --reload
This will start the server on http://localhost:8000.
API Usage Examples
List MCP Servers
curl -X POST http://localhost:8000/api/list-mcp-servers -H "Content-Type: application/json" -d '{}'
List Tools from an MCP Server
curl -X POST http://localhost:8000/api/list-tools -H "Content-Type: application/json" -d '{"server_url": "http://localhost:5000"}'
Invoke a Tool
curl -X POST http://localhost:8000/api/invoke-tool -H "Content-Type: application/json" -d '{
"server_url": "http://localhost:5000",
"tool_name": "example_tool",
"params": {
"parameter1": "value1",
"parameter2": "value2"
}
}'
Documentation
Once the server is running, you can access the interactive API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
License
MIT # chat-mcp