secondlayer — Claude Code MCP server: Stacks data
The secondlayer MCP server connects Claude Code to indexed Stacks data, contract discovery, and subgraph tools. The hosted API uses browser sign-in for its HTTP connection.
MIT ★ 8 updated 2026-10-29
claude mcp add --transport http secondlayer https://api.secondlayer.tools/mcpWhat secondlayer does
secondlayer gives an agent tools to query Stacks events, token transfers and block data, and to find contracts. It can scaffold a subgraph and manage deployment or reindexing, handle webhooks, and report instance status. For Streams, the available tools cover the chain tip and dump manifests.
For Claude Code, connect to the hosted API with the command below. Most index reads and contract searches work without a key; writes require authentication. The hosted service uses SECONDLAYER_API_KEY, while a self-hosted instance is selected with SECONDLAYER_API_URL and uses INSTANCE_TOKEN for writes. Hosted subgraph sources are restricted to event filters and contract calls or deployments, and require startBlock.
Some operations remain REST-only, including live Streams reads and individual transaction lookups. The secondlayer://context resource reports authentication state and read access tiers. Check it before asking the agent to perform a write.
What it helps with
- query Stacks events and token transfers
- find a contract and retrieve its ABI
- scaffold and reindex a subgraph
- set a webhook for contract events
- check instance or archive status
Example prompts for the agent
- Find the Stacks contracts involved in this call and show their ABIs.
- Create a subgraph for this contract’s events, then check its status.
- Set up a webhook for this contract’s
swap-*calls.
How to install secondlayer
1Platform CLI: remote server
claude mcp add --transport http secondlayer https://api.secondlayer.tools/mcp2Platform CLI
claude mcp add --env SECONDLAYER_API_KEY=<SECONDLAYER_API_KEY> --env SECONDLAYER_API_URL=<SECONDLAYER_API_URL> --transport stdio mcp -- npx -y @secondlayer/mcpReplace <…> with your own values
1Platform CLI: remote server
codex mcp add mcp --url https://api.secondlayer.tools/mcp2Platform CLI
codex mcp add mcp --env SECONDLAYER_API_KEY=<SECONDLAYER_API_KEY> --env SECONDLAYER_API_URL=<SECONDLAYER_API_URL> -- npx -y @secondlayer/mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"mcp": {
"url": "https://api.secondlayer.tools/mcp"
}
}
}{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@secondlayer/mcp"
],
"env": {
"SECONDLAYER_API_KEY": "<SECONDLAYER_API_KEY>",
"SECONDLAYER_API_URL": "<SECONDLAYER_API_URL>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"mcp": {
"type": "http",
"url": "https://api.secondlayer.tools/mcp"
}
}
}{
"servers": {
"mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@secondlayer/mcp"
],
"env": {
"SECONDLAYER_API_KEY": "<SECONDLAYER_API_KEY>",
"SECONDLAYER_API_URL": "<SECONDLAYER_API_URL>"
}
}
}
}Replace <…> with your own values
1Platform CLI: remote server
gemini mcp add -t http mcp https://api.secondlayer.tools/mcp2Platform CLI
gemini mcp add -e SECONDLAYER_API_KEY=<SECONDLAYER_API_KEY> -e SECONDLAYER_API_URL=<SECONDLAYER_API_URL> mcp npx -y @secondlayer/mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about secondlayer
How do I install secondlayer in Claude Code?
Run claude mcp add --transport http secondlayer https://api.secondlayer.tools/mcp to connect to the hosted API over HTTP.
What does secondlayer do?
It gives agents tools for querying Stacks data, finding contracts, managing subgraphs and handling webhooks. It also includes instance and archive checks.
Do I need an API key to use secondlayer?
Index reads and contract searches can work without a key. Writes to your instance need INSTANCE_TOKEN; the hosted API uses SECONDLAYER_API_KEY.