An MCP server is a program that reads JSON-RPC from standard input and writes JSON-RPC to standard output. The SDK hides that, which is convenient until something does not work — at which point the frames below are the only thing that tells you where the failure is.

The whole server

Using the official Python SDK (pip install mcp). This is a complete, runnable server: two tools and one resource.

# server.py

import sys, sqlite3, logging