Negotiate the MCP session
Implement initialize and advertise server identity and capabilities.
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.
MCP Handshake (Initialize Negotiation)
Before calling tools, an MCP client initiates an exchange via initialize to negotiate protocol versions and discover capabilities.
Mental Model: Initialize Handshake
- Initialize Request: Supplies
protocolVersion,capabilities, andclientInfo. - Initialize Response:
- Echoes
protocolVersion: "2025-06-18". - Declares
capabilities: {"tools": {}, "resources": {}}. - Identifies server via
serverInfo: {"name": "shipcode-mcp", "version": "1.0.0"}.
- Echoes
Your Goal in this Stage
Handle "initialize" requests and return server capability metadata.
Input Format
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": { "name": "tests", "version": "1" }
}
}
Output Format
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-06-18",
"capabilities": { "tools": {}, "resources": {} },
"serverInfo": { "name": "shipcode-mcp", "version": "1.0.0" }
}
}
Step-by-Step Implementation Guide
- Match
"initialize"method: - Assemble response result:
protocolVersion: "2025-06-18"capabilities: { tools: {}, resources: {} }serverInfo: { name: "shipcode-mcp", version: "1.0.0" }
- Emit output: Print JSON response with matching
id.
Acceptance Criteria
- ✅ Returns standard MCP initialize payload.
- ✅ Preserves ping capability.
Supported version
This project implements 2025-06-18. Return it when requested and offer it when a different version is requested. Do not echo an unsupported version. The client decides whether to accept the alternative. After the handshake it sends notifications/initialized, which produces no response. Exit cleanly at EOF.
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.