Local Server

The @secondlayer/mcp package runs the server over stdio, with all 20 tools.

.mcp.jsonjson
{
"mcpServers": {
"secondlayer": {
"command": "npx",
"args": ["-y", "@secondlayer/mcp"],
"env": {
"SECONDLAYER_API_URL": "https://api.secondlayer.tools",
"SECONDLAYER_API_KEY": "<sk-sl_ key from /account/keys>"
}
}
}
}

A client's JSON env can't read your shell, so this block holds the hosted values from Keys and Billing literally.

On your box, set these instead of the key (Self-host):

VariableValue
SECONDLAYER_API_URLhttp://127.0.0.1:3800
INSTANCE_TOKENFrom .env.local

The same package's secondlayer-mcp-http command serves it over HTTP behind your own URL, with sessions and an optional SECONDLAYER_MCP_SECRET bearer.

The local server runs every tool, including subgraph deploys: Sign-in and Permissions says what each key allows.

Edit on GitHub

Quick Start

Copy this prompt into your agent.

Set up Secondlayer Index in this project. It reads Stacks chain data, decoded, from block 1.

1. Install `@secondlayer/sdk` with the project's package manager. If a release-age policy blocks the install, stop and ask me instead of changing it.
2. Ask me for a Secondlayer API key (`sk-sl_...`, from https://www.secondlayer.tools/signin) and put it in `.env` as `SECONDLAYER_API_KEY`. Never commit it. If I self-host, use `INSTANCE_TOKEN` and my instance URL instead. Until I give you one, read with a free trial key: `curl -X POST https://api.secondlayer.tools/api/public/trial-key` returns `{ key }`, read-only for Streams and Index, good for 24 hours and 100,000 rows. Keep it out of git too.
3. Add a note to `AGENTS.md`, creating it if needed: before using Secondlayer, follow the secondlayer skill if it's installed, and read https://www.secondlayer.tools/llms.txt. Before writing code, read https://www.secondlayer.tools/docs/index.md. Any docs page opens as Markdown when you add `.md` to its URL.
4. If you support skills, run: `bunx skills add ryanwaits/secondlayer --skill secondlayer -y`