Token导航 LogoToken导航TokenDH.com
Fastapi Multi Server MCP logo
数据服务stdio官方级别未说明来源级核验

Fastapi Multi Server MCP

MCP Server

一个基于FastAPI的多服务集成平台,提供天气、新闻、货币和名言等API服务。

工具数

0

提示词数

0

GitHub Stars

3

资源数

0
API集成PythonCursor数据服务CursorWindsurf

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

AlwaysSany

提供方

AlwaysSany

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

多服务器MCP FastAPI项目

一个全面的FastAPI应用程序,托管多个模型上下文协议(MCP)服务器,每个服务器都提供对不同公共API和服务的访问。

工作演示

fastmcp-multi-server-mcp.webm

🚀 特性

该项目包括5个不同的MCP服务器:

  • 天气服务器 –天气数据的OpenWeatherMap API集成
  • 新闻服务器 –最新新闻文章的NewsAPI集成
  • 货币服务器 –汇率和货币兑换
  • 报价服务器 –鼓舞人心的引语和随机事实

📋 先决条件

  • Python 3.13+
  • 紫外线的 包管理器
  • 外部服务的API密钥(请参阅配置部分)

📁 项目结构

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

🛠️ 安装

使用紫外线(推荐)

# Clone the repository
git clone 
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

使用pip

pip install -r requirements.txt

🔧 配置

创建一个 .env 根目录中带有API密钥的文件:

# 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

获取API密钥

🏃‍♂️ 运行应用程序

发展

# 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

为了将特定服务器连接到检查器,

设置,

  1. 运输类型: StreamableHTTP
  1. 网址:
  • 新闻:http://localhost:10000/news/mcp/
  • 天气:http://localhost:10000/weather/mcp/
  • 对于货币:http://localhost:10000/currency/mcp/
  • 对于报价:http://localhost:10000/quotes/mcp/
  1. 点击连接,将打开检查器窗口,如下所示:

报价服务器:

Inspector

新闻服务器:

Inspector

天气服务器:

Inspector

货币服务器:

Inspector

截至2025年6月,Windsurf和Cursor支持MCP服务器的两种传输类型: stdio/sse,但不是 StreamableHTTP因此,使用 stdio/sse 因为推荐运输类型。但是,使用检查器,您可以使用任何传输类型连接到在FastAPI上运行的MCP服务器。

生产

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

📚 API终点

一旦一切运行成功,

您的FastAPI服务器将在以下位置可用:http://localhost:10000,文件在http://localhost:10000/docs 您的MCP服务器将在以下网址提供:

  • 天气服务器:http://localhost:10000/weather
  • 新闻服务器:http://localhost:10000/news
  • 货币服务器:http://localhost:10000/currency
  • 报价服务器:http://localhost:10000/quotes

🧪 测试

# Run all tests
pytest

# Run with coverage
pytest --cov=.

# Run specific server tests
pytest tests/test_weather.py

🛠️ 按服务器列出的可用工具

🖼️ Click to see the tool details

天气服务器(/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)

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.)

货币服务器(/货币)

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

报价服务器(/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

🚀 部署

码头工人

您可以使用Docker部署此项目。示例 Dockerfile 包括:

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"]

生产环境变量

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

📝 许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅License.md文件。

📚 支持和文档

  • 查看文档 docs/ 目录
  • 查看测试文件以获取使用示例

🔄 更新和路线图

  • 添加对实时数据的WebSocket支持
  • 为API响应实现缓存
  • 添加速率限制和身份验证
  • 创建用于监控的web仪表板
  • 添加更多API集成(Spotify、Twitter等)

目录标签

目录标签

API集成PythonCursor数据服务本地部署多服务管理FastAPI应用

支持客户端

CursorWindsurf

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP