loading…
Search for a command to run...
loading…
A minimal, well-structured starter template for building Model Context Protocol (MCP) servers using Python and the FastMCP framework. It includes boilerplate fo
A minimal, well-structured starter template for building Model Context Protocol (MCP) servers using Python and the FastMCP framework. It includes boilerplate for tools, testing setup, and modern Python packaging to accelerate server development.
A minimal, well-structured starter template for building Model Context Protocol (MCP) servers in Python using FastMCP.
The Model Context Protocol is an open standard that lets AI assistants (Claude, GPT, etc.) call external tools and access data sources through a unified interface. An MCP server exposes tools that AI models can discover and invoke — think of it as building an API specifically designed for LLM consumption.
pyproject.toml)Clone it, delete the example tools, add your own, and you have a production-ready MCP server.
# Clone the template
git clone https://github.com/futhgar/mcp-server-template.git
cd mcp-server-template
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"
# Run the server
python -m src.server
The server starts in stdio mode by default, which is how MCP clients (like Claude Desktop) communicate with it. To test it interactively:
# If you have the MCP inspector installed
mcp dev src/server.py
mcp-server-template/
├── src/
│ ├── __init__.py
│ └── server.py # MCP server definition and tools
├── tests/
│ └── test_server.py # Tool tests
├── pyproject.toml # Project config, dependencies
├── LICENSE
├── .gitignore
└── README.md
Open src/server.py and add a new function decorated with @mcp.tool():
@mcp.tool()
def my_tool(query: str, limit: int = 10) -> str:
"""Short description of what this tool does.
The docstring becomes the tool's description that the AI model sees,
so write it clearly — explain what the tool does, what the parameters
mean, and what it returns.
Args:
query: What to search for.
limit: Maximum number of results to return.
"""
# Your logic here
results = do_something(query, limit)
return format_results(results)
Key points:
Delete the example tools (system_info, find_files, word_frequency) once you understand the pattern.
# Run tests
pytest
# Run tests with output
pytest -v
# Lint
ruff check src/ tests/
The test file shows how to call your tool functions directly. Since MCP tools are regular Python functions under the hood, you can test them without spinning up a server.
Add your server to Claude Desktop's config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"my-server": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/mcp-server-template"
}
}
}
Restart Claude Desktop and your tools will appear in the tool picker.
MIT License. See LICENSE for details.
Add this to claude_desktop_config.json and restart Claude Desktop.
{
"mcpServers": {
"mcp-server-template-python": {
"command": "npx",
"args": []
}
}
}