A FastAPI-based async API server designed to communicate with Model Context Protocol (MCP) servers. This project provides a seamless way to interact with MCP servers, list available tools, and invoke them programmatically.
POST /api/list-mcp-servers
: List all available MCP servers.POST /api/list-tools
: List tools available from a specified MCP server.POST /api/invoke-tool
: Invoke a tool on an MCP server with provided parameters.shell
git clone <repository-url>
cd mcp-fastapi-server
shell
python -m venv venv
source venv/bin/activate # For Windows: venv\Scripts\activate
shell
pip install -r requirements.txt
.env
file:shell
cp .env.example .env
.env
file to set your MCP server URL and other configurations.Start the server using:
uvicorn app.main:app --reload
The server will run on http://localhost:8000
.
curl -X POST http://localhost:8000/api/list-mcp-servers -H "Content-Type: application/json" -d '{}'
curl -X POST http://localhost:8000/api/list-tools -H "Content-Type: application/json" -d '{"server_url": "http://localhost:5000"}'
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"
}
}'
Once the server is running, access the interactive API documentation:
http://localhost:8000/docs
http://localhost:8000/redoc
This project is licensed under the MIT License.