# secondlayer MCP server

> Enables AI agents to access Stacks blockchain data, manage subgraphs, and configure webhooks via a hosted API or local instance.

- Repository: https://github.com/ryanwaits/secondlayer
- Page: https://hostedmcp.org/servers/ryanwaits/secondlayer
- Transport: stdio, remote
- Stars: 8
- License: MIT
- Latest version: 11.6.6

## Install

### Claude Code

```sh
claude mcp add --env 'SECONDLAYER_API_KEY=<YOUR_SECONDLAYER_API_KEY>' secondlayer -- npx -y @secondlayer/mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "secondlayer": {
      "command": "npx",
      "args": [
        "-y",
        "@secondlayer/mcp"
      ],
      "env": {
        "SECONDLAYER_API_KEY": "<YOUR_SECONDLAYER_API_KEY>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "secondlayer": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@secondlayer/mcp"
      ],
      "env": {
        "SECONDLAYER_API_KEY": "<YOUR_SECONDLAYER_API_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"secondlayer","type":"stdio","command":"npx","args":["-y","@secondlayer/mcp"],"env":{"SECONDLAYER_API_KEY":"<YOUR_SECONDLAYER_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "secondlayer": {
      "command": "npx",
      "args": [
        "-y",
        "@secondlayer/mcp"
      ],
      "env": {
        "SECONDLAYER_API_KEY": "<YOUR_SECONDLAYER_API_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add secondlayer --env 'SECONDLAYER_API_KEY=<YOUR_SECONDLAYER_API_KEY>' -- npx -y @secondlayer/mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.secondlayer]
command = "npx"
args = ["-y", "@secondlayer/mcp"]

[mcp_servers.secondlayer.env]
SECONDLAYER_API_KEY = "<YOUR_SECONDLAYER_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'SECONDLAYER_API_KEY=<YOUR_SECONDLAYER_API_KEY>' secondlayer npx -- -y @secondlayer/mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "secondlayer": {
      "command": "npx",
      "args": [
        "-y",
        "@secondlayer/mcp"
      ],
      "env": {
        "SECONDLAYER_API_KEY": "<YOUR_SECONDLAYER_API_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `SECONDLAYER_API_KEY` | no | yes | Account API key (sk-sl_*) for the hosted API: credits, writes. |
| `INSTANCE_TOKEN` | no | no |  |
| `SECONDLAYER_API_URL` | no | no | Instance API URL. Use https://api.secondlayer.tools for hosted. |
| `SECONDLAYER_MCP_SECRET` | no | no |  |

## Tools (2)

- `fields`
- `count`

## FAQ

### Do I need an API key for all tools?

No, most reads like index_events and contracts_find are public and work without a key, but subgraph tools and writes require an INSTANCE_TOKEN or API key.

### Can I use this with my own local instance?

Yes, you can point the server to your own instance by configuring the SECONDLAYER_API_URL environment variable.

### What is the purpose of the secondlayer://context resource?

It is used to report the current authentication state and available read-auth tiers.
