Tools
The four developer surfaces around the platform. Same auth across all of them — sign in once with the CLI, every tool inherits the session.
SDK
TypeScript client for Streams, Subgraphs, and Subscriptions. Deploy subgraphs, query tables, manage row-change webhooks — programmatic parity with the CLI.
bun add @secondlayer/sdk @secondlayer/stacksimport { createClient, createStreamsClient } from "@secondlayer/sdk";
const client = createClient({ apiKey: process.env.SL_SERVICE_KEY! });
await client.subgraphs.queryTable("my-watcher", "transfers", { _limit: 10 });
await client.subscriptions.create({ ... });
const streams = createStreamsClient({ apiKey: process.env.SL_STREAMS_API_KEY! });
await streams.events.consume({ types: ["print"], onBatch: async (events) => { ... } });CLI
One binary for everything you'd otherwise click through dashboards for. Login, deploy, query, manage subscriptions, tail Streams, provision dedicated instances.
bun add -g @secondlayer/cli
sl login # magic-link email
sl subgraphs new my-watcher --template sip-010-balances
sl subgraphs deploy my-watcher.ts # prompts login if no session
sl subgraphs query my-watcher transfers --filter recipient=SP1...
sl streams events --types print --contract-id SP2...BNS-V2
sl create subscription my-watcher --runtime nodeMCP server
Model Context Protocol server so agents (Claude Code, Cursor, any MCP client) can list/query subgraphs, configure subscriptions, and invoke chain tools without you wiring REST calls by hand.
bunx @secondlayer/mcp # stdio transport (default)
bunx @secondlayer/mcp --http # HTTP transport on :3900// claude_desktop_config.json
{
"mcpServers": {
"secondlayer": {
"command": "bunx",
"args": ["@secondlayer/mcp"],
"env": { "SL_SERVICE_KEY": "sk-sl_..." }
}
}
}@secondlayer/stacks
The agent-native Stacks chain SDK. Typed contract reads + writes, AI SDK tool({...}) values, and the on.* filter factories that produce typed Subscription specs.
bun add @secondlayer/stacksimport { on } from "@secondlayer/stacks";
// Typed subscription filter — bind to a subgraph table you own.
const spec = on.transferTo(
{ subgraph: "my-watcher", table: "transfers" },
"SP1ABC...",
{ asset: "SP1...usdc::usdc-token" },
);
// Available: on.transferTo, on.sip010Transfer, on.sip009Transfer,
// on.bnsName, on.poxStack, on.sbtcDeposit, on.sbtcWithdrawal