Speak JSON-RPC
Process line-delimited ping requests and preserve their identifiers.
Build it in your language
The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.
JSON-RPC 2.0 Framing Loop (Ping)
The Model Context Protocol (MCP) relies on JSON-RPC 2.0 over standard input/output streams (stdin / stdout), framed by newline delimiters (\n).
Mental Model: Stdio JSON-RPC Communication
- Client Request: Arrives via stdin:
{"jsonrpc": "2.0", "id": 1, "method": "ping"}. - Request ID: Can be numeric or string (
1or"p-2"). The response must echo the exact ID. - Ping Response: Responds with an empty object under
result:{"jsonrpc": "2.0", "id": <id>, "result": {}}.
Your Goal in this Stage
Listen on stdin line by line, handle "ping" requests, and emit matching JSON-RPC responses to stdout.
Input Format
{ "jsonrpc": "2.0", "id": 1, "method": "ping" }
Output Format
{ "jsonrpc": "2.0", "id": 1, "result": {} }
Step-by-Step Implementation Guide
- Line reader: Process newline-separated lines from stdin.
- Parse JSON: Extract
jsonrpc,id, andmethod. - Handle
"ping": Construct response with matchingidand emptyresult: {}. - Emit output: Print JSON string with trailing newline to stdout.
Acceptance Criteria
- ✅ Echoes the incoming
id(supports number and string types). - ✅ Returns
result: {}for"ping"requests.
Starting and checking progress
Open your language starter’s README. From its root, execute the build command in shipcode.yml if present, then run. The scaffold is intentionally unfinished and initially reports missing implementation. After developing this stage, run shipcode test; preserve earlier stages’ behavior and use shipcode submit after passing.
You may use a JSON library for the input/output envelope, but not to implement the project’s algorithm. If your language has no built-in JSON support, document the dependency and update the shipcode.yml build command; verify installation in a clean directory.
Snippets using Math, .shift(), or similar notation illustrate algorithm ideas; they do not require JavaScript. Adapt them to your language. A byte is not always a character: count bytes in binary formats and specify the encoding.
Output and errors
Multiline examples are formatted for readability. Emit compact JSON without optional spaces, with properties in the order shown by the output examples, and a final newline. Keep logs off stdout. Tests compare exact text.