Please explain the MCP protocol and components, providing examples of usage
Assistant
MCP in a nutshell
When people in the MUD¹ world say “MCP” they almost always mean MUD Client Protocol.
It is an out-of-band (i.e. machine-readable) message layer that rides on top of the ordinary plain-text, line-oriented Telnet connection a MUD already uses.
Why was it invented?
Traditional MUD traffic is just text that scrolls in your terminal. MCP lets the server and a capable client exchange structured data without disturbing that text stream, enabling things such as:
graphical spell-cool-down bars
in-client editors (e.g. upload/download a whole description)
mapper synchronisation
inventory windows, health bars, etc.
1. How does MCP sit in the connection?
code
(TCP) <------> TELNET <------> plain text lines (the game)
\_ MCP messages start with "#$#"
Nothing special needs to be added at the transport level; we just reserve any line that begins with #$# for MCP.
2. Core components
Component
Purpose
Mini-example
Handshake packagesmcp and mcp-negotiate
Client & server prove they both speak MCP, negotiate a version, and agree on a one-time authentication key.
See “Example session” below
Message line prefix#$#
Makes the line invisible to old text-only clients (they treat it as a blank line) but easy for an MCP-aware client to spot.
#$#mcp ...
Package name
Names a namespace of related commands.Reverse-DNS notation is recommended to avoid clashes.
dns-org-mud-gui
Command (verb)
What to do inside that package.
dns-org-mud-gui.health
Key–value args
Data is sent as a list of key: value pairs separated by spaces.
hp: 83/100 color: red
Multiline arguments
Big blobs (maps, files, code) are sent using “” so they can span many lines without breaking Telnet’s line orientation.
User
I meant the Model Context Protocol by Anthropic
Assistant
continuation tags
text: *abc123#*abc123 This is the first data line
Authentication key
Every MCP message must echo the handshake’s random key. Prevents random text from being mis-parsed.
• All on a single line unless you explicitly start a multiline value
• Order of arg: pairs is irrelevant
• Whitespace inside a value must be quoted or put into a multiline block
4. Walk-through: first 30 seconds of a connection
code
Client connects … sees typical MOTD text …
Server → Client
#$#mcp version: 2.1 to: 2.1 authentication-key: 63e10b
Client → Server
#$#mcp authentication-key: 63e10b version: 2.1
(Server now knows the client understands MCP 2.1)
Server → Client
#$#mcp-negotiate-can authkey: 63e10b package: dns-org-mud-gui min-version: 1.0 max-version: 1.2
Client → Server
#$#mcp-negotiate-package authkey: 63e10b package: dns-org-mud-gui version: 1.2
(... negotiation done – both sides may now use dns-org-mud-gui.* messages)
#$#dns-org-mud-simpleedit.open authkey: 63e10b id: 978 prompt: RoomDesc len: 254 text: *edit978
#*edit978 This is the existing long description
#*edit978 It already contains newlines.
#*edit978 .
Client pops up its own editor window, user edits, then client returns the buffer:
code
#$#dns-org-mud-simpleedit.save authkey: 63e10b id: 978 text: *edit978
#*edit978 A bright, sun-dappled forest clearing stretches to the north.
#*edit978 The scent of pine mixes with the chatter of unseen birds.
#*edit978 .
Client side
• TinyFugue 5 / 6 (built-in MCP)
• Mudlet (script package available)
• BeipMU, MUSHclient, Vadi’s kMud – all have MCP modules
Server side
• PennMUSH (core support)
• RhostMUSH, TinyMUSH via patches
• Evennia (Python) – plugin available
• LPMud, Diku derivatives – various 3rd-party libs
7. Common pitfalls
Forgetting authkey: in follow-up messages → client ignores them.
Not quoting spaces or special chars in single-line values.
Attempting to nest MCP messages – you can’t; use more package.commands.
Version mismatch: always advertise min/max in mcp-negotiate-can.
8. Relationship to GMCP
GMCP (Generic MUD Client Protocol) is a newer, JSON-based offshoot.
It simplifies parsing and skips the authentication key, but conceptually fills the same niche. Many modern clients implement both MCP and GMCP.
¹ MUD = “Multi-User Dungeon”, the text-based fore-runner to MMOs.
🎉 That’s the MCP ecosystem at a glance. With these building blocks you can start adding rich, structured UI extensions to a 30-year-old text protocol—without breaking plain Telnet compatibility. Happy hacking!
Below is a concise “field-manual” style overview of Anthropic’s Model-Context Protocol (MCP)—the lightweight, line-delimited JSON format Anthropic services use to ship conversation state back-and-forth between:
• the Orchestrator (e.g. a chat backend, RAG pipeline, tool-caller, etc.)
• the underlying Claude model runtime.
The goal is to let many different systems compose a single linear context that the model can faithfully replay: system policies → memory → user messages → tool calls → assistant messages, etc.
Think of it as “HTML for an LLM prompt.”
Wire / framing
• Transport-agnostic — usually sent over HTTP(S) in the body of a /complete or
/messages call, or over a WebSocket in streaming mode.
• Each record is a one-line UTF-8 JSON object.
• Lines are delimited with either “\n” or the ASCII Record-Separator (0x1E) when
multiplexed inside a single streaming channel.
All records MUST be in the order you want them to appear in the final prompt.
The model sees the concatenation of the content fields (plus a role marker) exactly in that order.
Encoding rules & nudges
One JSON object per line, no trailing commas.
Everything that isn’t content should be small (<1 KB) because it counts
against the context window.
Binary blobs (images, PDFs) should be passed as URLs in attachments or
pre-processed into embeddings—don’t inline base64 unless the model version
explicitly supports it.
tool_call and tool_result pairs share the same id via call_id, letting the model
correlate responses.
Always send an explicit version in the opening record to stay forward-compatible
(current public API versions are “1.0” and “1.1”).
End-to-end walkthrough
Below is a skeletal TypeScript/Node example that:
• Opens a stream
• Gives Claude some system policy
• Injects a user message
• Surfaces a tool call & response
• Closes the context
ts
import fetch from "node-fetch";
import { v4 as uuid } from "uuid";
const session = uuid();
const lines = [
{ type: "open", version: "1.1", session_id: session },
// 1) System instruction
{ type: "system",
id: "sys1",
content: "You are a concise, upbeat travel assistant." },
// 2) Long-term memory
{ type: "memory",
id: "mem1",
content: "User's home airport is SFO." },
// 3) User request
{ type: "user",
id: "u1",
content: "Find me a beach destination under 6 h flight time." }
];
// Send the “setup” context
const body = lines.map(l => `\u001e${JSON.stringify(l)}`).join("") + "\n";
const resp = await fetch("https://api.anthropic.com/v1/complete", {
method: "POST",
headers: {
"x-api-key": process.env.CLAUDE_KEY,
"content-type": "application/mcp+jsonl; charset=utf-8"
},
body
});
// — later, inside your stream handler —
/*
Model emits:
{"type":"assistant","id":"a1","content":"Let me look that up…"}
{"type":"tool_call","id":"call1","name":"flightSearch",
"arguments":{"from":"SFO","duration":"<6h"}}
Your orchestrator runs flightSearch() and then sends:
{"type":"tool_result","call_id":"call1",
"content":{"destinations":["Cabo","Honolulu"]}}
Model resumes; returns an 'assistant' record with the final answer
*/
Comparison with OpenAI “chatml”
• ChatML is a nested array of dicts ([{role,content}, …]).
• MCP is a flat stream of role-tagged events.
• MCP explicitly models tool-calls / errors / memory as first-class records.
• Streaming: MCP’s one-object-per-line makes incremental decoding trivial.
Gotchas & best practices
Do not interleave two tool_call records without closing the first with a
tool_result; models rely on deterministic pairing.
The model only “sees” stringified content. All other keys are invisible
(they’re for the orchestrator / post-processing).
Avoid huge system blocks: put static policy in a single record and keep it
cached.
Version bumps (e.g. 1.0 → 1.1) normally mean added fields, never breaking
removal—but still gate new fields behind feature flags in prod code.
Minimal cheat-sheet
code
open → start of context
system → high-level instructions
memory → long-lived user facts
user → end-user utterance
assistant → model’s words / draft
tool_call → model asks you to run something
tool_result → your answer goes back to the model
error → optional troubleshooting record
close → end of stream
That’s the essentials of Anthropic’s Model-Context Protocol. Once you can
serialise those records in order, you can weave together prompts, memories,
and tool invocations into a single, deterministic context that Claude can
replay and extend. Happy hacking!