MCP Server Template
A production-ready template for building Model Context Protocol (MCP) servers in Python, using Docker Compose for containerized development and CI/CD.
README
MCP Server Template
A production-ready template for building Model Context Protocol (MCP) servers in Python. Everything runs through Docker Compose — no local Python installation required beyond Docker itself.
What's Included
- MCP server skeleton —
server/main.pyusing FastMCP with Streamable HTTP + SSE transport on port 8000 - Containerized tooling — reformat, lint, validate-docs, and test all run via
docker compose - MCP Inspector — visual browser UI for testing and debugging your tools
- Automated CI/CD — GitHub Actions that reformat on branches, lint + test on every push, publish to Docker Hub on main
- SemVer releases — stable vs. dev version logic driven by
server/__init__.py - VS Code tasks — one-click access to every workflow from the Command Palette
Quickstart
1. Create a repo from this template
Click "Use this template" on GitHub.
2. Replace placeholders
Find and replace these strings across the entire repo:
| Placeholder | Replace with | Used in |
|---|---|---|
<SERVER-NAME> |
my-mcp-server (hyphenated) |
Docker image names, GitHub URLs, workflow env |
<SERVER_NAME> |
my_mcp_server (underscored) |
Not currently used — reserved if you rename server/ |
<ORGANIZATION> |
Your GitHub username or org | URLs, badges |
Run this to find all occurrences:
grep -r "<SERVER-NAME>\|<ORGANIZATION>" --include="*.yaml" --include="*.toml" --include="*.md" --include="*.py" .
3. Rename server/ to your module name (optional but recommended)
mv server/ my_mcp_server/
# Then update every reference to `server/` in:
# Dockerfile, reformat/Dockerfile, lint/Dockerfile, docs-validate/Dockerfile,
# tests/Dockerfile, tests/docker-compose.yaml, reformat/reformat.sh,
# lint/lint.sh, pyproject.toml ([tool.setuptools.packages.find] and
# [tool.setuptools.dynamic]), .github/workflows/ci.yaml (Get Current Version step)
4. Write your version into server/__init__.py
__version__ = "0.1.0"
5. Fill in pyproject.toml
- Set
name,description,authors - Update
[project.urls]
6. Add your MCP tools in server/main.py
from fastmcp import FastMCP
mcp = FastMCP("my-mcp-server")
@mcp.tool()
def my_tool(param: str) -> str:
"""Do something useful."""
return f"Result: {param}"
if __name__ == "__main__":
mcp.run(transport="streamable-http", host="0.0.0.0", port=8000)
7. Set up Docker Hub secrets in GitHub
Go to Settings → Secrets and variables → Actions and add:
| Secret | Value |
|---|---|
DOCKERHUB_USERNAME |
Your Docker Hub username |
DOCKERHUB_TOKEN |
A Docker Hub access token (not your password) |
8. (Optional) Set up GitHub Pages for docs
Go to Settings → Pages → Deploy from a branch: gh-pages, / (root).
MCP Transport
The server uses Streamable HTTP transport (the current MCP standard). The endpoint is at:
http://localhost:8000/mcp
Compatible with all MCP clients that support HTTP transport (Claude Desktop, Claude.ai, Cursor, etc.).
Development
The only requirement is Docker.
Run the tests
docker compose -f tests/docker-compose.yaml up --build --abort-on-container-exit --exit-code-from test
This starts the MCP server, waits for it to be healthy, then runs pytest against it with pytest-mcp-tools.
Lint
docker compose -f lint/docker-compose.yaml up --build --abort-on-container-exit
Reformat
docker compose -f reformat/docker-compose.yaml up --build --abort-on-container-exit
Reformatting runs black, docformatter, and isort on server/ and tests/, then writes changes back to disk (via volume mount). On non-main branches CI commits these changes automatically.
Validate docs
docker compose -f docs-validate/docker-compose.yaml up --build --abort-on-container-exit
Run the MCP Inspector
docker compose -f inspector/docker-compose.yaml up --build
Then open the URL printed in the logs (includes the auth token):
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=<token>
VS Code Tasks
Open Terminal → Run Task (or Ctrl+Shift+P → Tasks: Run Task):
| Task | What it does |
|---|---|
test |
Runs the full test suite (server + test runner containers) |
lint |
Runs ruff against server/ and tests/ |
reformat |
Formats code with black + docformatter + isort |
validate-docs |
Builds MkDocs site with --strict |
inspector |
Starts the server + MCP Inspector (leaves running in background) |
CI/CD Pipeline
The workflow at .github/workflows/ci.yaml runs on every push and pull request:
push (any branch)
│
├── reformat ← runs black/isort/docformatter
│ └── (commits reformatted code back, non-main branches only)
│
├── lint ← ruff check (needs: reformat)
├── test ← pytest --mcp-tools (needs: reformat)
├── validate-docs ← mkdocs build --strict
└── detect-changes ← checks if server/ or README changed
│
└── publish (main only, when changed)
├── Build & push Docker image to Docker Hub
│ ├── stable: <org>/<server>:1.2.3 + :latest
│ └── dev: <org>/<server>:1.2.4.dev202401011200
├── Tag stable release in git
├── Create GitHub Release
└── publish-docs (stable + docs exist)
└── mike deploy to GitHub Pages
Versioning
Version is read from server/__init__.py. The logic:
- If
__version__> last git tag → stable release (tags git, pushes:latest) - If
__version__== last git tag → dev release (appends.devYYYYMMDDHHMM, no:latest)
Bump __version__ in server/__init__.py to trigger a stable release on the next main push.
Project Structure
.
├── Dockerfile # Builds and runs the MCP server
├── pyproject.toml # Project metadata, dependencies, tool config
├── server/
│ ├── __init__.py # __version__ = "x.y.z"
│ └── main.py # FastMCP server — add your tools here
├── tests/
│ ├── Dockerfile # Test runner image
│ ├── docker-compose.yaml # mcp-server + test-runner services
│ └── test_unit.py # Placeholder — add your tests here
├── reformat/ # black + docformatter + isort container
├── lint/ # ruff container
├── docs-validate/ # mkdocs build container
├── inspector/ # MCP Inspector + server for visual testing
├── scripts/
│ └── semver_compare.py # Used by CI to compare versions
└── .github/workflows/ci.yaml # Full CI/CD pipeline
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。