anchor-debug
Provides tools for debugging Solana Anchor program failures, including parsing logs, fetching transaction details, and looking up error codes.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
anchor-debug
CLI tool that makes Anchor program failures understandable.
When your Anchor test fails with custom program error: 0x1770, anchor-debug tells you exactly what broke, where, and why.
Before vs After
Without anchor-debug:
Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x7d2With anchor-debug:
✗ Transaction failed
Error: ConstraintHasOne
Code: 0x7d2 (2002)
Msg: A has_one constraint was violated — account field does not match expected value
Program: my_program (9uvbWC...)
CPI call stack:
└─ ✗ my_program (9uvbWC...) ← failed here
Error: A has_one constraint was violated — account field does not match expected value
└─ ✓ TokenkegQfeZy... (Token Program)
└─ ✗ my_program::validate_authority ← failed hereRelated MCP server: Solana MCP Demo
Installation
npm install -g anchor-debug
# or use directly with npx
npx anchor-debug --helpUsage
Pipe anchor test output
anchor test 2>&1 | npx anchor-debuganchor-debug reads stdin, finds the failure, and prints a human-readable error. If the test succeeds, output is passed through unchanged.
Debug a transaction by signature
npx anchor-debug tx <SIGNATURE> --cluster devnet
npx anchor-debug tx <SIGNATURE> --cluster mainnet-beta
npx anchor-debug tx <SIGNATURE> --cluster http://localhost:8899Fetches the transaction from the RPC, extracts its logs, and formats the error.
Run tests with automatic error formatting
npx anchor-debug test
npx anchor-debug test --skip-buildRuns anchor test for you and prints the parsed error on failure.
Options
Flag | Description |
| Also show raw log lines |
| Show all program log messages |
| Cluster or RPC URL (tx command) |
| Pass --skip-build to anchor test |
How it works
Log parser — reads Solana program logs line-by-line using a regex state machine
Error database — 60+ Anchor framework errors mapped by hex code (both new 0x7d0+ and legacy 0x1770+ ranges)
CPI tracer — rebuilds the full
Program invoke [N]call tree and marks the innermost failing invocationIDL resolver — reads
Anchor.tomlandtarget/idl/*.jsonto show program names instead of pubkeys
Supported error ranges
Range | Source |
| Instruction errors |
| IDL errors |
| Constraint errors (Anchor ≥ 0.24) |
| Account errors |
| State errors |
| Legacy constraint errors (Anchor < 0.24) |
MCP Server (for AI agents)
anchor-debug works as an MCP server, giving AI coding agents (Claude Code, Cursor, etc.) structured access to Solana error data.
Add to .mcp.json in your project:
{
"mcpServers": {
"anchor-debug": {
"command": "npx",
"args": ["anchor-debug", "mcp"]
}
}
}Or globally in ~/.claude/mcp.json.
Available tools:
Tool | What it does |
| Takes raw log lines → structured error + CPI stack |
| Takes signature + cluster → fetches and parses |
| Takes hex code → error name + message |
Example agent response after calling parse_logs:
{
"failed": true,
"error": {
"name": "ConstraintHasOne",
"code": 2002,
"hex": "0x7d2",
"message": "A has_one constraint was violated — account field does not match expected value",
"category": "constraint"
},
"failedProgram": "my_program",
"failedNode": {
"program": "my_program",
"depth": 2,
"errorMessage": "A has_one constraint was violated"
},
"cpiStack": [...]
}Instead of reasoning about 0x1770, the agent immediately knows what failed and can fix it in one shot.
Programmatic API
import { parseLogsFromString, formatResult } from "anchor-debug";
const logs = [
"Program MyProg invoke [1]",
"Program MyProg failed: custom program error: 0x7d2",
];
const parsed = parseLogsFromString(logs.join("\n"));
console.log(formatResult(parsed));Milestones
M1 — npm package, log parser, Anchor error database
M2 — CPI call stack visualizer, IDL integration
M3 — VS Code extension (inline hints)
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Solana address risk grades and token scans for AI agents. Pay-per-call via x402 (USDC on Base).
x402 pay-per-call Solana data + crypto market + JWT/unit utils for AI agents.
RiskDataApi — Solana token risk scoring for AI agents. Safety score, insider clusters, honeypot.
Trade, launch and research higher.fun coins on Solana, from any AI agent. Unsigned or policy-signed.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceCrypto-aware project memory for AI coding agents. Typed entities for Solana Programs/PDAs and EVM Contracts across Base, Optimism, Polygon, Arbitrum, Ethereum — plus chain-agnostic Decisions, Findings, and Integrations. Anchor + Hardhat auto-ingest, SQLite + FTS5 BM25 ranking, append-only versioning, git-aware diffs.47 npm1MIT
- AlicenseNot gradedqualityCmaintenanceProvides basic Solana RPC methods and prompts for AI models to interact with the Solana blockchain. Enables developers to fetch balances, account info, and transactions through natural language.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to access and search up-to-date Solana documentation, get canonical spec references, and fix Anchor/Pinocchio Solana programs via MCP tools.45 npm83MIT
- AlicenseNot gradedqualityDmaintenanceExtends Solana debugging to AI agents via MCP: decode transaction failures, trace CPI trees, and profile compute for any Solana transaction.7 npmMIT