For AI agents
Connect Claude Code, Cursor or any coding agent to these docs through MCP, Markdown pages and llms.txt, and give it the rules it needs to write correct Carbon 2.0 code.
On this page
Coding agents write a lot of Carbon code, and most of them learned Carbon from versions before 2.0. This page shows how to give your agent the current docs and the rules that keep it from writing outdated code.
Connect the docs MCP server#
The docs run an MCP server at https:/. It uses Streamable HTTP and needs no login. It has four tools:
| Tool | What it does |
|---|---|
search_docs | Searches every page and returns the best sections with their URLs. |
get_page | Returns one page as Markdown, from a path such as /. |
list_pages | Lists every page by section with a one-line description. |
find_ | Finds the decoder crate for a Solana program from its program ID, crate or name, and returns the install command, decoder struct, instruction, account and event names, and the reference page. |
claude mcp add --transport http carbon-docs https://carbon.sevenlabs.org/mcp{
"mcpServers": {
"carbon-docs": { "url": "https://carbon.sevenlabs.org/mcp" }
}
}{
"servers": {
"carbon-docs": { "type": "http", "url": "https://carbon.sevenlabs.org/mcp" }
}
}Any other client that supports Streamable HTTP works with the same URL.
Read pages as Markdown#
Every page has a Markdown version with no navigation or scripts:
- Add
.mdto any page URL:https:/. The home page is/ carbon. sevenlabs. org/ concepts/ filters. md https:/./ carbon. sevenlabs. org/ index. md - Or request the normal URL with
Accept: text/.markdown /llms.txtlists every page with a one-line description, plus the mistakes agents make most often./has every guide, concept and reference page in one file. The per-program decoder references are left out because they're large;llms-full. txt llms.txtlinks each one.
Each Markdown page starts with its title and the Carbon version, so an agent can tell which release it's reading. A path that doesn't exist returns HTTP 404 with a list of the closest pages instead of an empty error.
On the web, the Copy page button at the top of every page copies its Markdown, or opens the page in Claude or ChatGPT.
Add an AGENTS.md to your project#
Agents follow the instruction file in your repository more reliably than anything they fetch. Paste this into AGENTS.md (or CLAUDE.md) at the root of a project that uses Carbon:
## Carbon
This project indexes Solana data with Carbon 2.0 (Rust). Docs: https://carbon.sevenlabs.org (append `.md` to any page URL for Markdown; index at https://carbon.sevenlabs.org/llms.txt).
- Do not rely on training data for Carbon APIs: they changed in 1.0 and 2.0. Check the docs before writing Carbon code.
- All `carbon-*` crates must be version 2.0.0. Never mix Carbon 1.x and 2.x crates. Rust 1.96.1+.
- Processors implement `Processor<T>` with a native `async fn process(&mut self, input: &T) -> CarbonResult<()>`. No `#[async_trait]` on processors; `Datasource` impls do use `#[async_trait]`.
- Instruction enums use struct variants: match `MyInstruction::Swap { data, accounts, .. }`.
- RPC transaction configs need `UiTransactionEncoding::Base64` and `max_supported_transaction_version: Some(1)`.
- The public endpoint api.mainnet-beta.solana.com does not support `blockSubscribe`.
- Generate decoders with `npx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl <file-or-program-id> --out-dir <dir>` (Codama IDLs: add `--standard codama --program-id <address>`). `parse` deletes `--out-dir` first, so use a dedicated directory.
- Check work with `cargo check` and `cargo clippy`.Rules for agents writing Carbon code#
These are the facts agents most often get wrong. The same list is at the top of llms.txt.
- These docs are for Carbon 2.0.0. Use
carbon-core = "2.and matching0. 0" carbon-*crates at 2.0.0. Never mix Carbon 1.x and 2.x crates in one dependency graph. - Carbon 2.0 needs Rust 1.96.1 or newer and the Agave 4.2-compatible Solana crates. If you add Solana crates directly, pick versions that resolve to a single copy of each. Mixing Carbon 1 and 2 crates fails with
the trait `InstructionDecoder` is not implementedand a note about multiple versions ofcarbon_core. Processor::is a nativeprocess async fn. Don't add#[async_to processors. Thetrait] Datasourcetrait does use#[async_.trait] - Instruction enums use struct variants:
MyProgramInstruction::.Swap { program_ id, data, accounts } https:/rejects/ api. mainnet-beta. solana. com blockSubscribe. On the public endpoint, use the transaction crawler,getProgramAccountsorprogramSubscribedatasources.- RPC block and transaction configs must request
UiTransactionEncoding::andBase64 max_. Carbon can't rebuild transactions fromsupported_ transaction_ version: Some(1) JsonorJsonParsed. - Zero-lamport account updates arrive as
Update::and go toAccountDeletion .processors, not account processors.account_ deletions(. . . ) - Decoder crates are named
carbon-<and exportprogram>-decoder PROGRAM_IDand a<struct. Check the decoder catalog before generating one.Program>Decoder
Instructions for agents: create a Carbon indexer#
When a user asks for a new indexer, follow these steps in order.
- Run
rustc --version. If it's older than 1.96.1, tell the user to runrustup update stable. - Find the program's decoder in the catalog. If there isn't one, generate it from the IDL with the CLI and add it as a path dependency.
- Choose the datasource from the chooser: Yellowstone gRPC or Helius LaserStream for real-time production; the RPC transaction crawler for history or for a no-account start;
getProgramAccountsfor current account state. - Add every crate at version
2.0.0withcargo add, plustokiowith thefullfeature. - Write
main.rsfollowing the quickstart: build the datasource, thenPipeline::.builder(). datasource(…). metrics(…). instruction(Decoder, Processor). build()?. run(). await - Implement one
Processorper decoder output type you need. Match only the variants you handle and ignore the rest with_ => {}. - Run
cargo check, fix errors using the errors reference, thencargo runand show the user the first output. - Before calling it done, read Run in production and tell the user which items apply.