Channels / MCP

MCP

Point Claude Code, Cursor, or any MCP client at your instance so it can read and operate it directly.

The server ships as @secondlayer/mcp and speaks stdio. Add it to any MCP client (Claude Code, Cursor, Claude Desktop):

{
  "mcpServers": {
    "secondlayer": {
      "command": "npx",
      "args": ["-y", "@secondlayer/mcp"],
      "env": {
        "SECONDLAYER_API_URL": "http://127.0.0.1:3800",
        "INSTANCE_TOKEN": "..."
      }
    }
  }
}

INSTANCE_TOKEN is optional for reads on loopback; anything published past loopback requires it, and the write tools require it always. SECONDLAYER_API_URL is the lead instance URL (SL_API_URL still works). Hosted archive/credits tools also need SECONDLAYER_API_KEY. See Authentication.

An HTTP transport (@secondlayer/mcp-http) adds session management and optional SECONDLAYER_MCP_SECRET bearer auth for hosting the server behind a URL.

SurfaceReadsWrites
Index, Streams, Contracts, ScaffoldOpen on loopback
Subgraphs, WebhooksOpen on loopbackINSTANCE_TOKEN

A token sent on a loopback read that did not need it is ignored, never rejected.

Read these resources before calling tools:

ResourceWhat it returns
secondlayer://contextLive snapshot: your subgraphs, webhooks, chain tips, auth state, and what you can do. Read first.
secondlayer://filtersEvent filter types and the fields each accepts
secondlayer://column-typesSubgraph column types, SQL mappings, and options
secondlayer://traitsSIP standards you can classify and scaffold against (sip-009/010/013)
secondlayer://chain-triggersChain-webhook trigger types and their filter fields

For Index specifically, call index_discover to learn every event type, its columns, and the filters it accepts before building queries.

Reads are cursor-paginated; writes that kick off work (reindex, backfill, replay, deploy) return an operationId to poll.

Index: decoded reads

ToolWhat it does
index_eventsDecoded events by eventType (stx/ft/nft mint·burn, print, …), with trait scoping
index_ft_transfersDecoded SIP-010 fungible-token transfers
index_nft_transfersDecoded SIP-009 non-fungible-token transfers
index_contract_callsDecoded contract calls: function, args, result
index_transactionsDecoded transactions, filterable by type/sender/contract
index_blocksDecoded blocks
index_discoverThe Index vocabulary: event types, columns, allowed filters
index_print_schemaPer-topic print payload schemas for a contract, inferred from on-chain history; read before writing print_event handlers
batch_queryUp to 10 public /v1 reads in one round trip

Boot-contract reads (index_stacking, pox-5, sBTC) are the same Index tools on shared contracts, not a second product.

Subgraphs: your own indexer

ToolWhat it does
subgraphs_deployDeploy from defineSubgraph() source (instance Postgres or your own via database URL; dryRun previews DDL)
subgraphs_listList your deployed subgraphs
subgraphs_statusFull detail: schema, health, table columns
subgraphs_queryQuery a table with operator filters (amount.gte, name.like, …)
subgraphs_gapsList missing block ranges
subgraphs_backfillNon-destructive forward fill of a block range
subgraphs_reindexDrop + rebuild the whole subgraph, start block to chain tip (no range)
subgraphs_stopCancel an in-flight reindex/backfill
subgraphs_deleteDelete a subgraph and its data

Streams: raw firehose

ToolWhat it does
streams_dumpsList the signed bulk dumps manifest (cold backfill). Live Streams reads are REST-only at /v1/streams/*.

Webhooks: webhooks

ToolWhat it does
webhooks_createCreate a subgraph- or chain-triggered webhook (returns signingSecret once)
webhooks_listList webhooks
webhooks_getFull detail: filter, auth, retry, circuit state
webhooks_updatePatch url, filter, auth, retry, timeout, concurrency
webhooks_testSend a one-off SSRF-guarded test delivery
webhooks_replayReplay a block range
webhooks_deleteDelete a webhook

Contracts & scaffold

ToolWhat it does
contracts_findDiscover deployed contracts conforming to a trait (sip-010/009/013)
contracts_get_abiFetch a deployed contract's full ABI from the registry
subgraphs_scaffoldGenerate a subgraph scaffold from a contract's ABI
  • One-time secrets. webhooks_create returns its signing secret exactly once: forward it to the user.
  • Cursors are opaque and per-keyspace: contract-call cursors are not interchangeable with event cursors.
  • Tail without streaming. For subgraph tables, sort _id desc for the latest, then poll forward with {"_id.gt": "<last id>"}, order asc.
  • See the REST API for the underlying endpoints.