MCP Server Template (Python) MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/futhgar/mcp-server-template.git
cd mcp-server-template
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add mcp-server-template -- node "<FULL_PATH_TO_MCP_SERVER_TEMPLATE>/dist/index.js"

Replace <FULL_PATH_TO_MCP_SERVER_TEMPLATE>/dist/index.js with the actual folder you prepared in step 1.

README.md

A minimal, well-structured starter template for building MCP servers in Python.

mcp-server-template

A minimal, well-structured starter template for building Model Context Protocol (MCP) servers in Python using FastMCP.

What is MCP?

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.

What this template provides

  • A working MCP server with example tools you can run immediately
  • Clean project structure using modern Python packaging (pyproject.toml)
  • Type hints, docstrings, and error handling patterns to follow
  • Test setup showing how to verify your tools work
  • Linting config with Ruff

Clone it, delete the example tools, add your own, and you have a production-ready MCP server.

Quick start

# 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

Project structure

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

Adding your own tools

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:

  • The function name becomes the tool name the model calls.
  • The docstring becomes the tool description the model reads to decide when to use it.
  • Type hints on parameters are required — they define the tool's input schema.
  • Return a string (or something that serializes to string). The model reads the return value.
  • Raise exceptions for errors — FastMCP handles them and reports them to the client.

Delete the example tools (system_info, find_files, word_frequency) once you understand the pattern.

How to test

# 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.

Connecting to Claude Desktop

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.

Resources

License

MIT License. See LICENSE for details.

Tools (3)

system_infoProvides information about the system environment.
find_filesSearches for files within the project directory.
word_frequencyCalculates the frequency of words in a given text.

Configuration

claude_desktop_config.json
{"mcpServers": {"my-server": {"command": "python", "args": ["-m", "src.server"], "cwd": "/path/to/mcp-server-template"}}}

Try it

Get the current system information using the system_info tool.
Find all files matching the pattern *.py in the current directory.
Calculate the word frequency for the following text: 'The quick brown fox jumps over the lazy dog'.

Frequently Asked Questions

What are the key features of MCP Server Template (Python)?

Clean project structure using modern Python packaging with pyproject.toml. Includes example tools to demonstrate MCP server implementation. Built-in test setup using pytest to verify tool functionality. Linting configuration provided via Ruff. Uses FastMCP framework for simplified tool definition and error handling.

What can I use MCP Server Template (Python) for?

Developers looking to quickly bootstrap a new MCP server project in Python. Learning how to implement custom tools for AI models using the Model Context Protocol. Creating a production-ready foundation for custom LLM-integrated internal tools.

How do I install MCP Server Template (Python)?

Install MCP Server Template (Python) by running: git clone https://github.com/futhgar/mcp-server-template.git && cd mcp-server-template && python -m venv .venv && source .venv/bin/activate && pip install -e ".[dev]"

What MCP clients work with MCP Server Template (Python)?

MCP Server Template (Python) works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MCP Server Template (Python) docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare