FastMCP Python Boilerplate

FastMCP Python Boilerplate

Provides a production-ready FastMCP Python server boilerplate with structured logging, rate limiting, and config validation for building MCP servers compatible with Claude and other agents.

Category
Visit Server

README

FastMCP Python Boilerplate

Production-ready FastMCP Python boilerplate for building MCP servers that work with Claude, GPT, Cursor, and any MCP-compatible agent.

What's included

  • FastMCP server setup with proper tool schemas
  • Pydantic v2 config validation — reads from .env, never hardcodes secrets
  • Token-bucket rate limiter — thread-safe, per-client windows
  • structlog to stderr — structured logging that doesn't break MCP protocol framing
  • pytest suite, 36 tests — config, rate limiter, tools, and a subprocess-level check that stdout never carries anything but JSON-RPC

Docker packaging, CI, pre-commit, and the Claude Desktop config ship with the full package.

The stdout/stderr gotcha

MCP uses stdout for JSON-RPC frames. Any print() that lands on stdout corrupts the protocol — the client sees malformed JSON and either drops the message or errors out. All logging goes to stderr.

This boilerplate has it wired by default:

import structlog, sys
structlog.configure(logger_factory=structlog.PrintLoggerFactory(file=sys.stderr))

Quick start

git clone https://github.com/srmcguirt/fastmcp-python-boilerplate
cd fastmcp-python-boilerplate
cp .env.example .env
pip install -r requirements.txt
python server.py

Structure

fastmcp-python-boilerplate/
├── mcp_server/
│   ├── __main__.py        # Entrypoint: python -m mcp_server
│   ├── server.py          # FastMCP server + example tools
│   ├── config.py          # Pydantic v2 settings (reads from .env)
│   ├── logger.py          # structlog wired to stderr
│   └── rate_limiter.py    # Thread-safe token bucket
├── tests/
│   ├── test_config.py
│   ├── test_rate_limiter.py
│   ├── test_server.py
│   └── test_logging_stdout_purity.py   # proves stdout stays JSON-RPC only
├── .env.example
├── pyproject.toml
└── LICENSE

Everything above is MIT licensed and runs as-is. pytest passes 36 tests, including a suite that spawns a subprocess and asserts at the file-descriptor level that no log output ever reaches stdout.

Get the Full Boilerplate

The free core above is a working server with the patterns wired up.

The full $35 package adds the deployment layer:

  • Multi-stage Dockerfile with health check, non-root user
  • Docker Compose with env file support
  • Three real tool implementations beyond the examples here
  • Per-tool rate limits with configurable burst
  • Request ID tracing through the structlog pipeline
  • Integration tests against a mocked MCP client
  • Pre-commit hooks (ruff, mypy)
  • GitHub Actions CI workflow
  • Claude Desktop + Claude Code config
  • Deployment guide with troubleshooting

-> Get FastMCP Python Boilerplate — $35

Related tools

Full lineup: srmcguirt.dev

License

MIT — use it in production, keep it if you never buy anything.

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
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
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
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
E2B

E2B

Using MCP to run code via e2b.

Official
Featured