Claude Code MCP: build your own tiny MCP server in Python in 15 minutes A developer built a small read-only MCP server in Python using the official MCP Python SDK that exposes a folder of Markdown runbooks to Claude Code through two tools, list_runbooks and read_runbook, with path-traversal checks blocking access outside the directory. The server is tested in the MCP Inspector, connected to Claude Code via the claude mcp add command, and shared with teammates through a project-scoped .mcp.json that uses environment-variable expansion for per-user paths. Because both tools are read-only, the whole server can be allowlisted in .claude/settings.json without prompts. By Elena Novak, NBT Most Claude Code MCP guides are about connecting other people's servers. Building your own is often more useful: a 30-line server can give Claude safe, structured access to the internal things it otherwise guesses about, such as your feature flags, your on-call runbook or a read-only view of a staging database. This post builds a small but real server with the official MCP Python SDK, tests it, connects it to Claude Code and tightens its permissions. The SDK details come from the SDK's README and the "Build an MCP server" guide at modelcontextprotocol.io; the Claude Code details from code.claude.com. All were checked on 6 December 2026. A runbook server that exposes the Markdown files in a runbooks/ folder: list runbooks that returns the available runbook names read runbook name that returns one runbook's text, and refuses paths outside the folder It's read-only by design, which makes it easy to allow without prompts. The SDK needs Python 3.11 or later. With uv : uv init runbook-mcp cd runbook-mcp uv add "mcp cli " mkdir runbooks printf " Restart the API\n\n1. Check the health endpoint.\n2. Run the deploy rollback.\n" runbooks/restart-api.md pip install "mcp cli " works too. The cli extra adds the mcp command, which we'll use to test. Create server.py : python import logging from pathlib import Path from mcp.server import MCPServer logger = logging.getLogger name logs go to stderr RUNBOOK DIR = Path file .parent / "runbooks" .resolve mcp = MCPServer "runbooks" @mcp.tool def list runbooks - list str : """List the names of all available runbooks.""" return sorted p.stem for p in RUNBOOK DIR.glob " .md" @mcp.tool def read runbook name: str - str: """Return the full text of one runbook, by name without .md .""" path = RUNBOOK DIR / f"{name}.md" .resolve if RUNBOOK DIR not in path.parents: raise ValueError "Runbook name must not contain a path." if not path.exists : raise ValueError f"No runbook named {name r}. Call list runbooks first." logger.info "read runbook %s", name return path.read text encoding="utf-8" if name == " main ": mcp.run transport="stdio" Some things worth noticing: name: str and - list str become the tool's input and output definitions. You don't write any JSON Schema. print in a stdio server. logging , which writes to stderr. uv run mcp dev server.py This opens the MCP Inspector, where you can call list runbooks and read runbook with test inputs. Try read runbook "../server" and confirm it's refused. It's much faster to fix a server here than by asking Claude why it's confused. From your application's repository not the server's folder , add the server. Everything after -- is the command that starts it: claude mcp add runbooks -- uv --directory /ABSOLUTE/PATH/TO/runbook-mcp run server.py Check that it connected: claude mcp get runbooks claude mcp list claude mcp list shows a status next to each server, such as ✔ Connected or ✘ Failed to connect . Inside a session, /mcp shows the same. To commit the server configuration for everyone, use project scope: claude mcp add --scope project runbooks -- uv --directory /ABSOLUTE/PATH/TO/runbook-mcp run server.py This writes a .mcp.json in the repository. Since each teammate's path differs, edit the path in .mcp.json to ${RUNBOOK MCP DIR} : Claude Code expands environment variables in .mcp.json , so each person sets their own and ${VAR:-default} supplies a fallback . Teammates are asked to approve project servers before they connect, which is the right default. Keep secrets out of .mcp.json . If your server needs a token, read it from an environment variable each person sets. MCP tools are named mcp