Skip to main content
Glama

Rake

Decode a RISC-V trap cause

decode_riscv_trap
Read-onlyIdempotent

Decodes the mcause value of a 32-bit RISC-V core into the exception or interrupt it names, and says what mepc and mtval hold for that cause and what to check. Use it when a RISC-V microcontroller, such as an ESP32-C3 or a GD32V, stops in its trap handler and the register values are known. It covers the causes of the RISC-V privileged specification, not vendor-specific ones.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "mcause": "<mcause>"
    },
    "name": "decode_riscv_trap"
  }
}

Input Schema

NameRequiredDescriptionDefault
mepcNoThe mepc register: the program counter that the core saved when it took the trap.
mtvalNoThe mtval register: the faulting address or instruction, depending on the cause.
mcauseYesThe mcause register. Bit 31 set means an interrupt.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so the safety profile is covered. The description adds real value by stating what the answer contains (what mepc and mtval hold for that cause, and what to check) and where its coverage stops (privileged spec, not vendor-specific). It stops short of describing response format or how completely it handles unknown cause codes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the core action and followed by the usage condition and scope limit. No filler or restatement of the title.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description carries the burden of explaining the return, and it does state the decode result plus the mepc/mtval interpretation and 'what to check'. Only minor gaps remain, such as behavior on unrecognized cause values or the shape of the returned text.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the schema already explains each register, including that bit 31 of mcause signals an interrupt. The description only gestures at mepc and mtval in terms of what the output reports about them, adding no format or validation meaning beyond the schema, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

A specific verb (decodes) on a specific resource (the mcause value of a 32-bit RISC-V core), plus the output it produces (the named exception or interrupt, plus what mepc/mtval hold). Naming RISC-V and the privileged-spec scope separates it from siblings like decode_cortex_m_fault and decode_esp_panic without needing to reference them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a concrete triggering situation: a RISC-V microcontroller such as an ESP32-C3 or GD32V has stopped in its trap handler and the register values are known. It also states a scope exclusion (privileged-spec causes only, not vendor-specific ones), though it never names a sibling to use for the vendor-specific case.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources