FastMCP Server
A high-performance personal Model Context Protocol (MCP) server built with the FastMCP Python framework.
README
FastMCP Server
A high-performance personal Model Context Protocol (MCP) server built with the FastMCP Python framework.
Project Structure
mcp-server/
├── .agents/
│ └── mcp_config.json.example # IDE/agent configurations template
├── src/
│ └── mcp_server/
│ ├── __init__.py # Package initialization
│ └── server.py # Main server logic (tools, resources, prompts)
├── fastmcp.json.example # FastMCP CLI config template
├── pyproject.toml # Poetry/Setuptools metadata and dependencies
└── requirements.txt # Pip installation file
Features Scaffolded
- Tools (executable actions):
add_numbers(a, b): Adds two floats together.format_message(name, message): Returns a formatted greeting.save_user_profile(username, profile_content): Dynamically saves/updates a user profile in the active database.save_wiki_article(topic, markdown_content): Dynamically saves/updates markdown wiki pages in the active database.
- Resources (data exposed to LLMs):
config://system_info: Static resource returning OS and Python environment details.user://{username}: Dynamic resource returning profile data (queries database, falls back to defaults).wiki://{topic}: Dynamic resource returning markdown wiki articles (queries database, falls back to default bootstrap guides).
- Prompts (instruction templates):
code_reviewer(code, language): Generates structured instructions to review code.
Installation & Setup
1. Configure the Virtual Environment
Ensure you are using the local virtual environment:
source venv/bin/activate
pip install -r requirements.txt
[!TIP] Alternatively, you can install the package in editable mode:
pip install -e .
2. Run the Server
You can run the server in two modes:
Option A: CLI Config (Recommended)
Copy the example config and run with the fastmcp CLI:
cp fastmcp.json.example fastmcp.json
fastmcp run fastmcp.json
Option B: Standard Python (STDIO Only)
Run the module directly:
python -m mcp_server.server
Option C: Dev Mode (MCP Inspector)
Start the interactive developer interface to inspect tools and resources:
fastmcp dev src/mcp_server/server.py
Storage & Caching Backend
The server integrates a storage layer that powers user profiles and response caching. It can switch between a local, volatile memory store (development) and redis (production).
Configuration Options
Configure the backend inside your fastmcp.json file:
"storage": {
"backend": "memory",
"redis": {
"host": "localhost",
"port": 6379,
"db": 0
}
}
Alternatively, settings can be loaded from environment variables (e.g. in your .env file):
STORAGE_BACKEND:memoryorredisREDIS_HOST: Hostname (default:localhost)REDIS_PORT: Port number (default:6379)REDIS_DB: Database index (default:0)REDIS_PASSWORD: Optional authentication password
Integrations
1. Claude Desktop
Add this server to your local configuration:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add one of the following setups under the mcpServers object:
STDIO Connection
"personal-mcp-server": {
"command": "/absolute/path/to/mcp-server/venv/bin/python",
"args": ["-m", "mcp_server.server"]
}
(Make sure to replace /absolute/path/to/mcp-server with your actual workspace path).
HTTP SSE Connection
Start the server in HTTP mode first (fastmcp run fastmcp.json), then hook it up using mcp-remote:
"personal-mcp-server": {
"command": "npx",
"args": [
"mcp-remote@latest",
"--sse",
"--allow-http",
"http://localhost:8000/sse"
]
}
2. Antigravity IDE
Configure the server for the workspace agent panel.
Step 1: Initialize Workspace Configuration
Copy the configuration template:
cp .agents/mcp_config.json.example .agents/mcp_config.json
Step 2: Configure Transport
Open .agents/mcp_config.json and configure either stdio or http:
- For STDIO Transport:
{ "mcpServers": { "personal-mcp-server": { "command": "/absolute/path/to/mcp-server/venv/bin/python", "args": ["-m", "mcp_server.server"] } } } - For HTTP Transport:
{ "mcpServers": { "personal-mcp-server": { "serverUrl": "http://localhost:8000/sse" } } }
[!NOTE] Global configuration can also be set in
~/.gemini/config/mcp_config.json.
Upstream MCP Server Composition
You can configure this server to connect to, aggregate, and namespace other local or remote MCP servers. This is called Server Composition.
When upstream servers are mounted:
- All their tools, resources, and prompts are exposed under their respective
namespaceprefix (e.g., if you mountgit, its tools will be prefixed likegit_list_commitsto avoid naming collisions).
Setup Upstream Servers
- Copy the example configuration template:
cp upstream_servers.json.example upstream_servers.json - Configure your upstream servers under the
mcpServersobject inupstream_servers.json:{ "mcpServers": { "git": { "command": "uvx", "args": ["mcp-server-git"] }, "remote-helper": { "serverUrl": "http://localhost:8001/sse" } } } - Run or restart the FastMCP server. The configured servers will be dynamically mounted and namespaces on startup.
Container Deployment (Docker & Compose)
A complete, self-contained [docker-compose.yml](file:///workspaces/mcp-server/docker-compose.yml) file is provided that launches the entire architecture locally:
traefik: Routes incoming HTTP requests from the host (http://mcp.localhost) to the server.redis: Standardredis:8.8-alpinekey-value store database used for user profiles and FastMCP response caching.mcp-server: Pulls and launches the python server from GHCR, connecting to Redis and registering discovery labels for Traefik routing.
How to Run:
Start all services:
docker compose up -d
This will:
- Pull the pre-built server image
ghcr.io/jamesbspencer/mcp-server:latestfrom GitHub Container Registry. - Start the Traefik proxy on port
80(HTTP) and expose its dashboard interface onhttp://localhost:8080. - Start the Redis instance with a persistent named volume
redis-data. - Connect all services on a custom
mcp-networkbridge network.
Verification & Logs
You can check service status and logs using:
docker compose ps
docker compose logs -f
CI/CD Pipeline (GitHub Actions)
A GitHub Actions workflow is configured in [.github/workflows/docker-publish.yml](file:///workspaces/mcp-server/.github/workflows/docker-publish.yml) to automatically build and publish your server image to GitHub Container Registry (GHCR).
Triggers:
- On push to
mainormasterbranches (builds and pushes tag matching the branch name). - On push of version tags (e.g.,
v1.2.3). - Can be manually triggered via
workflow_dispatch.
The workflow extracts semver metadata and configures build cache (cache-from: type=gha) for fast incremental builds.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。