A debug plugin for OpenCode that enables runtime debugging by capturing data from instrumented code. Similar to Cursor's debug mode, this plugin allows the agent to insert fetch calls into your codebase, capture runtime data, and analyze it to identify issues.
Add the plugin to your OpenCode configuration:
{
"plugin": ["@thecto/opencode-debug-plugin@latest"]
}
The debug plugin enables a powerful debugging workflow:
fetch() calls at strategic locations in your codebase.opencode/debug.log| Tool | Description |
|---|---|
debug_start |
Start debug mode and get instrumentation instructions |
debug_stop |
Stop debug mode (remember to remove fetch calls) |
debug_read |
Read and analyze the captured debug data |
debug_clear |
Clear the debug log for a fresh session |
debug_status |
Check if debug mode is active and get the debug URL |
When you ask the agent to debug an issue, it will:
debug_start
This starts the debug server and provides the agent with instructions on how to instrument your code.
The agent will insert fetch calls like this at key locations:
fetch("http://localhost:PORT/debug", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ label: "function-entry", data: { arg1, arg2 } }),
}).catch(() => {});
Common instrumentation points:
After you reproduce the issue:
debug_read
debug_read tail=20
The agent analyzes the captured data to identify:
debug_stop
The agent will also remove the fetch calls it inserted.
For debugging deployed applications or remote environments:
opencode auth loginOr set the environment variable:
export NGROK_AUTHTOKEN=your_token_here
Once configured, debug_start automatically creates a public tunnel.
You: "The checkout function is returning the wrong total"
Agent:
debug_startYou: Reproduce the checkout bug
Agent:
debug_readcart-items: [...], discount-applied: 0.15, subtotal: 100, final-total: 80debug_stopMIT
$ claude mcp add opencode-debug \
-- python -m otcore.mcp_server <graph>