Stage 3 of 5v1 · afc51c9e
Publish and invoke tools
Add discovery and validated execution for echo and add.
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.
Tool Discovery and Execution (tools/list and tools/call)
MCP tools let AI agents execute actions on the server via two endpoints:
tools/list: Discovers available tool schemas.tools/call: Invokes a tool with specific parameters.
Mental Model: Tool Manifest and Invocation
- Manifest (
tools/list):"add": Takes numbersaandb."echo": Takes stringtext.
- Invocation (
tools/call):- Evaluates arguments and returns results in a
contentarray withisError: false.
- Evaluates arguments and returns results in a
Your Goal in this Stage
Implement tools/list for schema discovery and tools/call for execution.
Input Format (tools/list)
{ "jsonrpc": "2.0", "id": 3, "method": "tools/list" }
Output Format (tools/list)
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"tools": [
{
"name": "add",
"description": "Add two numbers",
"inputSchema": {
"type": "object",
"properties": {
"a": { "type": "number" },
"b": { "type": "number" }
},
"required": ["a", "b"],
"additionalProperties": false
}
},
{
"name": "echo",
"description": "Echo text",
"inputSchema": {
"type": "object",
"properties": { "text": { "type": "string" } },
"required": ["text"],
"additionalProperties": false
}
}
]
}
}
Input Format (tools/call)
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": { "name": "add", "arguments": { "a": 2.5, "b": 4 } }
}
Output Format (tools/call)
{
"jsonrpc": "2.0",
"id": 4,
"result": { "content": [{ "type": "text", "text": "6.5" }], "isError": false }
}
Step-by-Step Implementation Guide
- Handle
"tools/list": Return catalog withaddandechotool schemas. - Handle
"tools/call":- For
add: add numbers and stringify sum. - For
echo: stringify text argument.
- For
- Emit output: Print JSON response with matching
id.
Acceptance Criteria
- ✅ Discloses
addandechoschemas. - ✅ Correctly executes tool requests.
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.