A
Anchor Scaffold MCP
by @mukulcodezz
AI code generator for Solana Anchor programs — TypeScript clients, Rust accounts, tests & full programs from your IDL. MCP server + CLI.
Created 5/31/2026
Updated about 3 hours ago
README
Repository documentation and setup instructions
Anchor Scaffold MCP
AI code generator for Solana Anchor programs. Generates production-ready TypeScript clients, Rust account structs, tests, and complete programs.
Start here: QUICKSTART.md
What It Does
# TypeScript client (typed instruction callers, PDA helpers, account fetchers)
anchor-scaffold gen-ts-client --idl target/idl/my_program.json
# Rust accounts struct (derive(Accounts), all constraints, space calc)
anchor-scaffold gen-rust-accounts --idl target/idl/my_program.json --instruction initialize
# Test suite (Mocha/Chai, instruction tests, state verification)
anchor-scaffold gen-tests --idl target/idl/my_program.json
# Full program (lib.rs, all instructions, error enum, state accounts)
anchor-scaffold gen-program --description "A multi-sig wallet" --program-name multisig
Installation
npm install
npm run build
npm start # MCP server mode
or
npm install -g anchor-scaffold-mcp
anchor-scaffold --help
Configure
export SCAFFOLD_API_KEY=sk-ant-xxxxx
export SCAFFOLD_PROVIDER=claude # or openai
Or create ~/.anchor-scaffold/config.json:
{
"provider": "claude",
"apiKey": "sk-ant-...",
"model": "claude-sonnet-4-6"
}
In Claude Code
Add to .claude/settings.json:
{
"mcpServers": {
"anchor-scaffold": {
"command": "npx",
"args": ["anchor-scaffold-mcp"]
}
}
}
Then ask Claude:
Generate a TypeScript client for my program at target/idl/my_program.json
How It Works
- Parse Anchor IDL (JSON format)
- Send IDL + prompt to AI (Claude or OpenAI)
- AI generates code based on IDL structure
- Return ready-to-use code
Generated code:
- TypeScript: imports from
@coral-xyz/anchor, fully typed - Rust:
anchor buildcompatible, all constraints correct - Tests:
anchor testcompatible, instruction verified - Programs: complete, compiling lib.rs
Validation
- TypeScript output: no TS errors, imports valid
- Rust output:
anchor buildsucceeds - Tests:
anchor testpasses - Programs:
anchor buildsucceeds
Limitations
- IDL must be valid Anchor format
- Generated code is starter/scaffold (may need customization)
- Complex validation logic added by hand
- Custom business logic written by developer
Supported
- Anchor 0.30+
- Solana 1.17+
- Node.js 18+
Cost
Using Claude with prompt caching: ~$0.01-0.05 per generation (90% cheaper on repeated IDLs).
Deploy
See DEPLOY.md for:
- npm publish
- VS Code extension
- Docker/cloud deployment
- Web service wrapper
License
MIT
Quick Setup
Installation guide for this server
Install Package (if required)
npx @modelcontextprotocol/server-anchor-scaffold-mcp
Cursor configuration (mcp.json)
{
"mcpServers": {
"mukulcodezz-anchor-scaffold-mcp": {
"command": "npx",
"args": [
"mukulcodezz-anchor-scaffold-mcp"
]
}
}
}