# secondlayer

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.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 8 repo stars
- Author: ryanwaits
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/ryanwaits/secondlayer/tree/HEAD/packages/mcp
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/secondlayer

## What it 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.

## Requirements
- Needs: Node.js (commands run via npx)
- Remote server: `https://api.secondlayer.tools/mcp`
- Environment variables: `SECONDLAYER_API_KEY`, `SECONDLAYER_API_URL` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

1. **Platform CLI: remote server**
```bash
claude mcp add --transport http secondlayer https://api.secondlayer.tools/mcp
```

2. **Platform CLI**
```bash
claude mcp add --env SECONDLAYER_API_KEY=<SECONDLAYER_API_KEY> --env SECONDLAYER_API_URL=<SECONDLAYER_API_URL> --transport stdio mcp -- npx -y @secondlayer/mcp
```
Replace <…> with your own values

### Codex

1. **Platform CLI: remote server**
```bash
codex mcp add mcp --url https://api.secondlayer.tools/mcp
```

2. **Platform CLI**
```bash
codex mcp add mcp --env SECONDLAYER_API_KEY=<SECONDLAYER_API_KEY> --env SECONDLAYER_API_URL=<SECONDLAYER_API_URL> -- npx -y @secondlayer/mcp
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mcp": {
            "url": "https://api.secondlayer.tools/mcp"
        }
    }
}
```
File `.cursor/mcp.json`:
```json
{
    "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

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mcp": {
            "type": "http",
            "url": "https://api.secondlayer.tools/mcp"
        }
    }
}
```
File `.vscode/mcp.json`:
```json
{
    "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

### Gemini CLI

1. **Platform CLI: remote server**
```bash
gemini mcp add -t http mcp https://api.secondlayer.tools/mcp
```

2. **Platform CLI**
```bash
gemini mcp add -e SECONDLAYER_API_KEY=<SECONDLAYER_API_KEY> -e SECONDLAYER_API_URL=<SECONDLAYER_API_URL> mcp npx -y @secondlayer/mcp
```
Replace <…> with your own values

## When to use it
- 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
- 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.

## Similar
- [Context7](https://affpapa.org/en/nevibecode/mcp/context7.md) — MCP server · 5563 installs
- [Search Google Flights](https://affpapa.org/en/nevibecode/mcp/search-google-flights.md) — MCP server · 2595 installs
- [Math-MCP](https://affpapa.org/en/nevibecode/mcp/math-mcp.md) — MCP server · 5958 installs
- [pipeworx gateway](https://affpapa.org/en/nevibecode/mcp/pipeworx-gateway.md) — MCP server · 419019 installs
- [SparkForge](https://affpapa.org/en/nevibecode/mcp/sparkforge.md) — MCP server · 219896 installs
- [OpenWebSearch](https://affpapa.org/en/nevibecode/mcp/openwebsearch.md) — MCP server · 494 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
