Resources & Protocol
JSON-RPC 2.0 Protocol
Transport framing, handshake lifecycle, supported MCP methods, and JSON-RPC 2.0 error codes in ochreml mcp.
ochreml mcp implements MCP protocol version 2024-11-05 over line-delimited JSON-RPC 2.0 on stdin and stdout (python/ochreml/_mcp.py).
- Server Name:
ochreml-mcp - Capabilities:
{"tools": {}, "resources": {}} - Transport: One compact JSON object per line (
\n-terminated) onstdin/stdout; optional debug logs onstderrwhenOCHREML_DEBUG=1.
Supported Methods
| Method | Kind | Description |
|---|---|---|
initialize | Request | Handshake returning protocolVersion ("2024-11-05"), capabilities, and serverInfo (name, version). |
notifications/initialized | Notification | Client lifecycle acknowledgement; produces no response (None). Any notifications/* message without an id is also ignored without reply. |
ping | Request | Liveness check returning {}. |
tools/list | Request | Returns {"tools": [...]} with the JSON schemas for all 9 MCP tools. |
tools/call | Request | Executes params.name with params.arguments. Returns {"content": [{"type": "text", "text": "<json>"}], "isError": bool}. |
resources/list | Request | Returns {"resources": [...]} listing ochreml://catalog/estimators and ochreml://catalog/nn. |
resources/read | Request | Reads params.uri and returns {"contents": [{"uri", "mimeType": "application/json", "text": "<json>"}]}. |
Handshake Example
Request:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}Response:
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{},"resources":{}},"serverInfo":{"name":"ochreml-mcp","version":"0.3.7a1"}}}Tool Errors vs. Protocol Errors
ochreml mcp distinguishes between tool execution errors and JSON-RPC protocol errors:
- Tool execution errors (missing file, path traversal outside
--root, invalid.ditextension, bad hyperparameter, unknown tool name) return a normal JSON-RPCresultwith"isError": trueso the LLM can read the error message and recover:
{
"jsonrpc": "2.0",
"id": 6,
"result": {
"content": [
{
"type": "text",
"text": "{\"error\": \"Access denied: path '../secret.csv' escapes allowed MCP root '/workspace' ( >_< )\"}"
}
],
"isError": true
}
}- Protocol errors return a standard JSON-RPC
errorobject:
| Code | Meaning | Trigger |
|---|---|---|
-32700 | Parse error | Malformed JSON line on stdin. |
-32600 | Invalid Request | Non-object JSON payload or missing method string. |
-32601 | Method not found | Unknown JSON-RPC method. |
-32602 | Invalid params | Non-string name or non-object arguments in tools/call, or unknown uri in resources/read. |
-32603 | Internal error | Unhandled server-level exception outside tool dispatch. |
ochreml://catalog/nn
Read-only MCP resource exposing ochreml.nn modules, layers, activations, Transformer/LLM blocks, LoRA, losses, and optimizers.
Architecture & Latency
How ochreml mcp achieves zero-dependency JSON-RPC 2.0 over stdio, shares core logic with the CLI via _ops.py, and benchmarks on CPU and CUDA.