‹ Harness Lab
STAGE 3 · MCP FROM SCRATCH

MCP, Implemented Raw

A real JSON-RPC 2.0 server running in this page: parse, dispatch, error objects, notifications. No SDK, no framework, no mock: the same code ships as a Node stdio server.

Product database (server state)

db.restock mutates this table. vault.secret only answers when the scoped token is presented.

Raw request console

Quick buttons load a sample request and send it. Edit freely, then Send.

Raw response

No request sent yet.

The same server, over stdio

The dispatch function below is mirrored line for line in mcp-server.mjs, a dependency-free Node program that reads one JSON-RPC message per line on stdin and writes responses to stdout. A test client ships next to it:

node mcp-server.mjs          # the server, waiting on stdin
node mcp-client-test.mjs     # spawns it, runs initialize, tools/list,
                             # db.query, and vault.secret with and
                             # without the token, prints the transcript

That mapping is the whole lesson: MCP is JSON-RPC over a pipe. The page is a demo surface; the protocol is identical.

What this proves