MCP Server Playground
A learning project that wraps a FastAPI app with endpoints for random facts and Japan FAQs as MCP tools, enabling LLMs to call them via LiteLLM proxy.
README
MCP Server Playground
A learning project for building and testing custom MCP (Model Context Protocol) servers connected to a deployed LiteLLM proxy.
What This Is
This project explores how to:
- Build a REST API and automatically expose it as an MCP server
- Register that MCP server with a LiteLLM proxy
- Chat with an LLM that can call your custom tools via MCP
- Test the whole flow from a CLI
Architecture
┌─────────────┐ MCP protocol ┌──────────────┐ HTTP ┌──────────────┐
│ LiteLLM │ ──────────────────── ▶│ MCP Server │ ────────────▶ │ FastAPI │
│ Proxy │ │ :8001 │ │ :8000 │
│ (deployed) │ └──────────────┘ └──────────────┘
└─────────────┘
▲
│ OpenAI-compatible API
│
┌─────────────┐
│ CLI │
│ (cli.py) │
└─────────────┘
FastAPI (api/) — serves two endpoints:
GET /home— returns a random David Salazar factGET /faq— returns Japan FAQ Q&A pairs
MCP Server (mcp_server/) — wraps the FastAPI via its OpenAPI spec and exposes the routes as MCP tools. LiteLLM registers this server and makes the tools available to the LLM.
LiteLLM Proxy — deployed externally. Holds your Anthropic API key, registers your MCP server, and handles all LLM routing.
CLI (cli.py) — interactive chat tool. Lists available MCP tools, lets you pick one, then chats with the LLM using that tool.
Project Structure
faq/
├── api/
│ └── main.py # FastAPI routes
├── mcp_server/
│ └── server.py # MCP server (auto-generated from OpenAPI spec)
├── core/
│ ├── llm.py # LLMService — async chat via LiteLLM proxy
│ ├── models.py # Shared Pydantic models
│ └── settings.py # Config loaded from .env
├── cli.py # Interactive CLI chat tool
├── .env.example # Environment variable template
└── pyproject.toml
Setup
1. Install dependencies
uv sync
2. Configure environment
cp .env.example .env
Edit .env with your values:
BASE_URL="http://localhost:8000/"
BASE_URL_DOCS="http://localhost:8000/openapi.json"
OPENAI_KEY="sk-your-litellm-master-key"
LITELLM_URL="https://your-litellm-proxy.com" # or http://localhost:4000 locally
Running Locally
Start each service in a separate terminal:
# 1. FastAPI
uv run uvicorn api.main:app --reload --port 8000
# 2. MCP Server (requires FastAPI to be running first)
uv run python mcp_server/server.py
# 3. CLI chat tool (requires MCP server to be running)
uv run python cli.py
Deploying
Both api/ and mcp_server/ live in this repo and can be deployed together.
FastAPI
uvicorn api.main:app --host 0.0.0.0 --port 8000
MCP Server — update BASE_URL in your deployed .env to point to the deployed FastAPI URL, then:
python mcp_server/server.py
Register with LiteLLM — in your LiteLLM config.yaml, add:
mcp_servers:
- name: faq
url: https://your-mcp-server.com/mcp
Or
You can use the LiteLLM UI.
CLI Usage
uv run python cli.py
Available tools:
1. faq-home_home_get — Returns a random fact about Me.
2. faq-faq_faq_get — Returns a list of frequently asked questions about Japan.
Pick a tool (number): 2
Using tool: faq-faq_faq_get | Type 'quit' to exit.
You: Do I need a visa to go to Japan?
Assistant: Based on the information available, **visa requirements for Japan depend on your nationality**:
**Citizens of about 68 countries** can enter Japan **visa-free for short stays**, typically up to **90 days**.
However, this varies by country, so I recommend checking the **Japanese Ministry of Foreign Affairs website** to confirm the specific requirements for your country of citizenship.
If your country isn't on the visa-free list, you'll need to apply for an appropriate visa before traveling to Japan.
You: quit
Adding New Tools
- Add a new route to
api/main.py - Restart the MCP server — it auto-discovers routes from the OpenAPI spec or the
@mcp.tooldecorator - The new tool appears automatically in LiteLLM and the CLI
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。