Agents can write and run Clarity tests via the SDK, but when something goes wrong, they have no visibility into why, they only see the final error. Giving agents access to execution traces and the debug adapter would let them reason about contract behavior the same way a developer does with a debugger.
Problem
When an agent calls session.callPublicFn(...) and gets an unexpected result, it has no way to inspect what happened inside the contract. It can only re-read source code and guess. Interactive debugging via DAP is designed for humans, not agents.
Proposed solution(s)
(in order of implementation effort)
- Execution traces on every call
Extend callPublicFn / eval responses to include an optional structured trace: each subexpression evaluated, its result, any state mutations (maps written, variables updated). Agents can read this trace to understand exactly what the contract did without needing an interactive debugger.
- MCP server (
clarinet mcp serve)
Expose the debug SDK as an https://modelcontextprotocol.io server so agents can call tools like deploy_contract, call_function, get_trace, get_state directly. This is the most natural interface for AI agents and works with any MCP-compatible client
- Extended SDK protocol with DAP event relay
Push DAP events (breakpoints hit, step results, variable state) over the existing SDK TCP socket so a non-interactive client can receive them. This would let an agent set breakpoints and inspect state at specific points without a human-driven debugger UI.
Agents can write and run Clarity tests via the SDK, but when something goes wrong, they have no visibility into why, they only see the final error. Giving agents access to execution traces and the debug adapter would let them reason about contract behavior the same way a developer does with a debugger.
Problem
When an agent calls session.callPublicFn(...) and gets an unexpected result, it has no way to inspect what happened inside the contract. It can only re-read source code and guess. Interactive debugging via DAP is designed for humans, not agents.
Proposed solution(s)
(in order of implementation effort)
Extend callPublicFn / eval responses to include an optional structured trace: each subexpression evaluated, its result, any state mutations (maps written, variables updated). Agents can read this trace to understand exactly what the contract did without needing an interactive debugger.
clarinet mcp serve)Expose the debug SDK as an https://modelcontextprotocol.io server so agents can call tools like deploy_contract, call_function, get_trace, get_state directly. This is the most natural interface for AI agents and works with any MCP-compatible client
Push DAP events (breakpoints hit, step results, variable state) over the existing SDK TCP socket so a non-interactive client can receive them. This would let an agent set breakpoints and inspect state at specific points without a human-driven debugger UI.