Python MCP Server Template

See exactly how an MCP server works in under 100 lines of Python, then ship your own tools on it today.

Python MCP Server Template cover

What it is

The smallest complete MCP server we could write in plain Python: one file of protocol code, one file of tools, no SDK, no pip install. Copy the folder, rename it, replace the two example tools with yours, and connect it to Claude Code, Cursor or Claude Desktop. Includes mcp_probe.py, a tiny MCP client that tests any stdio server (yours or someone else's) the way a real client does.

What you get

The screenshot is real output from the kit’s own commands. Tested from a fresh download of this exact zip: ./run_tests.sh ran 11 tests OK on Python 3.13 and 3.10.

Real terminal output from Python MCP Server Template: demo and passing tests

What's inside

FileWhat it is
server.pyentry point: name, version, instructions, tool table
myserver/tools.pyyour tools: two examples (text_stats, convert_units) showing return values, input validation and ToolError
myserver/mcpcore.pythe protocol: JSON-RPC over stdio, server/discover, initialize, tools/list, tools/call, errors (under 100 lines)
mcp_probe.pyclient: tries MCP 2026-07-28 server/discover, falls back to the initialize handshake, lists tools, calls one
tests/11 tests: both protocol eras, error codes, your tools, the probe against a legacy-only server
.claude-plugin/, .mcp.jsonso the folder also installs as a Claude Code plugin

Protocol

It speaks MCP 2026-07-28 (stateless: every request carries its version in _meta, server/discover, resultType and server info on results, cache hints on lists) and the handshake revisions 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05 on the same process, as the spec's "dual-era" server. Newer clients (for example Claude Code's v2 MCP runtime) use the stateless path; older ones keep working.

Add a tool (3 steps)

1. Write a function in myserver/tools.py that takes keyword arguments and returns a dict. 2. Add it to TOOLS: "name": (function, "what it does and when to use it", {json schema properties}, ["required"], {"readOnlyHint": True}). 3. Add a test in tests/test_template.py, run ./run_tests.sh, then python3 mcp_probe.py --call name '{"arg": 1}' -- python3 server.py.

Raise ToolError("message") for problems the model should see and fix (bad input, not found). Anything else becomes a JSON-RPC internal error and is logged to stderr. Never print to stdout: stdout is the protocol channel.

Connect it

claude mcp add my-server -- python3 /absolute/path/to/server.py         # Claude Code

Cursor: examples/configs/cursor-mcp.json into .cursor/mcp.json. Claude Desktop: merge examples/configs/claude_desktop_config.json.

Honest limits

  • stdio only (local servers). For a deployed HTTP server with auth, rate limits and a registry kit, see the MCP Starter Kit (TypeScript).
  • Tools only: no resources, prompts, sampling or the tasks extension.

Want a real server built on this core? See the GitHub Issue Triage MCP Server. More at https://youraitools.co/marketplace. License: LICENSE.txt (free, keep the notice).

Format and license

Zip, 13 KB, v1.0, 15 files. Free to use, modify and share for any purpose, including commercial work, as long as this notice stays in copies. Not affiliated with or endorsed by Anthropic or the Model Context Protocol project.

FAQ

Is this the official MCP SDK?
No, it's a small standalone implementation; use the official SDK if you need HTTP, resources or prompts.
Does it work with Claude Code and Cursor?
Yes, as a local stdio server; newer clients use the 2026-07-28 path, older ones the handshake.
Is it free for commercial use?
Yes, keep the license notice.
How do I get the files?
Click Download free. The zip downloads straight away: no checkout, no account.
Do I have to sign up for the newsletter?
No. The form is optional and the download works without it.

Get Python MCP Server Template

Free Python MCP server template with no dependencies: stdio server for MCP 2026-07-28 and 2025 clients, two example tools, tests and a probe client.

Pairs well with

Download$19

DevOps & SRE Subagents for Claude Code

10 Claude Code subagents for DevOps and SRE: incident triage, Terraform plan review, Kubernetes, CI fixes, alerts, postmortems. Guard hook blocks destroy. $19.

View DevOps & SRE Subagents for Claude Code
Download$19

Data & Analytics Subagents for Claude Code

10 Claude Code subagents for data teams: SQL and dbt review, query tuning, data quality, metrics, A/B tests. SQL guard blocks DROP and unfiltered DELETE. $19.

View Data & Analytics Subagents for Claude Code
Download$39

Claude Code Subagents Bundle

30 Claude Code subagents: code review, security, tests, DevOps/SRE, Terraform, Kubernetes, SQL, dbt, data quality. Guard hooks included. $39 ($57 separately).

View Claude Code Subagents Bundle

Related