nikivdev/code · error

Maple MCP error {code}: {message}

Error message

Maple MCP error {code}: {message}

What it means

This error is raised by `maple_json_rpc_request` when the parsed JSON-RPC envelope contains an `error` object. The library extracts the `code` (defaulting to -1) and `message` (defaulting to 'unknown Maple MCP error') from the error payload and surfaces them. Unlike error 250, the HTTP transport succeeded but the JSON-RPC layer itself reported a failure (e.g. unknown method, invalid params).

Source

Thrown at src/codex_telemetry.rs:427

            serde_json::to_string(&payload)
                .unwrap_or_else(|_| "unparseable error body".to_string())
        );
    }
    let envelope = if let Some(items) = payload.as_array() {
        items.first().cloned().unwrap_or(serde_json::Value::Null)
    } else {
        payload
    };
    if let Some(error) = envelope.get("error") {
        let code = error
            .get("code")
            .and_then(serde_json::Value::as_i64)
            .unwrap_or(-1);
        let message = error
            .get("message")
            .and_then(serde_json::Value::as_str)
            .unwrap_or("unknown Maple MCP error");
        anyhow::bail!("Maple MCP error {code}: {message}");
    }
    envelope
        .get("result")
        .cloned()
        .ok_or_else(|| anyhow::anyhow!("Maple MCP response did not include a result payload"))
}

fn maple_tool_result_error(result: &serde_json::Value) -> Option<String> {
    if result.get("isError").and_then(|value| value.as_bool()) != Some(true) {
        return None;
    }
    result
        .get("content")
        .and_then(|value| value.as_array())
        .and_then(|items| items.first())
        .and_then(|item| item.get("text"))
        .and_then(|value| value.as_str())
        .map(|value| value.trim().to_string())

View on GitHub (pinned to a747e741ae)

Solutions

  1. Read the code/message in the error: fix the tool name or arguments for -32601/-32602.
  2. Dump the exact request arguments passed to `maple_call_tool` and validate them against the tool's input schema.
  3. Confirm the Maple MCP server exposes the requested tool (list tools via the MCP protocol or server docs).
  4. If code is -1 with 'unknown Maple MCP error', capture the raw response body to debug the server-side failure.

Example fix

// before: nonexistent tool name
maple_call_tool("trace.inspect.v2", args)?;
// after: use the tool name the server actually exposes
maple_call_tool("inspect_trace", args)?;
Defensive patterns

Strategy: try-catch

Validate before calling

// validate tool name and arguments against the server's tool list first
let tools = list_maple_tools()?; // JSON-RPC tools/list
if !tools.iter().any(|t| t["name"] == tool_name) {
    return Err(format!("tool {tool_name} not exposed by Maple MCP server"));
}

Type guard

fn json_rpc_error_code(envelope: &serde_json::Value) -> Option<i64> {
    envelope.get("error")?.get("code")?.as_i64()
}

Try / catch

match maple_json_rpc_request(&payload) {
    Err(e) if e.to_string().starts_with("Maple MCP error ") => {
        let code = extract_code(&e); // e.g. -32601 method not found
        eprintln!("JSON-RPC error {code}: adjust method/args: {e}");
    }
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: `maple_json_rpc_request` (called by `maple_call_tool` and `trace_status`) receives a 2xx response whose JSON body contains an `error` field, e.g. code -32601 (method not found) or -32602 (invalid params), and bails with `Maple MCP error {code}: {message}`.

Common situations: Calling a Maple tool name that does not exist on the server, passing arguments that fail server-side schema validation, using an MCP client protocol version the server rejects, or a server bug that returns a JSON-RPC error with no message (surfaced as 'unknown Maple MCP error').

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/9d62102bc8cac97d. Report an issue: GitHub.