Menu

A zero-dependency MCP server in one file: what the protocol actually needs
📰

A zero-dependency MCP server in one file: what the protocol actually needs

DEV Community: node·Todd Doane·19 days ago
#nws80T3s
#devtonodejs#devto#dev#tools#server
Reading 0:00
15s threshold

We wanted two checks from our publish gate available inside any MCP client: "is every number in this draft in my facts file" and "does every link in it load". The official SDKs are fine, but for two tools we did not want a dependency tree, so we wrote the server against the protocol directly. It is one file, 119 lines, and it imports only node:fs and node:readline . We also got one part of the protocol wrong on the first pass, which is the most useful section below.

What a stdio MCP server has to do

For a tools-only server on the stdio transport, the job is small:

Read JSON-RPC 2.0 messages from stdin, one per line.

Write one JSON reply per line to stdout. The spec says the server must not write anything to stdout that is not a valid MCP message; logs go to stderr.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.