Multi-Server MCP FastAPI Project

Multi-Server MCP FastAPI Project

A FastAPI application that hosts multiple MCP servers for weather, news, currency, and quotes APIs.

Category
Visit Server

README

Multi-Server MCP FastAPI Project

A comprehensive FastAPI application that hosts multiple Model Context Protocol (MCP) servers, each providing access to different public APIs and services.

Work Demo

fastmcp-multi-server-mcp.webm

๐Ÿš€ Features

This project includes 5 different MCP servers:

  • Weather Server โ€“ OpenWeatherMap API integration for weather data
  • News Server โ€“ NewsAPI integration for latest news articles
  • Currency Server โ€“ Exchange rates and currency conversion
  • Quote Server โ€“ Inspirational quotes and random facts

๐Ÿ“‹ Prerequisites

  • Python 3.13+
  • UV package manager
  • API keys for external services (see Configuration section)

๐Ÿ“ Project Structure

fastapi-multi-server-mcp/
โ”œโ”€โ”€ main.py                 # FastAPI application entry point
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ pyproject.toml         # UV project configuration
โ”œโ”€โ”€ .env.example           # Environment variables template
โ”œโ”€โ”€ README.md              # This file
โ”œโ”€โ”€ servers/               # MCP servers directory
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ weather_server.py  # Weather API MCP server
โ”‚   โ”œโ”€โ”€ news_server.py     # News API MCP server
โ”‚   โ”œโ”€โ”€ currency_server.py # Currency API MCP server
โ”‚   โ””โ”€โ”€ quote_server.py    # Quotes API MCP server
โ”œโ”€โ”€ utils/                 # Utility modules
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ api_clients.py     # HTTP client utilities
โ”‚   โ””โ”€โ”€ config.py          # Configuration management
โ”œโ”€โ”€ tests/                 # Test suite
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ test_weather.py
โ”‚   โ”œโ”€โ”€ test_news.py
โ”‚   โ”œโ”€โ”€ test_currency.py
โ”‚   โ””โ”€โ”€ test_quote.py
โ””โ”€โ”€ docs/                  # Documentation
    โ”œโ”€โ”€ api_reference.md
    โ””โ”€โ”€ deployment.md

๐Ÿ› ๏ธ Installation

Using UV (Recommended)

# Clone the repository
git clone <your-repo-url>
cd fastapi-multi-server-mcp

# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt

Using pip

pip install -r requirements.txt

๐Ÿ”ง Configuration

Create a .env file in the root directory with your API keys:

# Weather API (OpenWeatherMap)
OPENWEATHER_API_KEY=your_openweather_api_key

# News API
NEWS_API_KEY=your_news_api_key


# Exchange Rates API
EXCHANGE_RATES_API_KEY=your_exchange_rates_api_key

# Server Configuration
PORT=10000
HOST=0.0.0.0

Getting API Keys

๐Ÿƒโ€โ™‚๏ธ Running the Application

Development

# Using UV
uv run uvicorn main:app --reload --host 0.0.0.0 --port 10000 --reload

# Using `npx` to debug the running application,
npx @modelcontextprotocol/inspector uv run uvicorn main:app

To connect specific server to inspector,

Set,

  1. Transport Type: StreamableHTTP

  2. URLs:

  • for news: http://localhost:10000/news/mcp/
  • for weather: http://localhost:10000/weather/mcp/
  • for currency: http://localhost:10000/currency/mcp/
  • for quotes: http://localhost:10000/quotes/mcp/
  1. Click connect, it will open inspector window like this:

Quotes server:

Inspector

News server:

Inspector

Weather server:

Inspector

Currency server:

Inspector

As of June 2025, Windsurf and Cursor supports two transport types for MCP servers: stdio and /sse, but not StreamableHTTP. So using stdio or /sse as transport type is recommended. But with inspector, you can connect to the MCP server running on FastAPI with any transport type.

Production

# Using Gunicorn
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:10000

๐Ÿ“š API Endpoints

Once running everything successfully,

Your FastAPI server will be available at: http://localhost:10000, docs at http://localhost:10000/docs and your MCP servers will be available at:

  • Weather Server: http://localhost:10000/weather
  • News Server: http://localhost:10000/news
  • Currency Server: http://localhost:10000/currency
  • Quote Server: http://localhost:10000/quotes

๐Ÿงช Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=.

# Run specific server tests
pytest tests/test_weather.py

๐Ÿ› ๏ธ Available Tools by Server

<details> <summary>๐Ÿ–ผ๏ธ Click to see the tool details</summary>

Weather Server (/weather)

get_current_weather - Get current weather for a city
get_weather_forecast - Get 5-day weather forecast
get_weather_by_coordinates - Get weather by latitude/longitude

News Server (/news)

get_top_headlines - Get top news headlines
search_news - Search news articles by keyword
get_news_by_category - Get news by category (business, tech, sports, etc.)

Currency Server (/currency)

get_exchange_rates - Get current exchange rates
convert_currency - Convert between currencies
get_supported_currencies - List all supported currencies

Quote Server (/quotes)

get_random_quote - Get a random inspirational quote
get_quote_by_category - Get quotes by category
get_random_fact - Get a random interesting fact

</details>

๐Ÿš€ Deployment

Docker

You can deploy this project using Docker. Example Dockerfile is included:

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 10000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "10000"]

Environment Variables for Production

PORT=10000
HOST=0.0.0.0
LOG_LEVEL=info
WORKERS=4

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE.md file for details.

๐Ÿ“š Support & Documentation

  • Check the documentation in the docs/ directory
  • Review the test files for usage examples

๐Ÿ”„ Updates and Roadmap

  • Add WebSocket support for real-time data
  • Implement caching for API responses
  • Add rate limiting and authentication
  • Create web dashboard for monitoring
  • Add more API integrations (Spotify, Twitter, etc.)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured