#!/usr/bin/env python3 # A tools bundle in a second language (novox/hq ADR 0188): MCP over stdio, no SDK, no dependencies. # One tool of its own, one seat verb, and one that exits the process mid-call. import json, sys def say(m): m["jsonrpc"] = "2.0"; sys.stdout.write(json.dumps(m) + "\n"); sys.stdout.flush() TOOLS = [ {"name": "greet", "description": "say hello", "inputSchema": {"type": "object", "properties": {"who": {"type": "string"}}}}, {"name": "node-lamp.on", "description": "the seat's verb", "inputSchema": {"type": "object", "properties": {}}}, {"name": "die", "description": "exit without answering", "inputSchema": {"type": "object", "properties": {}}}, ] for line in sys.stdin: req = json.loads(line); rid = req.get("id"); m = req.get("method"); p = req.get("params") or {} if m == "initialize": say({"id": rid, "result": {"protocolVersion": "2025-03-26", "capabilities": {"tools": {}}, "serverInfo": {"name": "delta", "version": "1"}}}) elif m == "tools/list": say({"id": rid, "result": {"tools": TOOLS}}) elif m == "tools/call": name = p.get("name"); args = p.get("arguments") or {} if name == "greet": say({"id": rid, "result": {"content": [{"type": "text", "text": json.dumps({"greeting": "hello " + args.get("who", "world"), "language": "python"})}]}}) elif name == "node-lamp.on": say({"id": rid, "result": {"content": [{"type": "text", "text": json.dumps({"on": True, "language": "python"})}]}}) elif name == "die": print("delta: told to die", file=sys.stderr); sys.exit(3) else: say({"id": rid, "error": {"code": -32602, "message": "no such tool"}})