open-index/open-npm huggingface dataset:
npm package: @secondlayer/mcp
Description: MCP server for the Second Layer indexing platform.
Latest version: 0.4.2

# @secondlayer/mcp

MCP server for the Second Layer indexing platform.

## Install

```bash
bun add @secondlayer/mcp
```

## Quick Start — Stdio (IDE)

Add to your Claude Desktop or Cursor config:

```json
{
  "mcpServers": {
    "secondlayer": {
      "command": "npx",
      "args": ["@secondlayer/mcp"],
      "env": {
        "SECONDLAYER_API_KEY": "sl_live_..."
      }
    }
  }
}
```

## Quick Start — HTTP (Remote)

```bash
export SECONDLAYER_API_KEY=sl_live_...
export SECONDLAYER_MCP_SECRET=your-secret
npx @secondlayer/mcp-http
# Listening on port 3100
```

## Environment Variables

| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `SECONDLAYER_API_KEY` | Yes | — | API key |
| `SECONDLAYER_MCP_PORT` | No | `3100` | HTTP transport port |
| `SECONDLAYER_MCP_SECRET` | No | — | Bearer token for HTTP auth. Disabled if unset. |

## Tools

28 tools across 6 domains.

| Domain | Tools |
| --- | --- |
| **Streams** (11) | `streams_list`, `streams_get`, `streams_create`, `streams_update`, `streams_delete`, `streams_toggle`, `streams_deliveries`, `streams_pause_all`, `streams_resume_all`, `streams_replay`, `streams_rotate_secret` |
| **Subgraphs** (6) | `subgraphs_list`, `subgraphs_get`, `subgraphs_query`, `subgraphs_reindex`, `subgraphs_delete`, `subgraphs_deploy` |
| **Workflows** (6) | `workflows_list`, `workflows_get`, `workflows_trigger`, `workflows_pause`, `workflows_resume`, `workflows_runs` |
| **Scaffold** (2) | `scaffold_from_contract`, `scaffold_from_abi` |
| **Templates** (2) | `templates_list`, `templates_get` |
| **Account** (1) | `account_whoami` |

### `subgraphs_query` enhancements

- `fields` — comma-separated column projection (e.g. `"sender,amount_x"`)
- `count` — boolean, returns row count instead of rows
- Filter operators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `like`
- Max limit raised from 50 to 200

## Resources

3 MCP resources for agent context:

| URI | Description |
| --- | --- |
| `secondlayer://filters` | Filter types reference |
| `secondlayer://column-types` | Column type mappings and options |
| `secondlayer://templates` | Available subgraph templates |

## Error Handling

All tools return structured errors with `isError: true`:

```json
{ "error": { "type": "not_found", "status": 404, "message": "Stream not found" } }
```

| Error type | Status | When |
| --- | --- | --- |
| `unauthorized` | 401 | Invalid or missing API key |
| `not_found` | 404 | Resource doesn't exist |
| `rate_limited` | 429 | Too many requests |
| `server_error` | 5xx | Server-side failure |
| `error` | other | Validation, bundling, etc. |

Bundle/deploy errors use descriptive prefixes: `"Bundle failed:"`, `"Module evaluation failed:"`, `"Validation failed:"`.

HTTP transport enforces a 1MB body limit (413) and JSON parse safety (400). Scaffold ABI fetch has a 10s timeout.

## Programmatic Usage

```typescript
import { createServer } from "@secondlayer/mcp";

const server = createServer();
// Connect to your own transport
```

## License

MIT
npm package: @secondlayer/recipes
Description: CLI for installing recipe code blocks
Latest version: 1.0.8

# recipes

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.1.41. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
npm package: @secondlayer/sdk
Description: TypeScript SDK for the Second Layer API.
Latest version: 0.10.3

# @secondlayer/sdk

TypeScript SDK for the Second Layer API.

## Install

```bash
bun add @secondlayer/sdk
```

## Quick Start

```typescript
import { SecondLayer } from "@secondlayer/sdk";

const sl = new SecondLayer({
  apiKey: "sk-sl_...",                          // or session token
  baseUrl: "https://api.secondlayer.tools",     // default
});
```

## Streams

Manage real-time event streams with endpoint delivery.

```typescript
// Create
const { stream, signingSecret } = await sl.streams.create({
  name: "my-stream",
  endpointUrl: "https://example.com/receive",
  filters: { type: "contract_call", contract_id: "SP...token" },
});

// List
const { streams, total } = await sl.streams.list({ status: "active" });

// Get / Update / Delete
const stream = await sl.streams.get("stream-id");
await sl.streams.update("stream-id", { name: "renamed" });
await sl.streams.delete("stream-id");
```

## Subgraphs

Deploy and query subgraphs (custom indexers).

```typescript
// List
const { data } = await sl.subgraphs.list();

// Get
const subgraph = await sl.subgraphs.get("my-subgraph");

// Query table
const rows = await sl.subgraphs.queryTable("my-subgraph", "transfers", {
  sort: "block_height",
  order: "desc",
  limit: 50,
});

// Deploy
const result = await sl.subgraphs.deploy({ name, sources, schema, handlerCode });
```

## Workflows

Deploy and manage automated workflows.

```typescript
// List
const { workflows } = await sl.workflows.list();

// Get
const detail = await sl.workflows.get("whale-alerts");

// Deploy
const result = await sl.workflows.deploy({
  name: "whale-alerts",
  trigger: { type: "event", filter: { type: "stx_transfer" } },
  handlerCode: "...",
});

// Trigger manually
const { runId } = await sl.workflows.trigger("whale-alerts", { threshold: 100000 });

// Pause / Resume / Delete
await sl.workflows.pause("whale-alerts");
await sl.workflows.resume("whale-alerts");
await sl.workflows.delete("whale-alerts");

// List runs
const { runs } = await sl.workflows.listRuns("whale-alerts", { status: "completed", limit: 10 });

// Get run details
const run = await sl.workflows.getRun("run-id");
```

## Error Handling

```typescript
import { ApiError } from "@secondlayer/sdk";

try {
  await sl.streams.get("nonexistent");
} catch (err) {
  if (err instanceof ApiError) {
    console.log(err.status);  // 404
    console.log(err.message); // "Contract not found"
  }
}
```
npm package: @secondlayer/shared
Description: Foundational utilities for Second Layer services: DB layer (Kysely+Postgres), job queue, Zod schemas, HMAC signing, Stacks node clients.
Latest version: 0.12.3

# @secondlayer/shared

Foundational utilities for Second Layer services: DB layer (Kysely+Postgres), job queue, Zod schemas, HMAC signing, Stacks node clients.

## Testing

```bash
# Run tests (DB tests skip without DATABASE_URL)
bun test

# Run with database
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/streams_test bun test
```

## Migrations

```bash
DATABASE_URL=... bun run migrate
```

## Exports

| Path | Description |
|------|-------------|
| `@secondlayer/shared` | Core utilities |
| `@secondlayer/shared/db` | Kysely database layer |
| `@secondlayer/shared/db/queries/*` | Query helpers (integrity, metrics, accounts, usage, subgraphs) |
| `@secondlayer/shared/db/schema` | Database schema |
| `@secondlayer/shared/db/jsonb` | JSONB helpers |
| `@secondlayer/shared/schemas` | Zod schemas |
| `@secondlayer/shared/schemas/filters` | Stream filter schemas |
| `@secondlayer/shared/schemas/subgraphs` | Subgraph schemas |
| `@secondlayer/shared/types` | Shared TypeScript types |
| `@secondlayer/shared/queue` | Job queue |
| `@secondlayer/shared/queue/listener` | Queue listener |
| `@secondlayer/shared/queue/recovery` | Queue recovery |
| `@secondlayer/shared/env` | Environment config |
| `@secondlayer/shared/logger` | Logger |
| `@secondlayer/shared/errors` | Error types |
| `@secondlayer/shared/crypto` | HMAC signing |
| `@secondlayer/shared/node` | Stacks node client |
| `@secondlayer/shared/node/hiro-pg-client` | Direct PG queries against Hiro DB |
| `@secondlayer/shared/lib/plans` | Plan definitions |