Open source · MIT · MCP + CLI

Stop writing Anchor
boilerplate. Generate it.

Anchor Scaffold MCP turns an IDL — or a plain-English description — into production-ready TypeScript clients, Rust #[derive(Accounts)] structs, and full test suites for Solana's Anchor framework. Runs as a Claude Code MCP server and a CLI.

View on GitHub
~90%cost cut via prompt caching
4code generators
3LLM backends
anchor-scaffold — zsh
The old way

Anchor boilerplate eats hours.

  • Hand-writing typed instruction callers for every IX
  • Deriving PDAs and computing account space by hand
  • Re-typing #[derive(Accounts)] constraints
  • Scaffolding Mocha/Chai tests from scratch
  • Drift between your IDL and your client
With Anchor Scaffold

Generate it in seconds.

  • Typed clients, PDA helpers & account fetchers
  • Correct space math & constraints, every time
  • Full Rust account structs from your IDL
  • Ready-to-run test suites
  • Always in sync with the source of truth
What it generates

Everything around your program, written for you

Four focused generators plus the infrastructure that makes them fast and cheap to run.

🧩

TypeScript clients

Typed instruction callers, PDA derivation helpers and account fetchers — generated straight from your IDL.

anchor-scaffold gen-ts-client
🦀

Rust account structs

#[derive(Accounts)] structs with the right constraints and exact space calculations baked in.

anchor-scaffold gen-accounts
🧪

Test suites

Mocha/Chai tests that exercise every instruction and assert on resulting account state.

anchor-scaffold gen-tests

Whole programs

Describe what you want in plain English and get a complete, idiomatic Anchor program back.

anchor-scaffold gen-program
🔌

MCP + CLI

Use it natively inside Claude Code as an MCP server, or run it as a standalone CLI in any pipeline.

claude · terminal
🧠

Multi-backend

Point it at Claude, OpenAI, or any OpenAI-compatible endpoint. Your keys, your models, your control.

claude · openai · custom

Prompt caching = ~90% cheaper

Shared system context and IDL schemas are cached across calls, so repeated generations cost a fraction of a naive setup — without sacrificing quality.

~90% token cost reduction on repeat runs
How it works

From zero to generated in three steps

1

Install

One global install gives you the CLI and the MCP server binary.

$ npm install -g anchor-scaffold-mcp
2

Set an API key

Bring your own provider — Anthropic, OpenAI, or a compatible endpoint.

$ export ANTHROPIC_API_KEY=sk-ant-...
# or
$ export OPENAI_API_KEY=sk-...
3

Generate

Feed it an IDL and pick a generator. Output lands in your project.

$ anchor-scaffold gen-ts-client \
    --idl ./target/idl/escrow.json \
    --out ./app/src/client
Before / after

Hand-rolled boilerplate vs one command

Same typed escrow client. One you maintain forever — the other regenerates from the IDL.

client.ts · written & maintained manually
// You write all of this, then keep it in sync forever…
import { Program, BN, web3 } from "@coral-xyz/anchor";

function findEscrowPda(maker: web3.PublicKey, seed: BN) {
  return web3.PublicKey.findProgramAddressSync(
    [
      Buffer.from("escrow"),
      maker.toBuffer(),
      seed.toArrayLike(Buffer, "le", 8),
    ],
    PROGRAM_ID,
  );
}

async function initialize(
  program: Program,
  maker: web3.PublicKey,
  seed: BN,
  amount: BN,
) {
  const [escrow, bump] = findEscrowPda(maker, seed);
  // remember the account order… and the constraints…
  return program.methods
    .initialize(seed, amount)
    .accounts({ maker, escrow, /* …8 more */ })
    .rpc();
}
// …repeat for every instruction. 😮‍💨
terminal · one command, fully typed output
$ anchor-scaffold gen-ts-client --idl target/idl/escrow.json

 Parsed IDL  (4 instructions, 2 accounts)
 Generated typed instruction callers
 Generated PDA helpers + account fetchers
 Wrote app/src/client/escrow.ts  (prompt cache hit · 91% cheaper)

// app/src/client/escrow.ts — now just import & call:
import { EscrowClient } from "./client/escrow";

const client = new EscrowClient(program);

await client.initialize({ maker, seed, amount });   // fully typed ✨
const escrow = await client.fetchEscrow(maker, seed);
const pda    = client.pdas.escrow(maker, seed);
Get started

Two ways to run it

Use the CLI in any project, or wire it into Claude Code as an MCP server.

CLI

Install & run

Global install, then call any generator from your terminal or CI.

$ npm install -g anchor-scaffold-mcp
$ anchor-scaffold gen-ts-client \
    --idl ./target/idl/myprog.json
MCP

Add to Claude Code

Drop this into your Claude Code MCP config and call the generators from chat.

{
  "mcpServers": {
    "anchor-scaffold": {
      "command": "npx",
      "args": ["-y", "anchor-scaffold-mcp"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}

Ship Solana programs faster.

Free, open source, and MIT-licensed. Star it on GitHub or grab it from npm.