Stateless MCP Server for a Real Data Source
Wrap a real data source of your choice in a stdio MCP server that follows the 2026-07-28 stateless contract, with well-designed tools, resources, a prompt, and wire-level conformance tests.
Lessons this project uses
- 1Tool Schema Design - Naming, Descriptions, Parameter ConstraintsPhase 13: Tools and protocols
- 2MCP Fundamentals: Stateless Requests and JSON-RPCPhase 13: Tools and protocols
- 3Building an MCP Server: Stateless Python and TypeScriptPhase 13: Tools and protocols
- 4MCP Transports: stdio and Stateless Streamable HTTPPhase 13: Tools and protocols
- 5MCP Resources and Prompts: Addressable Context for Stateless ServersPhase 13: Tools and protocols
- 6MCP Tool Contracts and ContentPhase 13: Tools and protocols
What You'll Build
An MCP server that exposes a real data source you care about through the stateless MCP 2026-07-28 contract taught in lessons 06 and 07: every request carries its own metadata, server/discover is implemented, and there is no handshake or protocol session. Pick one source: a free no-key public HTTP API (weather, public transport, a library catalog, an open government dataset) or a local open dataset loaded into SQLite or CSV (your shop's product list, a city's bus stops, a public holiday calendar). You also write a small stdio client script and tests that check the wire, not just your Python functions.
Requirements
- Transport. Newline-delimited JSON-RPC 2.0 over stdio: only JSON-RPC messages on stdout, diagnostics on stderr, flush per response, exit promptly on stdin EOF, and no response to notifications (lesson 09).
- Per-request validation. Every request must carry
io.modelcontextprotocol/protocolVersionandio.modelcontextprotocol/clientCapabilitiesinparams._meta. Missing or malformed metadata returns-32602. An unsupported version returns-32022withdata.requestedanddata.supported. The server must never reuse metadata from an earlier request; prove it with a test. - Discovery.
server/discoverreturnsresultType: "complete",supportedVersions,capabilities, shortinstructions,ttlMs,cacheScope, and server identity in result_meta. Every successful result carriesresultTypeand server identity. - Tools (at least 3, atomic). Follow lesson 05:
snake_caseverb-noun names with a namespace prefix, descriptions in the "Use when X. Do not use for Y." form under 1024 characters,additionalProperties: false, enums for closed sets, apatternon any ID field, and annotations (readOnlyHintand friends) as hints only. At least one tool declares anoutputSchemaand returns matchingstructuredContentplus a serialized text block. - Two error layers. Unknown tool or invalid arguments is a JSON-RPC error. A valid call whose execution fails (upstream down, date out of range, no match) returns
isError: truewith a message written to teach the model what to try next, still conforming to the output schema if one is declared (lesson 28). - Resources and a prompt.
resources/list(deterministic order, cache hints) andresources/readfor at least two URIs in your own namespace (for examplebusstops://stop/1234); an unknown URI returns-32602. One prompt viaprompts/listandprompts/get. ChoosecacheScopedeliberately and explain the choice. - Offline determinism. If you use a live API, record fixtures so tests and the demo can run with no network (
--offline). Lists must come back in the same order regardless of insertion order. - Client script and tests.
client.pylaunches the server as a subprocess and runs a scripted session: discover, list tools, call every tool once, read a resource, get the prompt, send one unsupported-version request. Save the full request and response transcript toresults/transcript.jsonl. Write at least 12 tests covering requirements 1 to 6.
Constraints
- Python 3 standard library is enough (the lesson servers use only stdlib); TypeScript is also fine. If you use an MCP SDK, it must produce the
2026-07-28per-request behavior above, and your tests must still assert on raw JSON lines. - No paid API keys. Runs on any laptop CPU. No model is required to build or test the server.
- Treat data from the source as untrusted content, not instructions; do not echo it into tool descriptions.
- Bind nothing to a network port; this project is stdio only.
Stretch Goals
- Add
resources/templates/listand a cursor-paginatedtools/listwhere an empty-string cursor is handled correctly. - Connect the server to a real MCP host or to a tool-calling loop backed by any OpenAI-compatible endpoint or local model, and show one real model-driven call.
- Add the Streamable HTTP binding from lesson 09 on loopback only, with Origin validation.
How to Submit
Public GitHub repo with README.md, server.py, client.py, tests/, fixtures/ (if using a live API), and results/transcript.jsonl. The README must state the data source and why you chose it, how to run the server, the client and the tests (online and offline), a table of your tools with their annotations, your cache-scope choices, and a short reflection on one contract mistake your tests caught. Paste the client output and the test output when submitting.
How It's Reviewed
Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.
Submit
Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.
- Full terminal output of python client.py (or the offline variant)
- The first 20 lines of results/transcript.jsonl, including the discover request and the -32022 error
- Full output of the test run
- Your tools/list response showing names, descriptions and schemas
- One paragraph naming the data source and a contract mistake your tests caught
Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.