Validate the protocol envelope before routing a tool: JSON-RPC version, request ID, method, and capability must be explicit.
Required APIdef validate_jsonrpc(message, supported_version, methods):
return {'valid': ..., 'kind': ..., 'error': ...}BehaviorThink through the mechanism first if you want the extra reasoning step. It never blocks the editor.
validate_jsonrpc({'jsonrpc': '2.0', 'id': 1, 'method': 'tools/list'}, '2.0', ['tools/list'])a valid protocol envelope reaches the capability layer
validate_jsonrpc({'jsonrpc': '2.0', 'id': 1, 'method': 'shell'}, '2.0', ['tools/list'])unknown protocol methods fail closed
2 hidden edge tests run after the visible contract passes.
Run Tests to see the contract verdicts here.