@secondlayer/mcp 7.0.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -8
- package/dist/bin-http.js +26 -8
- package/dist/bin-http.js.map +7 -6
- package/dist/bin.js +26 -8
- package/dist/bin.js.map +7 -6
- package/dist/index.js +26 -8
- package/dist/index.js.map +7 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ bun add @secondlayer/mcp
|
|
|
15
15
|
|
|
16
16
|
## Auth
|
|
17
17
|
|
|
18
|
-
Most reads are public
|
|
18
|
+
Most reads are public: `index_*` and `contracts_find` work with no key. Subgraph tools need an `INSTANCE_TOKEN` past loopback; separately, **public** subgraphs are anon-readable over HTTP at `GET /v1/subgraphs/<name>/<table>` (`{ rows, next_cursor, tip }` cursor envelope), while private ones need the instance token (anon → 404). `streams_dumps` needs no key: the dumps manifest is public; the tool only needs `SL_STREAMS_DUMPS_URL` configured. Every other `streams_*` tool is key-mandatory (keyless → 401). Writes (deploy, reindex, delete, subscriptions) need a key: set `INSTANCE_TOKEN` from `secondlayer init`. `SL_API_KEY` is a legacy alias of `INSTANCE_TOKEN`. Read `secondlayer://context` first: it reports auth state and read-auth tiers.
|
|
19
19
|
|
|
20
20
|
## Quick Start — Stdio (IDE)
|
|
21
21
|
|
|
@@ -28,7 +28,8 @@ Add to your Claude Desktop or Cursor config:
|
|
|
28
28
|
"command": "bunx",
|
|
29
29
|
"args": ["-p", "@secondlayer/mcp", "secondlayer-mcp"],
|
|
30
30
|
"env": {
|
|
31
|
-
"
|
|
31
|
+
"SL_API_URL": "http://127.0.0.1:3800",
|
|
32
|
+
"INSTANCE_TOKEN": "..."
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -38,7 +39,8 @@ Add to your Claude Desktop or Cursor config:
|
|
|
38
39
|
## Quick Start — HTTP (Remote)
|
|
39
40
|
|
|
40
41
|
```bash
|
|
41
|
-
export
|
|
42
|
+
export SL_API_URL=http://127.0.0.1:3800
|
|
43
|
+
export INSTANCE_TOKEN=<from secondlayer init>
|
|
42
44
|
export SECONDLAYER_MCP_SECRET=your-secret
|
|
43
45
|
bunx -p @secondlayer/mcp secondlayer-mcp-http
|
|
44
46
|
# Listening on port 3100
|
|
@@ -48,8 +50,9 @@ bunx -p @secondlayer/mcp secondlayer-mcp-http
|
|
|
48
50
|
|
|
49
51
|
| Variable | Required | Default | Description |
|
|
50
52
|
| --- | --- | --- | --- |
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
+
| `INSTANCE_TOKEN` | Writes only | — | From `secondlayer init`. Required for write tools; reads are public. `SL_API_KEY` is a legacy alias. |
|
|
54
|
+
| `SL_API_URL` | No | `http://127.0.0.1:3800` | Instance API. |
|
|
55
|
+
| `SECONDLAYER_API_URL` | No | — | Overrides `SL_API_URL`. |
|
|
53
56
|
| `SECONDLAYER_MCP_PORT` | No | `3100` | HTTP transport port. |
|
|
54
57
|
| `SECONDLAYER_MCP_SECRET` | No | — | Bearer token for HTTP auth. Disabled if unset. |
|
|
55
58
|
|
|
@@ -62,7 +65,7 @@ bunx -p @secondlayer/mcp secondlayer-mcp-http
|
|
|
62
65
|
| **Subscriptions** (13) | `subscriptions_create`, `subscriptions_list`, `subscriptions_get`, `subscriptions_update`, `subscriptions_delete`, `subscriptions_test`, `subscriptions_pause`, `subscriptions_resume`, `subscriptions_rotate_secret`, `subscriptions_deliveries`, `subscriptions_dead`, `subscriptions_requeue`, `subscriptions_replay` |
|
|
63
66
|
| **Streams** (7) | `streams_tip`, `streams_events`, `streams_events_by_tx`, `streams_block_events`, `streams_canonical`, `streams_reorgs`, `streams_dumps` |
|
|
64
67
|
| **Contracts** (2) | `contracts_find`, `contracts_get_abi` |
|
|
65
|
-
| **Account** (2) | `account_whoami`, `account_create_key` |
|
|
68
|
+
| **Account** (2) | `account_whoami`, `account_create_key` (only when pointed at `https://api.secondlayer.tools`) |
|
|
66
69
|
|
|
67
70
|
Verify after mutating: `subgraphs_operations` for deploy/reindex/backfill/stop,
|
|
68
71
|
`subscriptions_deliveries` for create/test/replay.
|
|
@@ -72,8 +75,9 @@ credits/caps, live Streams SSE) are REST-only: see the OpenAPI spec at the API
|
|
|
72
75
|
host. Following the chain over MCP means polling `streams_events` with a cursor.
|
|
73
76
|
|
|
74
77
|
Point the server at your instance with `SL_API_URL` (default
|
|
75
|
-
`http://127.0.0.1:3800`). Writes
|
|
76
|
-
`secondlayer init`.
|
|
78
|
+
`http://127.0.0.1:3800`). Writes use `INSTANCE_TOKEN` from
|
|
79
|
+
`secondlayer init`. `account_*` tools appear only when the server is pointed at
|
|
80
|
+
`https://api.secondlayer.tools`.
|
|
77
81
|
|
|
78
82
|
### `subscriptions_create` kinds
|
|
79
83
|
|
package/dist/bin-http.js
CHANGED
|
@@ -12,6 +12,16 @@ import { dirname, join } from "node:path";
|
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
14
|
|
|
15
|
+
// src/lib/hosted.ts
|
|
16
|
+
var HOSTED_ARCHIVE_HOST = "api.secondlayer.tools";
|
|
17
|
+
function isHostedArchiveUrl(url) {
|
|
18
|
+
try {
|
|
19
|
+
return new URL(url).hostname === HOSTED_ARCHIVE_HOST;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
// src/resources.ts
|
|
16
26
|
import { CHAIN_TRIGGER_FIELDS } from "@secondlayer/shared";
|
|
17
27
|
import { TRAIT_STANDARDS } from "@secondlayer/stacks/clarity";
|
|
@@ -191,7 +201,13 @@ var READ_AUTH_TIERS = {
|
|
|
191
201
|
};
|
|
192
202
|
async function buildContext(deps = { clientProvider: getClient }) {
|
|
193
203
|
const unavailable = "unavailable: set INSTANCE_TOKEN";
|
|
194
|
-
const orNull = (
|
|
204
|
+
const orNull = (field) => {
|
|
205
|
+
if (!field)
|
|
206
|
+
return unavailable;
|
|
207
|
+
if (field.value != null)
|
|
208
|
+
return field.value;
|
|
209
|
+
return field.error ? `unavailable: ${field.error.message}` : unavailable;
|
|
210
|
+
};
|
|
195
211
|
const snap = await deps.clientProvider().context().catch(() => null);
|
|
196
212
|
return {
|
|
197
213
|
authState: {
|
|
@@ -201,7 +217,7 @@ async function buildContext(deps = { clientProvider: getClient }) {
|
|
|
201
217
|
account: orNull(snap?.account),
|
|
202
218
|
streamsTip: orNull(snap?.streamsTip),
|
|
203
219
|
indexTip: orNull(snap?.indexTip),
|
|
204
|
-
subgraphs: snap?.subgraphs ? snap.subgraphs.map(formatSubgraphSummary) :
|
|
220
|
+
subgraphs: snap?.subgraphs.value ? snap.subgraphs.value.map(formatSubgraphSummary) : orNull(snap?.subgraphs),
|
|
205
221
|
subscriptions: orNull(snap?.subscriptions),
|
|
206
222
|
activeOperations: orNull(snap?.activeOperations)
|
|
207
223
|
},
|
|
@@ -271,14 +287,13 @@ function registerResources(server) {
|
|
|
271
287
|
// src/tools/account.ts
|
|
272
288
|
import { z } from "zod";
|
|
273
289
|
function registerAccountTools(server) {
|
|
274
|
-
defineTool(server, "account_whoami", "Show the
|
|
290
|
+
defineTool(server, "account_whoami", "Show the archive account email at api.secondlayer.tools, not the self-host instance.", {}, async () => {
|
|
275
291
|
const result = await apiRequest("GET", "/api/accounts/me");
|
|
276
292
|
return jsonResponse(result);
|
|
277
293
|
});
|
|
278
|
-
defineTool(server, "account_create_key", "Mint
|
|
279
|
-
product: z.enum(["streams", "index"]).optional().describe("Key scope (default streams)"),
|
|
294
|
+
defineTool(server, "account_create_key", "Mint an account key (sk-sl_*) for archive credits, quote, and fetch at api.secondlayer.tools. The returned `key` is shown ONCE.", {
|
|
280
295
|
name: z.string().optional().describe("Optional label for the key")
|
|
281
|
-
}, async ({
|
|
296
|
+
}, async ({ name }) => jsonResponse(await apiRequest("POST", "/api/keys", { name })));
|
|
282
297
|
}
|
|
283
298
|
|
|
284
299
|
// src/tools/codegen.ts
|
|
@@ -694,7 +709,10 @@ function createServer() {
|
|
|
694
709
|
registerStreamsTools(server);
|
|
695
710
|
registerContractTools(server);
|
|
696
711
|
registerCodegenTools(server);
|
|
697
|
-
|
|
712
|
+
const baseUrl = process.env.SECONDLAYER_API_URL || process.env.SL_API_URL || "http://127.0.0.1:3800";
|
|
713
|
+
if (isHostedArchiveUrl(baseUrl)) {
|
|
714
|
+
registerAccountTools(server);
|
|
715
|
+
}
|
|
698
716
|
registerResources(server);
|
|
699
717
|
return server;
|
|
700
718
|
}
|
|
@@ -785,5 +803,5 @@ httpServer.listen(port, () => {
|
|
|
785
803
|
console.error("Warning: SECONDLAYER_MCP_SECRET not set, authentication disabled");
|
|
786
804
|
});
|
|
787
805
|
|
|
788
|
-
//# debugId=
|
|
806
|
+
//# debugId=83999A89E39499BE64756E2164756E21
|
|
789
807
|
//# sourceMappingURL=bin-http.js.map
|
package/dist/bin-http.js.map
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/bin-http.ts", "../src/server.ts", "../src/resources.ts", "../src/lib/client.ts", "../src/lib/format.ts", "../src/lib/tool.ts", "../src/tools/account.ts", "../src/tools/codegen.ts", "../src/tools/contracts.ts", "../src/tools/index.ts", "../src/tools/scaffold.ts", "../src/tools/streams.ts", "../src/tools/subgraphs.ts", "../src/tools/subscriptions.ts"],
|
|
3
|
+
"sources": ["../src/bin-http.ts", "../src/server.ts", "../src/lib/hosted.ts", "../src/resources.ts", "../src/lib/client.ts", "../src/lib/format.ts", "../src/lib/tool.ts", "../src/tools/account.ts", "../src/tools/codegen.ts", "../src/tools/contracts.ts", "../src/tools/index.ts", "../src/tools/scaffold.ts", "../src/tools/streams.ts", "../src/tools/subgraphs.ts", "../src/tools/subscriptions.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"#!/usr/bin/env node\nimport {\n\ttype IncomingMessage,\n\ttype ServerResponse,\n\tcreateServer as createHttpServer,\n} from \"node:http\";\nimport { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\nimport { createServer } from \"./server.ts\";\n\nconst port = Number.parseInt(process.env.SECONDLAYER_MCP_PORT || \"3100\");\nconst secret = process.env.SECONDLAYER_MCP_SECRET;\nconst sessions = new Map<string, StreamableHTTPServerTransport>();\n\nfunction authenticate(req: IncomingMessage): boolean {\n\tif (!secret) return true;\n\treturn req.headers.authorization === `Bearer ${secret}`;\n}\n\nconst httpServer = createHttpServer(\n\tasync (req: IncomingMessage, res: ServerResponse) => {\n\t\t// Only handle /mcp endpoint\n\t\tconst url = new URL(req.url ?? \"/\", `http://localhost:${port}`);\n\t\tif (url.pathname !== \"/mcp\") {\n\t\t\tres.writeHead(404).end(JSON.stringify({ error: \"Not found\" }));\n\t\t\treturn;\n\t\t}\n\n\t\t// Auth check\n\t\tif (!authenticate(req)) {\n\t\t\tres.writeHead(401).end(JSON.stringify({ error: \"Unauthorized\" }));\n\t\t\treturn;\n\t\t}\n\n\t\tconst sessionId = req.headers[\"mcp-session-id\"] as string | undefined;\n\n\t\tif (req.method === \"POST\") {\n\t\t\t// Read body with 1MB limit\n\t\t\tconst MAX_BODY = 1_048_576;\n\t\t\tconst chunks: Buffer[] = [];\n\t\t\tlet totalSize = 0;\n\t\t\tfor await (const chunk of req) {\n\t\t\t\ttotalSize += (chunk as Buffer).length;\n\t\t\t\tif (totalSize > MAX_BODY) {\n\t\t\t\t\tres\n\t\t\t\t\t\t.writeHead(413)\n\t\t\t\t\t\t.end(JSON.stringify({ error: \"Request body too large\" }));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchunks.push(chunk as Buffer);\n\t\t\t}\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\tlet body: any;\n\t\t\ttry {\n\t\t\t\tbody = JSON.parse(Buffer.concat(chunks).toString());\n\t\t\t} catch {\n\t\t\t\tres.writeHead(400).end(JSON.stringify({ error: \"Invalid JSON\" }));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if this is an initialize request (new session)\n\t\t\tconst isInitialize = Array.isArray(body)\n\t\t\t\t? body.some((m: { method?: string }) => m.method === \"initialize\")\n\t\t\t\t: body.method === \"initialize\";\n\n\t\t\tif (isInitialize) {\n\t\t\t\t// Create new session\n\t\t\t\tconst transport = new StreamableHTTPServerTransport({\n\t\t\t\t\tsessionIdGenerator: () => crypto.randomUUID(),\n\t\t\t\t});\n\t\t\t\tconst server = createServer();\n\t\t\t\tawait server.connect(transport);\n\n\t\t\t\t// Store session after handling (sessionId is set after first request)\n\t\t\t\tawait transport.handleRequest(req, res, body);\n\n\t\t\t\tif (transport.sessionId) {\n\t\t\t\t\tsessions.set(transport.sessionId, transport);\n\t\t\t\t\ttransport.onclose = () => {\n\t\t\t\t\t\tif (transport.sessionId) sessions.delete(transport.sessionId);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Existing session\n\t\t\tif (!sessionId || !sessions.has(sessionId)) {\n\t\t\t\tres\n\t\t\t\t\t.writeHead(400)\n\t\t\t\t\t.end(JSON.stringify({ error: \"Invalid or missing session ID\" }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait sessions.get(sessionId)?.handleRequest(req, res, body);\n\t\t} else if (req.method === \"GET\") {\n\t\t\t// SSE stream for existing session\n\t\t\tif (!sessionId || !sessions.has(sessionId)) {\n\t\t\t\tres\n\t\t\t\t\t.writeHead(400)\n\t\t\t\t\t.end(JSON.stringify({ error: \"Invalid or missing session ID\" }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait sessions.get(sessionId)?.handleRequest(req, res);\n\t\t} else if (req.method === \"DELETE\") {\n\t\t\t// Session teardown\n\t\t\tif (sessionId && sessions.has(sessionId)) {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tconst transport = sessions.get(sessionId)!;\n\t\t\t\tawait transport.handleRequest(req, res);\n\t\t\t\tawait transport.close();\n\t\t\t\tsessions.delete(sessionId);\n\t\t\t} else {\n\t\t\t\tres\n\t\t\t\t\t.writeHead(400)\n\t\t\t\t\t.end(JSON.stringify({ error: \"Invalid or missing session ID\" }));\n\t\t\t}\n\t\t} else {\n\t\t\tres.writeHead(405).end(JSON.stringify({ error: \"Method not allowed\" }));\n\t\t}\n\t},\n);\n\nhttpServer.listen(port, () => {\n\tconsole.error(`SecondLayer MCP HTTP server listening on port ${port}`);\n\tif (!secret)\n\t\tconsole.error(\n\t\t\t\"Warning: SECONDLAYER_MCP_SECRET not set, authentication disabled\",\n\t\t);\n});\n",
|
|
6
|
-
"import { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { registerResources } from \"./resources.ts\";\nimport { registerAccountTools } from \"./tools/account.ts\";\nimport { registerCodegenTools } from \"./tools/codegen.ts\";\nimport { registerContractTools } from \"./tools/contracts.ts\";\nimport { registerIndexTools } from \"./tools/index.ts\";\nimport { registerScaffoldTools } from \"./tools/scaffold.ts\";\nimport { registerStreamsTools } from \"./tools/streams.ts\";\nimport { registerSubgraphTools } from \"./tools/subgraphs.ts\";\nimport { registerSubscriptionTools } from \"./tools/subscriptions.ts\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(\n\treadFileSync(join(__dirname, \"../package.json\"), \"utf-8\"),\n);\n\nexport function createServer(): McpServer {\n\tconst server = new McpServer({\n\t\tname: \"secondlayer\",\n\t\tversion: pkg.version,\n\t});\n\n\tregisterScaffoldTools(server);\n\tregisterSubgraphTools(server);\n\tregisterSubscriptionTools(server);\n\tregisterIndexTools(server);\n\tregisterStreamsTools(server);\n\tregisterContractTools(server);\n\tregisterCodegenTools(server);\n\tregisterAccountTools(server);\n\tregisterResources(server);\n\n\treturn server;\n}\n",
|
|
7
|
-
"
|
|
6
|
+
"import { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { isHostedArchiveUrl } from \"./lib/hosted.ts\";\nimport { registerResources } from \"./resources.ts\";\nimport { registerAccountTools } from \"./tools/account.ts\";\nimport { registerCodegenTools } from \"./tools/codegen.ts\";\nimport { registerContractTools } from \"./tools/contracts.ts\";\nimport { registerIndexTools } from \"./tools/index.ts\";\nimport { registerScaffoldTools } from \"./tools/scaffold.ts\";\nimport { registerStreamsTools } from \"./tools/streams.ts\";\nimport { registerSubgraphTools } from \"./tools/subgraphs.ts\";\nimport { registerSubscriptionTools } from \"./tools/subscriptions.ts\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(\n\treadFileSync(join(__dirname, \"../package.json\"), \"utf-8\"),\n);\n\nexport function createServer(): McpServer {\n\tconst server = new McpServer({\n\t\tname: \"secondlayer\",\n\t\tversion: pkg.version,\n\t});\n\n\tregisterScaffoldTools(server);\n\tregisterSubgraphTools(server);\n\tregisterSubscriptionTools(server);\n\tregisterIndexTools(server);\n\tregisterStreamsTools(server);\n\tregisterContractTools(server);\n\tregisterCodegenTools(server);\n\tconst baseUrl =\n\t\tprocess.env.SECONDLAYER_API_URL ||\n\t\tprocess.env.SL_API_URL ||\n\t\t\"http://127.0.0.1:3800\";\n\tif (isHostedArchiveUrl(baseUrl)) {\n\t\tregisterAccountTools(server);\n\t}\n\tregisterResources(server);\n\n\treturn server;\n}\n",
|
|
7
|
+
"export const HOSTED_ARCHIVE_HOST = \"api.secondlayer.tools\";\n\nexport function isHostedArchiveUrl(url: string): boolean {\n\ttry {\n\t\treturn new URL(url).hostname === HOSTED_ARCHIVE_HOST;\n\t} catch {\n\t\treturn false;\n\t}\n}\n",
|
|
8
|
+
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ContextField } from \"@secondlayer/sdk\";\nimport { CHAIN_TRIGGER_FIELDS } from \"@secondlayer/shared\";\nimport { TRAIT_STANDARDS } from \"@secondlayer/stacks/clarity\";\nimport { filterFieldsByType } from \"@secondlayer/subgraphs\";\nimport { TYPE_MAP } from \"@secondlayer/subgraphs/schema\";\nimport type { ColumnType } from \"@secondlayer/subgraphs/types\";\nimport { getClient, readApiKey } from \"./lib/client.ts\";\nimport { formatSubgraphSummary } from \"./lib/format.ts\";\nimport { getRegisteredToolNames } from \"./lib/tool.ts\";\n\n// SubgraphFilter vocabulary — the per-type fields an agent may set on a source\n// filter. Fields are hand-authored (the per-type breakdown lives only in the\n// SubgraphFilter interfaces), but the drift test in resources.test.ts locks the\n// type set to VALID_FILTER_TYPES and asserts every field is accepted by the\n// `.strict()` SubgraphFilterSchema, so this can never advertise a field the\n// validator rejects. `trait` (TraitScope) indexes all contracts of a standard\n// (e.g. all SIP-010 tokens). `prints` on print_event is type-level only (not a\n// runtime match field) and is intentionally omitted.\n// One-line human blurb per SIP trait standard, keyed by TRAIT_STANDARDS so a new\n// standard forces an entry here.\nconst TRAIT_BLURBS: Record<(typeof TRAIT_STANDARDS)[number], string> = {\n\t\"sip-009\": \"Non-fungible token (NFT) standard\",\n\t\"sip-010\": \"Fungible token standard\",\n\t\"sip-013\": \"Semi-fungible token standard\",\n};\n\n/**\n * Per-source-type filter fields, DERIVED from the subgraphs filter schema —\n * this was a hand-maintained parallel copy, so adding a field to a filter\n * left the agent-facing reference silently behind.\n */\nexport const FILTERS_REFERENCE: Array<{ type: string; fields: string[] }> =\n\tfilterFieldsByType();\n\n// Human blurb per column type, keyed by ColumnType so adding a type to the union\n// forces an entry here (the drift test in resources.test.ts asserts full coverage).\nconst COLUMN_TYPE_DESCRIPTIONS: Record<ColumnType, string> = {\n\ttext: \"UTF-8 string\",\n\tuint: \"Unsigned integer (Clarity uint) — NUMERIC for lossless 128-bit range\",\n\tint: \"Signed integer (Clarity int) — NUMERIC for lossless 128-bit range\",\n\tprincipal: \"Stacks address (standard or contract)\",\n\tboolean: \"Boolean value\",\n\ttimestamp: \"Timestamp with time zone\",\n\tjsonb: \"Arbitrary JSON data\",\n};\n\n// Derived from the subgraphs TYPE_MAP so the type→SQL mapping can't drift behind\n// the deployer (which is what actually creates the columns).\nexport const COLUMN_TYPES: Array<Record<string, unknown>> = [\n\t...(Object.keys(TYPE_MAP) as ColumnType[]).map((type) => ({\n\t\ttype,\n\t\tsqlType: TYPE_MAP[type],\n\t\tdescription: COLUMN_TYPE_DESCRIPTIONS[type],\n\t})),\n\t{\n\t\toptions: [\"nullable\", \"indexed\", \"search\"],\n\t\tdescription:\n\t\t\t\"Column options: nullable allows NULL, indexed creates a B-tree index, search enables full-text search\",\n\t},\n];\n\n// One-line human blurb per product surface; the tool list for each is\n// generated from the live tool registry (see buildCapabilities) so it can't\n// drift behind the actual surface.\nconst PRODUCT_BLURBS: Record<string, string> = {\n\tindex: \"decoded events, transfers, contract calls, blocks, transactions\",\n\tstreams:\n\t\t\"raw chain event firehose — cursor-paginated reads, tip/canonical/reorg checks, bulk parquet dumps\",\n\tcontracts: \"trait-based contract discovery and ABIs\",\n\tsubgraphs: \"author/scaffold/deploy/query custom indexes\",\n\tsubscriptions: \"webhook delivery on subgraph rows or raw chain events\",\n\taccount: \"identity and self-provisioned API keys\",\n\tcodegen: \"ORM schemas for the tables you read\",\n};\n\nconst PRODUCT_ORDER = [\n\t\"index\",\n\t\"streams\",\n\t\"contracts\",\n\t\"subgraphs\",\n\t\"subscriptions\",\n\t\"account\",\n\t\"codegen\",\n];\n\n/**\n * \"What you can do\" overview, generated from the registered tool names so every\n * tool surfaces under its product without a hand-maintained list to fall stale.\n * Tools register (via defineTool) before registerResources runs, so the\n * registry is fully populated by the time a context read calls this.\n */\nexport function buildCapabilities() {\n\tconst byPrefix = new Map<string, string[]>();\n\tfor (const name of getRegisteredToolNames()) {\n\t\tconst prefix = name.slice(0, name.indexOf(\"_\"));\n\t\tconst tools = byPrefix.get(prefix) ?? [];\n\t\ttools.push(name);\n\t\tbyPrefix.set(prefix, tools);\n\t}\n\tconst order = [\n\t\t...PRODUCT_ORDER.filter((p) => byPrefix.has(p)),\n\t\t...[...byPrefix.keys()].filter((p) => !PRODUCT_ORDER.includes(p)),\n\t];\n\tconst products = order.map((p) => {\n\t\tconst tools = byPrefix.get(p) ?? [];\n\t\tconst blurb = PRODUCT_BLURBS[p];\n\t\treturn blurb\n\t\t\t? `${p} — ${blurb} (${tools.join(\", \")})`\n\t\t\t: `${p} (${tools.join(\", \")})`;\n\t});\n\treturn {\n\t\tproducts,\n\t\tdiscoverFirst:\n\t\t\t\"Call index_discover / contracts_find to learn what exists (and which filters each surface accepts) before querying.\",\n\t};\n}\n\n/** Per-product read-auth tiers — what an agent must know before reading. */\nconst READ_AUTH_TIERS = {\n\tindex:\n\t\t\"keyless while the API is only reachable on loopback; the instance token is required once it is published past loopback\",\n\tstreams:\n\t\t\"keyless while the API is only reachable on loopback; the instance token is required once it is published past loopback\",\n\tsubgraphs:\n\t\t\"reads at /v1/subgraphs/<name>/<table> ({ rows, next_cursor, tip } cursor envelope) follow the same loopback rule as the other read planes; writes always require the instance token\",\n};\n\ntype ContextDeps = {\n\tclientProvider: typeof getClient;\n};\n\n/**\n * Assemble the live agent context read at connect: who you are, the live\n * Streams/Index tips, what you own (subgraphs/subscriptions), any in-flight\n * reindex operations, what the agent can do, and the read-auth tiers. The\n * snapshot comes from the SDK's `context()` (shared with non-MCP agents); each\n * field that couldn't be read becomes a sentinel string so the resource never\n * throws and always orients the agent.\n */\nexport async function buildContext(\n\tdeps: ContextDeps = { clientProvider: getClient },\n) {\n\tconst unavailable = \"unavailable: set INSTANCE_TOKEN\";\n\t// The SDK says why a field is missing; pass that reason through so the\n\t// agent can tell an unreachable API from a rejected token.\n\tconst orNull = <T>(field: ContextField<T> | undefined) => {\n\t\tif (!field) return unavailable;\n\t\tif (field.value != null) return field.value;\n\t\treturn field.error ? `unavailable: ${field.error.message}` : unavailable;\n\t};\n\n\tconst snap = await deps\n\t\t.clientProvider()\n\t\t.context()\n\t\t.catch(() => null);\n\n\treturn {\n\t\tauthState: {\n\t\t\tapiKeySet: Boolean(readApiKey()),\n\t\t},\n\t\twhatExists: {\n\t\t\taccount: orNull(snap?.account),\n\t\t\tstreamsTip: orNull(snap?.streamsTip),\n\t\t\tindexTip: orNull(snap?.indexTip),\n\t\t\tsubgraphs: snap?.subgraphs.value\n\t\t\t\t? snap.subgraphs.value.map(formatSubgraphSummary)\n\t\t\t\t: orNull(snap?.subgraphs),\n\t\t\tsubscriptions: orNull(snap?.subscriptions),\n\t\t\tactiveOperations: orNull(snap?.activeOperations),\n\t\t},\n\t\twhatYouCanDo: buildCapabilities(),\n\t\treadAuthTiers: READ_AUTH_TIERS,\n\t};\n}\n\nexport function registerResources(server: McpServer) {\n\tserver.resource(\n\t\t\"context\",\n\t\t\"secondlayer://context\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Live agent context — what exists (your subgraphs, subscriptions, account), what you can do, and read-auth tiers. Read this first.\",\n\t\t},\n\t\tasync () => ({\n\t\t\tcontents: [\n\t\t\t\t{\n\t\t\t\t\turi: \"secondlayer://context\",\n\t\t\t\t\tmimeType: \"application/json\",\n\t\t\t\t\ttext: JSON.stringify(await buildContext(), null, 2),\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t);\n\n\tserver.resource(\n\t\t\"filters\",\n\t\t\"secondlayer://filters\",\n\t\t{ description: \"Event filter types and their available fields\" },\n\t\tasync () => ({\n\t\t\tcontents: [\n\t\t\t\t{\n\t\t\t\t\turi: \"secondlayer://filters\",\n\t\t\t\t\tmimeType: \"application/json\",\n\t\t\t\t\ttext: JSON.stringify(FILTERS_REFERENCE, null, 2),\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t);\n\n\tserver.resource(\n\t\t\"column-types\",\n\t\t\"secondlayer://column-types\",\n\t\t{ description: \"Subgraph column types, SQL mappings, and options\" },\n\t\tasync () => ({\n\t\t\tcontents: [\n\t\t\t\t{\n\t\t\t\t\turi: \"secondlayer://column-types\",\n\t\t\t\t\tmimeType: \"application/json\",\n\t\t\t\t\ttext: JSON.stringify(COLUMN_TYPES, null, 2),\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t);\n\n\tserver.resource(\n\t\t\"traits\",\n\t\t\"secondlayer://traits\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"SIP trait standards the platform can classify and scaffold against — the valid values for contracts_find `trait` and subgraph scaffold `--trait`.\",\n\t\t},\n\t\tasync () => ({\n\t\t\tcontents: [\n\t\t\t\t{\n\t\t\t\t\turi: \"secondlayer://traits\",\n\t\t\t\t\tmimeType: \"application/json\",\n\t\t\t\t\ttext: JSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttraits: TRAIT_STANDARDS.map((id) => ({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tdescription: TRAIT_BLURBS[id],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t2,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t);\n\n\tserver.resource(\n\t\t\"chain-triggers\",\n\t\t\"secondlayer://chain-triggers\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Chain-subscription trigger types and the filter fields each accepts (for subscriptions_create triggers).\",\n\t\t},\n\t\tasync () => ({\n\t\t\tcontents: [\n\t\t\t\t{\n\t\t\t\t\turi: \"secondlayer://chain-triggers\",\n\t\t\t\t\tmimeType: \"application/json\",\n\t\t\t\t\ttext: JSON.stringify(CHAIN_TRIGGER_FIELDS, null, 2),\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t);\n}\n",
|
|
8
9
|
"import { SecondLayer, resolveApiKey } from \"@secondlayer/sdk\";\n\nlet instance: SecondLayer | null = null;\n\n/**\n * Read the credential from env: `INSTANCE_TOKEN` first, then its legacy alias\n * `SL_API_KEY`. Delegated to the SDK so the MCP server, CLI, and SDK resolve\n * identically. (The former `SL_SERVICE_KEY` / `SECONDLAYER_API_KEY` aliases\n * were removed.)\n */\nexport function readApiKey(): string | undefined {\n\treturn resolveApiKey();\n}\n\n/**\n * Lazy SDK singleton. Built keyless when no key is set so read tools (list,\n * get, query, spec) work during open beta — reads are public. Write tools\n * (deploy/reindex/delete) and account tools hit the API without a key and get\n * a 401, surfaced with a key hint via `keyHint` below.\n */\nexport function getClient(): SecondLayer {\n\tif (!instance) {\n\t\tconst apiKey = readApiKey();\n\t\tconst baseUrl =\n\t\t\tprocess.env.SECONDLAYER_API_URL ||\n\t\t\tprocess.env.SL_API_URL ||\n\t\t\t\"http://127.0.0.1:3800\";\n\t\tconst dumpsBaseUrl = process.env.SL_STREAMS_DUMPS_URL;\n\t\tinstance = new SecondLayer({\n\t\t\t...(apiKey ? { apiKey } : {}),\n\t\t\torigin: \"mcp\",\n\t\t\tbaseUrl,\n\t\t\t...(dumpsBaseUrl ? { dumpsBaseUrl } : {}),\n\t\t});\n\t}\n\treturn instance;\n}\n\n// Appended to 401/403 errors raised on keyless requests — the operation needs\n// a write/account key, so point at where to get one.\nexport const keyHint =\n\t\" — set INSTANCE_TOKEN from `sl init` for writes (SL_API_KEY is a legacy alias)\";\n\n/** Raw fetch helper for API endpoints not covered by the SDK. */\nexport async function apiRequest<T>(\n\tmethod: string,\n\tpath: string,\n\tbody?: unknown,\n): Promise<T> {\n\tconst apiKey = readApiKey();\n\tconst baseUrl =\n\t\tprocess.env.SECONDLAYER_API_URL ||\n\t\tprocess.env.SL_API_URL ||\n\t\t\"http://127.0.0.1:3800\";\n\tconst res = await fetch(`${baseUrl}${path}`, {\n\t\tmethod,\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),\n\t\t},\n\t\tbody: body ? JSON.stringify(body) : undefined,\n\t});\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tconst needsKey = !apiKey && (res.status === 401 || res.status === 403);\n\t\tthrow Object.assign(\n\t\t\tnew Error((text || `HTTP ${res.status}`) + (needsKey ? keyHint : \"\")),\n\t\t\t{ status: res.status },\n\t\t);\n\t}\n\tif (res.status === 204) return undefined as T;\n\treturn res.json() as Promise<T>;\n}\n",
|
|
9
10
|
"/** Summarize a subgraph for list responses. */\nexport function formatSubgraphSummary(s: {\n\tname: string;\n\tstatus: string;\n\ttables: string[] | Record<string, unknown>;\n\tlastProcessedBlock: number;\n}) {\n\treturn {\n\t\tname: s.name,\n\t\tstatus: s.status,\n\t\ttables: Array.isArray(s.tables) ? s.tables : Object.keys(s.tables),\n\t\tlastProcessedBlock: s.lastProcessedBlock,\n\t};\n}\n\n/** Cap array length and return truncation metadata. */\nexport function withCap<T>(\n\titems: T[],\n\tcap: number,\n): { items: T[]; truncated: boolean; total: number } {\n\treturn {\n\t\titems: items.slice(0, cap),\n\t\ttruncated: items.length > cap,\n\t\ttotal: items.length,\n\t};\n}\n\n/** Build MCP text response with JSON-serialized payload. */\nexport function jsonResponse(\n\tdata: unknown,\n\tisError?: boolean,\n): { content: Array<{ type: \"text\"; text: string }>; isError?: boolean } {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: JSON.stringify(data, null, 2) }],\n\t\t...(isError && { isError: true }),\n\t};\n}\n\n/** Build MCP text response with plain text payload. */\nexport function textResponse(\n\ttext: string,\n\tisError?: boolean,\n): { content: Array<{ type: \"text\"; text: string }>; isError?: boolean } {\n\treturn {\n\t\tcontent: [{ type: \"text\", text }],\n\t\t...(isError && { isError: true }),\n\t};\n}\n",
|
|
10
11
|
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\n\ninterface ToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tisError?: boolean;\n}\n\n// Names of every tool registered via defineTool, in registration order. The\n// context resource generates its capability list from this so CAPABILITIES can\n// never drift behind the actual tool surface (a new tool auto-appears). A Set\n// dedupes across repeated createServer() calls in tests.\nconst registeredToolNames = new Set<string>();\n\n/** Tool names registered so far this process (see {@link defineTool}). */\nexport function getRegisteredToolNames(): string[] {\n\treturn [...registeredToolNames];\n}\n\n/**\n * Type-safe wrapper around McpServer.tool() that avoids TS2589.\n *\n * The MCP SDK's Zod-generic `tool()` signature recurses past TypeScript's\n * instantiation depth limit when schemas contain discriminated unions or\n * nested optionals. This helper isolates the boundary cast to one place\n * so tool files stay fully typed via the explicit `T` generic.\n *\n * Schema is typed as Record<string, unknown> to prevent TypeScript from\n * resolving the deeply recursive ZodRawShapeCompat constraint. Zod still\n * validates at runtime.\n */\nexport function defineTool<T>(\n\tserver: McpServer,\n\tname: string,\n\tdescription: string,\n\tschema: Record<string, unknown>,\n\thandler: (args: T) => Promise<ToolResult> | ToolResult,\n): void {\n\tconst wrappedHandler = async (args: T): Promise<ToolResult> => {\n\t\ttry {\n\t\t\treturn await handler(args);\n\t\t} catch (err: unknown) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\tconst status =\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\t\terr instanceof Error && \"status\" in err ? (err as any).status : 0;\n\t\t\tconst type =\n\t\t\t\tstatus === 401\n\t\t\t\t\t? \"unauthorized\"\n\t\t\t\t\t: status === 404\n\t\t\t\t\t\t? \"not_found\"\n\t\t\t\t\t\t: status === 429\n\t\t\t\t\t\t\t? \"rate_limited\"\n\t\t\t\t\t\t\t: status >= 500\n\t\t\t\t\t\t\t\t? \"server_error\"\n\t\t\t\t\t\t\t\t: \"error\";\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: JSON.stringify({ error: { type, status, message } }),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tisError: true,\n\t\t\t};\n\t\t}\n\t};\n\tregisteredToolNames.add(name);\n\t(server.tool as (...args: unknown[]) => unknown)(\n\t\tname,\n\t\tdescription,\n\t\tschema,\n\t\twrappedHandler,\n\t);\n}\n",
|
|
11
|
-
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { apiRequest } from \"../lib/client.ts\";\nimport { jsonResponse } from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\nexport function registerAccountTools(server: McpServer) {\n\tdefineTool<Record<string, never>>(\n\t\tserver,\n\t\t\"account_whoami\",\n\t\t\"Show the
|
|
12
|
+
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { apiRequest } from \"../lib/client.ts\";\nimport { jsonResponse } from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\nexport function registerAccountTools(server: McpServer) {\n\tdefineTool<Record<string, never>>(\n\t\tserver,\n\t\t\"account_whoami\",\n\t\t\"Show the archive account email at api.secondlayer.tools, not the self-host instance.\",\n\t\t{},\n\t\tasync () => {\n\t\t\tconst result = await apiRequest<{ email: string }>(\n\t\t\t\t\"GET\",\n\t\t\t\t\"/api/accounts/me\",\n\t\t\t);\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n\n\tdefineTool<{ name?: string }>(\n\t\tserver,\n\t\t\"account_create_key\",\n\t\t\"Mint an account key (sk-sl_*) for archive credits, quote, and fetch at api.secondlayer.tools. The returned `key` is shown ONCE.\",\n\t\t{\n\t\t\tname: z.string().optional().describe(\"Optional label for the key\"),\n\t\t},\n\t\tasync ({ name }) =>\n\t\t\tjsonResponse(await apiRequest(\"POST\", \"/api/keys\", { name })),\n\t);\n}\n",
|
|
12
13
|
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport {\n\ttype IndexCodegenTarget,\n\tgenerateIndexSchema,\n} from \"@secondlayer/subgraphs\";\nimport { z } from \"zod\";\nimport { textResponse } from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\n/**\n * Codegen over MCP.\n *\n * An agent that has just read rows off `/v1/index` usually wants the ORM types\n * for them next, and the CLI path (`sl codegen index`) means shelling out of\n * the conversation. These are thin wrappers over the same generators the CLI\n * calls, so the emitted schema is identical either way — no second\n * implementation to drift.\n */\nconst TARGETS = [\"prisma\", \"kysely\", \"drizzle\", \"json-schema\"] as const;\n\nexport function registerCodegenTools(server: McpServer) {\n\tdefineTool<{\n\t\ttarget?: IndexCodegenTarget;\n\t\ttables?: string[];\n\t\tschemaName?: string;\n\t\tdatasourceEnv?: string;\n\t}>(\n\t\tserver,\n\t\t\"codegen_index_schema\",\n\t\t\"Generate an ORM schema for the Index tables (blocks, transactions, decoded_events, …) — the same output as `sl codegen index`. Returns the file contents as text; write it wherever your project keeps its schema. Use `tables` to emit only what you read.\",\n\t\t{\n\t\t\ttarget: z\n\t\t\t\t.enum(TARGETS)\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Output flavor (default kysely)\"),\n\t\t\ttables: z\n\t\t\t\t.array(z.string())\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Restrict to these Index tables (default: all)\"),\n\t\t\tschemaName: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Postgres schema to qualify table names with\"),\n\t\t\tdatasourceEnv: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Prisma only: datasource url env var (default DATABASE_URL)\"),\n\t\t},\n\t\t({ target, tables, schemaName, datasourceEnv }) =>\n\t\t\ttextResponse(\n\t\t\t\tgenerateIndexSchema(target ?? \"kysely\", {\n\t\t\t\t\ttables,\n\t\t\t\t\tschemaName,\n\t\t\t\t\tdatasourceEnv,\n\t\t\t\t}),\n\t\t\t),\n\t);\n}\n",
|
|
13
14
|
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { getClient } from \"../lib/client.ts\";\nimport { jsonResponse } from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\ntype ClientProvider = typeof getClient;\n\nexport function registerContractTools(\n\tserver: McpServer,\n\tclientProvider: ClientProvider = getClient,\n) {\n\tdefineTool<{\n\t\ttrait: string;\n\t\tconformance?: \"declared\" | \"inferred\" | \"any\";\n\t\tinclude?: \"abi\";\n\t\tlimit?: number;\n\t\tcursor?: string;\n\t}>(\n\t\tserver,\n\t\t\"contracts_find\",\n\t\t'Discover deployed Stacks contracts conforming to a trait (e.g. \"sip-010\", \"sip-009\", \"sip-013\"). The discovery endpoint for \"which contracts implement X\". Reads are public.',\n\t\t{\n\t\t\ttrait: z.string().describe('Required. Trait to match (e.g. \"sip-010\").'),\n\t\t\tconformance: z\n\t\t\t\t.enum([\"declared\", \"inferred\", \"any\"])\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"declared = parsed from source, inferred = ABI shape-match, any = either (default)\",\n\t\t\t\t),\n\t\t\tinclude: z\n\t\t\t\t.literal(\"abi\")\n\t\t\t\t.optional()\n\t\t\t\t.describe('Set to \"abi\" to include each contract\\'s full ABI'),\n\t\t\tlimit: z.number().optional().describe(\"Page size, 1–500 (default 100)\"),\n\t\t\tcursor: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Opaque cursor from a prior response's next_cursor\"),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().contracts.list(params)),\n\t);\n\n\tdefineTool<{ contractId: string }>(\n\t\tserver,\n\t\t\"contracts_get_abi\",\n\t\t\"Fetch a single deployed contract's ABI from the registry (prod-safe). Returns the contract's metadata + full ABI (functions, maps, variables, fungible/non-fungible tokens). Returns not_found if the contract isn't in the registry. Use it to inspect a contract before subgraphs_scaffold.\",\n\t\t{\n\t\t\tcontractId: z\n\t\t\t\t.string()\n\t\t\t\t.describe(\"Fully qualified contract id (e.g. SP….amm-pool-v2-01)\"),\n\t\t},\n\t\tasync ({ contractId }) => {\n\t\t\tconst contract = await clientProvider().contracts.get(contractId, {\n\t\t\t\tincludeAbi: true,\n\t\t\t});\n\t\t\treturn contract\n\t\t\t\t? jsonResponse(contract)\n\t\t\t\t: jsonResponse(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\ttype: \"not_found\",\n\t\t\t\t\t\t\t\tstatus: 404,\n\t\t\t\t\t\t\t\tmessage: `Contract not in registry: ${contractId}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t);\n\t\t},\n\t);\n}\n",
|
|
14
15
|
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { DECODED_EVENT_TYPES } from \"@secondlayer/shared\";\nimport { z } from \"zod\";\nimport { getClient } from \"../lib/client.ts\";\nimport { jsonResponse } from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\ntype ClientProvider = typeof getClient;\n\nconst INDEX_EVENT_TYPES = DECODED_EVENT_TYPES;\n\n/** Filters shared by the height/cursor-paginated Index endpoints. */\nconst rangeFilters = {\n\tcontractId: z.string().optional().describe(\"Filter by contract id\"),\n\tfromHeight: z.number().optional().describe(\"Start block height (inclusive)\"),\n\ttoHeight: z.number().optional().describe(\"End block height (inclusive)\"),\n\tcursor: z\n\t\t.string()\n\t\t.optional()\n\t\t.describe(\"Opaque cursor from a prior response's next_cursor\"),\n\tlimit: z.number().optional().describe(\"Max rows for this page\"),\n};\n\n/** Height-range subset for endpoints that don't filter by contract (blocks). */\nconst heightFilters = {\n\tfromHeight: rangeFilters.fromHeight,\n\ttoHeight: rangeFilters.toHeight,\n\tcursor: rangeFilters.cursor,\n\tlimit: rangeFilters.limit,\n};\n\nexport function registerIndexTools(\n\tserver: McpServer,\n\tclientProvider: ClientProvider = getClient,\n) {\n\tdefineTool<{\n\t\tcontractId?: string;\n\t\tsender?: string;\n\t\trecipient?: string;\n\t\tassetIdentifier?: string;\n\t\tfromHeight?: number;\n\t\ttoHeight?: number;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}>(\n\t\tserver,\n\t\t\"index_ft_transfers\",\n\t\t\"List decoded SIP-010 fungible-token transfers from Index. Reads are keyless.\",\n\t\t{\n\t\t\t...rangeFilters,\n\t\t\tsender: z.string().optional().describe(\"Filter by sender principal\"),\n\t\t\trecipient: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by recipient principal\"),\n\t\t\tassetIdentifier: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token\",\n\t\t\t\t),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.ftTransfers.list(params)),\n\t);\n\n\tdefineTool<{\n\t\tcontractId?: string;\n\t\tsender?: string;\n\t\trecipient?: string;\n\t\tassetIdentifier?: string;\n\t\tfromHeight?: number;\n\t\ttoHeight?: number;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}>(\n\t\tserver,\n\t\t\"index_nft_transfers\",\n\t\t\"List decoded SIP-009 non-fungible-token transfers from Index. Reads are keyless.\",\n\t\t{\n\t\t\t...rangeFilters,\n\t\t\tsender: z.string().optional().describe(\"Filter by sender principal\"),\n\t\t\trecipient: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by recipient principal\"),\n\t\t\tassetIdentifier: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by asset identifier (contract::asset)\"),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.nftTransfers.list(params)),\n\t);\n\n\tdefineTool<{\n\t\teventType: (typeof INDEX_EVENT_TYPES)[number];\n\t\tcontractId?: string;\n\t\tsender?: string;\n\t\trecipient?: string;\n\t\tassetIdentifier?: string;\n\t\ttrait?: string;\n\t\ttxContext?: boolean;\n\t\tfromHeight?: number;\n\t\ttoHeight?: number;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}>(\n\t\tserver,\n\t\t\"index_events\",\n\t\t\"List decoded chain events from the Index by event type. Use this for event types without a dedicated tool (stx_*, ft_mint/burn, nft_mint/burn, print), and for trait-scoped queries: set `trait` (e.g. sip-010) to match all contracts conforming to a standard — pair with contracts_find to discover traits. For ft/nft transfers without a trait prefer index_ft_transfers / index_nft_transfers.\",\n\t\t{\n\t\t\teventType: z\n\t\t\t\t.enum(INDEX_EVENT_TYPES)\n\t\t\t\t.describe(\"Required. Decoded event type to list.\"),\n\t\t\t...rangeFilters,\n\t\t\tsender: z.string().optional().describe(\"Filter by sender principal\"),\n\t\t\trecipient: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by recipient principal\"),\n\t\t\tassetIdentifier: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by asset identifier where applicable\"),\n\t\t\ttrait: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only.\",\n\t\t\t\t),\n\t\t\ttxContext: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Join the submitting transaction into each event (tx_sender, tx_type, tx_status, tx_contract_id, tx_function_name). For print events it's the only source of the submitting sender.\",\n\t\t\t\t),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.events.list(params)),\n\t);\n\n\tdefineTool<{\n\t\tcontractId?: string;\n\t\tfunctionName?: string;\n\t\tsender?: string;\n\t\ttrait?: string;\n\t\tfromHeight?: number;\n\t\ttoHeight?: number;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}>(\n\t\tserver,\n\t\t\"index_contract_calls\",\n\t\t\"List decoded contract calls from the Index (function name, args, result). Set `trait` (e.g. sip-010) to match calls to all contracts conforming to a standard. Note: contract-call cursors are a SEPARATE keyspace from event cursors — they are not interchangeable.\",\n\t\t{\n\t\t\t...rangeFilters,\n\t\t\tfunctionName: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by called function name\"),\n\t\t\tsender: z.string().optional().describe(\"Filter by caller principal\"),\n\t\t\ttrait: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.\",\n\t\t\t\t),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.contractCalls.list(params)),\n\t);\n\n\tdefineTool<{\n\t\tfromHeight?: number;\n\t\ttoHeight?: number;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}>(\n\t\tserver,\n\t\t\"index_blocks\",\n\t\t\"List decoded blocks from Index. Reads are keyless.\",\n\t\t{ ...heightFilters },\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.blocks.list(params)),\n\t);\n\n\tdefineTool<{\n\t\ttype?: string;\n\t\tsender?: string;\n\t\tcontractId?: string;\n\t\tfromHeight?: number;\n\t\ttoHeight?: number;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}>(\n\t\tserver,\n\t\t\"index_transactions\",\n\t\t\"List decoded transactions from Index. Filter by type, sender, or contract. Reads are keyless.\",\n\t\t{\n\t\t\t...rangeFilters,\n\t\t\ttype: z.string().optional().describe(\"Filter by transaction type\"),\n\t\t\tsender: z.string().optional().describe(\"Filter by sender principal\"),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.transactions.list(params)),\n\t);\n\n\tdefineTool<{ contractId: string }>(\n\t\tserver,\n\t\t\"index_print_schema\",\n\t\t\"Empirical per-topic print payload schemas for a contract, inferred from sampled on-chain events: each topic's fields with observed Clarity types, decoded TS types, subgraph column types, and presence rates. Use before writing print_event subgraph handlers to learn what's on e.data. Anonymous read.\",\n\t\t{\n\t\t\tcontractId: z\n\t\t\t\t.string()\n\t\t\t\t.describe(\"Contract id (SP….name) whose print events to profile\"),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().index.printSchema(params.contractId)),\n\t);\n\n\tdefineTool<Record<string, never>>(\n\t\tserver,\n\t\t\"index_discover\",\n\t\t\"Discover the Index vocabulary: every event type and its columns, allowed/equality filters, and required-non-null fields (and which types accept `trait`). Read this before building Index queries instead of guessing filters. Anonymous read.\",\n\t\t{},\n\t\tasync () => jsonResponse(await clientProvider().index.discover()),\n\t);\n\n\tdefineTool<{\n\t\trequests: Array<{ path: string; params?: Record<string, string> }>;\n\t}>(\n\t\tserver,\n\t\t\"batch_query\",\n\t\t\"Run up to 10 public /v1 reads in one round trip (POST /v1/batch). Each item keeps its own auth/quota/pay-per-call semantics; results return in order with per-item status. Paths must start with /v1/index, /v1/subgraphs, /v1/streams, or /v1/contracts.\",\n\t\t{\n\t\t\trequests: z\n\t\t\t\t.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tpath: z.string().describe(\"Public /v1 read path\"),\n\t\t\t\t\t\tparams: z.record(z.string(), z.string()).optional(),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.min(1)\n\t\t\t\t.max(10)\n\t\t\t\t.describe(\"Read descriptors, executed concurrently\"),\n\t\t},\n\t\tasync (params) =>\n\t\t\tjsonResponse(await clientProvider().batch(params.requests)),\n\t);\n}\n",
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { bundleSubgraphCode } from \"@secondlayer/bundler\";\nimport { z } from \"zod\";\nimport { getClient } from \"../lib/client.ts\";\nimport {\n\tformatSubgraphSummary,\n\tjsonResponse,\n\ttextResponse,\n\twithCap,\n} from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\ntype SubgraphClientProvider = typeof getClient;\n\nexport function registerSubgraphTools(\n\tserver: McpServer,\n\tclientProvider: SubgraphClientProvider = getClient,\n) {\n\tdefineTool<Record<string, never>>(\n\t\tserver,\n\t\t\"subgraphs_list\",\n\t\t\"List all deployed subgraphs. Returns summary fields only; read rows with subgraphs_query.\",\n\t\t{},\n\t\tasync () => {\n\t\t\tconst { data } = await clientProvider().subgraphs.list();\n\t\t\treturn jsonResponse(data.map(formatSubgraphSummary));\n\t\t},\n\t);\n\n\tdefineTool<{ name: string }>(\n\t\tserver,\n\t\t\"subgraphs_status\",\n\t\t\"Get full details of a subgraph including schema, health, and table columns.\",\n\t\t{ name: z.string().describe(\"Subgraph name\") },\n\t\tasync ({ name }) => {\n\t\t\tconst detail = await clientProvider().subgraphs.status(name);\n\t\t\treturn jsonResponse(detail);\n\t\t},\n\t);\n\n\tdefineTool<{ name: string; format?: \"agent\" | \"openapi\" | \"markdown\" }>(\n\t\tserver,\n\t\t\"subgraphs_spec\",\n\t\t\"Fetch a subgraph's self-describing spec — the tables, columns, filters, and read URLs a consumer needs, without guessing. `agent` (default) returns the compact JSON schema built for tool use, `openapi` the OpenAPI document for the subgraph's read routes, `markdown` human-readable docs. Read it before writing queries against an unfamiliar subgraph.\",\n\t\t{\n\t\t\tname: z.string().describe(\"Subgraph name\"),\n\t\t\tformat: z\n\t\t\t\t.enum([\"agent\", \"openapi\", \"markdown\"])\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md\",\n\t\t\t\t),\n\t\t},\n\t\tasync ({ name, format }) => {\n\t\t\tconst client = clientProvider();\n\t\t\tif (format === \"openapi\")\n\t\t\t\treturn jsonResponse(await client.subgraphs.openapi(name));\n\t\t\tif (format === \"markdown\")\n\t\t\t\treturn textResponse(await client.subgraphs.markdown(name));\n\t\t\treturn jsonResponse(await client.subgraphs.schema(name));\n\t\t},\n\t);\n\n\tdefineTool<{\n\t\tname: string;\n\t\ttable: string;\n\t\tfilters?: Record<string, string>;\n\t\tsort?: string;\n\t\torder?: string;\n\t\tlimit?: number;\n\t\toffset?: number;\n\t\tfields?: string;\n\t\tcount?: boolean;\n\t}>(\n\t\tserver,\n\t\t\"subgraphs_query\",\n\t\t'Query rows from a subgraph table (max 200 rows). Filters support operators: \"amount.gte\": \"1000\", \"sender.neq\": \"SP...\", \"name.like\": \"%token%\". Available operators: eq, neq, gt, gte, lt, lte, like. To TAIL new rows (no streaming over MCP): sort=_id, order=desc for the latest, then poll forward with the filter {\"_id.gt\": \"<last _id seen>\"}, order=asc — when tailing with a `fields` list, include \"_id\" in it or the next poll filter cannot be formed. Fetch one row by id with {\"_id\": \"<id>\"}. The same rows are readable over HTTP at GET /v1/subgraphs/<name>/<table> — { rows, next_cursor, tip } envelope, resume with ?cursor=<next_cursor> + _order=asc|desc (no _offset/_sort on /v1); hand that URL to third parties.',\n\t\t{\n\t\t\tname: z.string().describe(\"Subgraph name\"),\n\t\t\ttable: z.string().describe(\"Table name\"),\n\t\t\tfilters: z\n\t\t\t\t.record(z.string(), z.string())\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t'Column filters — plain values or with operators (e.g. {\"amount.gte\": \"1000\", \"sender\": \"SP...\"})',\n\t\t\t\t),\n\t\t\tsort: z.string().optional().describe(\"Column to sort by\"),\n\t\t\torder: z.enum([\"asc\", \"desc\"]).optional().describe(\"Sort order\"),\n\t\t\tlimit: z\n\t\t\t\t.number()\n\t\t\t\t.max(200)\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Max rows (default 50, max 200)\"),\n\t\t\toffset: z.number().optional().describe(\"Offset for pagination\"),\n\t\t\tfields: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t'Comma-separated column list to return (e.g. \"sender,amount\")',\n\t\t\t\t),\n\t\t\tcount: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"If true, return row count instead of rows\"),\n\t\t},\n\t\tasync ({\n\t\t\tname,\n\t\t\ttable,\n\t\t\tfilters,\n\t\t\tsort,\n\t\t\torder,\n\t\t\tlimit,\n\t\t\toffset,\n\t\t\tfields,\n\t\t\tcount,\n\t\t}) => {\n\t\t\tif (count) {\n\t\t\t\tconst result = await clientProvider().subgraphs.queryTableCount(\n\t\t\t\t\tname,\n\t\t\t\t\ttable,\n\t\t\t\t\t{ filters, sort, order },\n\t\t\t\t);\n\t\t\t\treturn jsonResponse(result);\n\t\t\t}\n\t\t\tconst rows = await clientProvider().subgraphs.queryTable(name, table, {\n\t\t\t\tfilters,\n\t\t\t\tsort,\n\t\t\t\torder,\n\t\t\t\tlimit: limit ?? 50,\n\t\t\t\toffset,\n\t\t\t\tfields,\n\t\t\t});\n\t\t\tconst result = withCap(\n\t\t\t\trows as Record<string, unknown>[],\n\t\t\t\tMath.min(limit ?? 50, 200),\n\t\t\t);\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n\n\tdefineTool<{ name: string }>(\n\t\tserver,\n\t\t\"subgraphs_reindex\",\n\t\t\"Reindex a subgraph: drops and rebuilds the whole subgraph from its start block to chain tip. Takes no block range — use subgraphs_backfill to process a specific range. Returns an operationId — check subgraphs_status (health) or the REST operations endpoint to track progress to completion.\",\n\t\t{\n\t\t\tname: z.string().describe(\"Subgraph name\"),\n\t\t},\n\t\tasync ({ name }) => {\n\t\t\tconst result = await clientProvider().subgraphs.reindex(name);\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n\n\tdefineTool<{ name: string; fromBlock: number; toBlock: number }>(\n\t\tserver,\n\t\t\"subgraphs_backfill\",\n\t\t\"Backfill a subgraph over a block range. Non-destructive forward fill (does not drop existing data) — unlike subgraphs_reindex, and the only data-fill path for BYO subgraphs (reindex is blocked there). Both blocks required. Returns an operationId — check subgraphs_status (health) or the REST operations endpoint to track progress.\",\n\t\t{\n\t\t\tname: z.string().describe(\"Subgraph name\"),\n\t\t\tfromBlock: z\n\t\t\t\t.number()\n\t\t\t\t.int()\n\t\t\t\t.nonnegative()\n\t\t\t\t.describe(\"Start block (inclusive)\"),\n\t\t\ttoBlock: z.number().int().nonnegative().describe(\"End block (inclusive)\"),\n\t\t},\n\t\tasync ({ name, fromBlock, toBlock }) => {\n\t\t\tconst result = await clientProvider().subgraphs.backfill(name, {\n\t\t\t\tfromBlock,\n\t\t\t\ttoBlock,\n\t\t\t});\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n\n\tdefineTool<{ name: string }>(\n\t\tserver,\n\t\t\"subgraphs_stop\",\n\t\t\"Cancel an in-flight reindex or backfill operation for a subgraph. Returns the stop request status; check subgraphs_status (health) or the REST operations endpoint to confirm it reaches a terminal state.\",\n\t\t{ name: z.string().describe(\"Subgraph name\") },\n\t\tasync ({ name }) => {\n\t\t\tconst result = await clientProvider().subgraphs.stop(name);\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n\n\tdefineTool<{\n\t\tname: string;\n\t\tlimit?: number;\n\t\toffset?: number;\n\t\tresolved?: boolean;\n\t}>(\n\t\tserver,\n\t\t\"subgraphs_gaps\",\n\t\t\"List indexing gaps (missing block ranges) for a subgraph. Each gap reports start/end/size, reason, and detected/resolved timestamps. Feed an unresolved gap's range into subgraphs_backfill to fill it. Defaults to unresolved gaps.\",\n\t\t{\n\t\t\tname: z.string().describe(\"Subgraph name\"),\n\t\t\tlimit: z\n\t\t\t\t.number()\n\t\t\t\t.int()\n\t\t\t\t.positive()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Max gaps to return\"),\n\t\t\toffset: z\n\t\t\t\t.number()\n\t\t\t\t.int()\n\t\t\t\t.nonnegative()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Pagination offset\"),\n\t\t\tresolved: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Filter by resolved state (omit for unresolved only)\"),\n\t\t},\n\t\tasync ({ name, limit, offset, resolved }) => {\n\t\t\tconst result = await clientProvider().subgraphs.gaps(name, {\n\t\t\t\tlimit,\n\t\t\t\toffset,\n\t\t\t\tresolved,\n\t\t\t});\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n\n\tdefineTool<{ name: string; operationId?: string }>(\n\t\tserver,\n\t\t\"subgraphs_operations\",\n\t\t\"Operation history for a subgraph (deploy/reindex/backfill/stop), newest first — status, block range, progress, and error. THIS IS THE VERIFY CALL: after subgraphs_deploy, subgraphs_reindex, subgraphs_backfill, or subgraphs_stop, poll it with the returned operationId until `status` is terminal (completed/failed/cancelled) before reporting success. Omit operationId for the recent history.\",\n\t\t{\n\t\t\tname: z.string().describe(\"Subgraph name\"),\n\t\t\toperationId: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history\",\n\t\t\t\t),\n\t\t},\n\t\tasync ({ name, operationId }) => {\n\t\t\tconst client = clientProvider();\n\t\t\treturn jsonResponse(\n\t\t\t\toperationId\n\t\t\t\t\t? await client.subgraphs.getOperation(name, operationId)\n\t\t\t\t\t: await client.subgraphs.operations(name),\n\t\t\t);\n\t\t},\n\t);\n\n\tdefineTool<{ name: string }>(\n\t\tserver,\n\t\t\"subgraphs_delete\",\n\t\t\"Delete a subgraph permanently.\",\n\t\t{ name: z.string().describe(\"Subgraph name\") },\n\t\tasync ({ name }) => {\n\t\t\tconst result = await clientProvider().subgraphs.delete(name);\n\t\t\treturn textResponse(result.message);\n\t\t},\n\t);\n\n\tdefineTool<{\n\t\tcode: string;\n\t\tstartBlock?: number;\n\t\tdryRun?: boolean;\n\t}>(\n\t\tserver,\n\t\t\"subgraphs_deploy\",\n\t\t\"Deploy a subgraph from TypeScript code. Pass the full defineSubgraph() source — it will be bundled, validated, and deployed. Optional startBlock overrides the source definition for this deploy. Set dryRun to validate and preview the schema/DDL without writing anything. Call `subgraphs_reindex` separately if you need a forced reindex.\",\n\t\t{\n\t\t\tcode: z\n\t\t\t\t.string()\n\t\t\t\t.describe(\"TypeScript source code containing a defineSubgraph() call\"),\n\t\t\tstartBlock: z\n\t\t\t\t.number()\n\t\t\t\t.int()\n\t\t\t\t.nonnegative()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Override the definition startBlock for this deploy\"),\n\t\t\tdryRun: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Validate and preview the deploy (schema/DDL) without writing changes\",\n\t\t\t\t),\n\t\t},\n\t\tasync ({ code, startBlock, dryRun }) => {\n\t\t\tconst bundled = await bundleSubgraphCode(code);\n\t\t\tconst result = await clientProvider().subgraphs.deploy({\n\t\t\t\tname: bundled.name,\n\t\t\t\tversion: bundled.version,\n\t\t\t\tdescription: bundled.description,\n\t\t\t\tsources: bundled.sources,\n\t\t\t\tschema: bundled.schema,\n\t\t\t\thandlerCode: bundled.handlerCode,\n\t\t\t\tsourceCode: code,\n\t\t\t\t...(startBlock !== undefined ? { startBlock } : {}),\n\t\t\t\t...(dryRun !== undefined ? { dryRun } : {}),\n\t\t\t});\n\t\t\treturn jsonResponse(result);\n\t\t},\n\t);\n}\n",
|
|
18
19
|
"import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type {\n\tChainTrigger,\n\tCreateSubscriptionRequest,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/sdk\";\nimport { CHAIN_TRIGGER_TYPES } from \"@secondlayer/shared\";\nimport { z } from \"zod\";\nimport { getClient } from \"../lib/client.ts\";\nimport { jsonResponse } from \"../lib/format.ts\";\nimport { defineTool } from \"../lib/tool.ts\";\n\ntype SubscriptionClientProvider = typeof getClient;\n\n/**\n * Subscription MCP tools — let agents list, configure, test, and replay\n * subgraph event subscriptions. Mirrors the HTTP API 1:1; structured\n * errors bubble through the SDK's ApiError.\n */\nexport function registerSubscriptionTools(\n\tserver: McpServer,\n\tclientProvider: SubscriptionClientProvider = getClient,\n) {\n\tdefineTool<Record<string, never>>(\n\t\tserver,\n\t\t\"subscriptions_list\",\n\t\t\"List all subscriptions for the current account. Returns summary fields (no secrets).\",\n\t\t{},\n\t\tasync () => {\n\t\t\tconst { data } = await clientProvider().subscriptions.list();\n\t\t\treturn jsonResponse(data);\n\t\t},\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_get\",\n\t\t\"Get full detail for a subscription (filter, auth, retry config, circuit state).\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) => {\n\t\t\tconst detail = await clientProvider().subscriptions.get(id);\n\t\t\treturn jsonResponse(detail);\n\t\t},\n\t);\n\n\tdefineTool<{\n\t\tname: string;\n\t\tsubgraphName?: string;\n\t\ttableName?: string;\n\t\ttriggers?: ChainTrigger[];\n\t\turl: string;\n\t\tformat?:\n\t\t\t| \"standard-webhooks\"\n\t\t\t| \"inngest\"\n\t\t\t| \"trigger\"\n\t\t\t| \"cloudflare\"\n\t\t\t| \"cloudevents\"\n\t\t\t| \"raw\";\n\t\truntime?: \"inngest\" | \"trigger\" | \"cloudflare\" | \"node\";\n\t\tfilter?: Record<string, unknown>;\n\t\tauthConfig?: Record<string, unknown>;\n\t}>(\n\t\tserver,\n\t\t\"subscriptions_create\",\n\t\t\"Create a subscription. Two kinds (mutually exclusive): a SUBGRAPH subscription fires on a subgraph table's rows (set subgraphName + tableName + optional filter); a CHAIN subscription fires on raw chain events with no subgraph (set triggers). Returns `signingSecret` ONCE — forward it to the user so they can wire it into their receiver.\",\n\t\t{\n\t\t\tname: z.string().describe(\"Human-readable name, unique per account\"),\n\t\t\tsubgraphName: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Subgraph to subscribe to (subgraph subscription)\"),\n\t\t\ttableName: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Table within the subgraph (subgraph subscription)\"),\n\t\t\ttriggers: z\n\t\t\t\t.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z.enum(CHAIN_TRIGGER_TYPES),\n\t\t\t\t\t\tcontractId: z.string().optional(),\n\t\t\t\t\t\tfunctionName: z.string().optional(),\n\t\t\t\t\t\tcaller: z.string().optional(),\n\t\t\t\t\t\tsender: z.string().optional(),\n\t\t\t\t\t\trecipient: z.string().optional(),\n\t\t\t\t\t\tassetIdentifier: z.string().optional(),\n\t\t\t\t\t\tdeployer: z.string().optional(),\n\t\t\t\t\t\tcontractName: z.string().optional(),\n\t\t\t\t\t\ttopic: z.string().optional(),\n\t\t\t\t\t\tlockedAddress: z.string().optional(),\n\t\t\t\t\t\ttrait: z.string().optional(),\n\t\t\t\t\t\tminAmount: z.union([z.string(), z.number()]).optional(),\n\t\t\t\t\t\tmaxAmount: z.union([z.string(), z.number()]).optional(),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Chain triggers (chain subscription) — provide INSTEAD of subgraphName/tableName. Each targets a raw chain event/tx; string fields accept `*` wildcards, `trait` scopes to a SIP/trait. Per-type accepted fields: see the secondlayer://chain-triggers resource. Forward-looking: starts at chain tip, no backfill.\",\n\t\t\t\t),\n\t\t\turl: z.string().describe(\"Webhook URL\"),\n\t\t\tformat: z\n\t\t\t\t.enum([\n\t\t\t\t\t\"standard-webhooks\",\n\t\t\t\t\t\"inngest\",\n\t\t\t\t\t\"trigger\",\n\t\t\t\t\t\"cloudflare\",\n\t\t\t\t\t\"cloudevents\",\n\t\t\t\t\t\"raw\",\n\t\t\t\t])\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Wire format (default standard-webhooks)\"),\n\t\t\truntime: z\n\t\t\t\t.enum([\"inngest\", \"trigger\", \"cloudflare\", \"node\"])\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Receiver runtime label (display only)\"),\n\t\t\tfilter: z\n\t\t\t\t.record(z.string(), z.unknown())\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t'Scalar filter DSL, e.g. {\"amount\": {\"gte\": 100}, \"sender\": \"SP...\"}',\n\t\t\t\t),\n\t\t\tauthConfig: z\n\t\t\t\t.record(z.string(), z.unknown())\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t'Receiver auth sent with each delivery, e.g. {\"type\": \"bearer\", \"token\": \"...\"}',\n\t\t\t\t),\n\t\t},\n\t\tasync (input) => {\n\t\t\tconst res = await clientProvider().subscriptions.create(\n\t\t\t\tinput as CreateSubscriptionRequest,\n\t\t\t);\n\t\t\treturn jsonResponse(res);\n\t\t},\n\t);\n\n\tdefineTool<{\n\t\tid: string;\n\t\tname?: string;\n\t\turl?: string;\n\t\tfilter?: Record<string, unknown>;\n\t\tauthConfig?: Record<string, unknown>;\n\t\tformat?:\n\t\t\t| \"standard-webhooks\"\n\t\t\t| \"inngest\"\n\t\t\t| \"trigger\"\n\t\t\t| \"cloudflare\"\n\t\t\t| \"cloudevents\"\n\t\t\t| \"raw\";\n\t\truntime?: \"inngest\" | \"trigger\" | \"cloudflare\" | \"node\" | null;\n\t\tmaxRetries?: number;\n\t\ttimeoutMs?: number;\n\t\tconcurrency?: number;\n\t}>(\n\t\tserver,\n\t\t\"subscriptions_update\",\n\t\t\"Patch a subscription (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).\",\n\t\t{\n\t\t\tid: z.string(),\n\t\t\tname: z.string().optional().describe(\"Rename the subscription\"),\n\t\t\turl: z.string().optional(),\n\t\t\tfilter: z.record(z.string(), z.unknown()).optional(),\n\t\t\tauthConfig: z\n\t\t\t\t.record(z.string(), z.unknown())\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Receiver auth sent with each delivery (bearer/etc.)\"),\n\t\t\tformat: z\n\t\t\t\t.enum([\n\t\t\t\t\t\"standard-webhooks\",\n\t\t\t\t\t\"inngest\",\n\t\t\t\t\t\"trigger\",\n\t\t\t\t\t\"cloudflare\",\n\t\t\t\t\t\"cloudevents\",\n\t\t\t\t\t\"raw\",\n\t\t\t\t])\n\t\t\t\t.optional(),\n\t\t\truntime: z\n\t\t\t\t.enum([\"inngest\", \"trigger\", \"cloudflare\", \"node\"])\n\t\t\t\t.nullable()\n\t\t\t\t.optional(),\n\t\t\tmaxRetries: z.number().int().min(0).optional(),\n\t\t\ttimeoutMs: z.number().int().min(100).optional(),\n\t\t\tconcurrency: z.number().int().min(1).optional(),\n\t\t},\n\t\tasync ({ id, ...patch }) => {\n\t\t\tconst res = await clientProvider().subscriptions.update(\n\t\t\t\tid,\n\t\t\t\tpatch as UpdateSubscriptionRequest,\n\t\t\t);\n\t\t\treturn jsonResponse(res);\n\t\t},\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_delete\",\n\t\t\"Delete a subscription. Pending outbox rows are cascade-deleted.\",\n\t\t{ id: z.string() },\n\t\tasync ({ id }) => {\n\t\t\tconst res = await clientProvider().subscriptions.delete(id);\n\t\t\treturn jsonResponse(res);\n\t\t},\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_test\",\n\t\t\"Send a one-off test webhook to a subscription's URL (built for its format, SSRF-guarded). Logged as a delivery row. Returns {ok, statusCode, error, durationMs, deliveryId}.\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) => {\n\t\t\tconst res = await clientProvider().subscriptions.test(id);\n\t\t\treturn jsonResponse(res);\n\t\t},\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_pause\",\n\t\t\"Pause a subscription: stops delivery attempts and stops queueing new ones. Nothing is deleted — resume picks the subscription back up from the tip. Verify with subscriptions_get (status).\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) =>\n\t\t\tjsonResponse(await clientProvider().subscriptions.pause(id)),\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_resume\",\n\t\t\"Resume a paused subscription (also clears a tripped circuit breaker). Deliveries restart from the current tip — use subscriptions_replay for the blocks missed while paused. Verify with subscriptions_get (status).\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) =>\n\t\t\tjsonResponse(await clientProvider().subscriptions.resume(id)),\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_rotate_secret\",\n\t\t\"Rotate a subscription's webhook signing secret. Returns the NEW `signingSecret` ONCE — forward it to the user; deliveries signed with the old secret stop verifying as soon as this returns, so the receiver must be updated.\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) =>\n\t\t\tjsonResponse(await clientProvider().subscriptions.rotateSecret(id)),\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_deliveries\",\n\t\t\"List recent delivery attempts for a subscription — status code, attempt count, error, duration, timestamps. THIS IS THE VERIFY CALL: after subscriptions_create, subscriptions_test, or subscriptions_replay, read it to confirm the webhook actually landed (and to see the receiver's response when it didn't) instead of trusting the enqueue result.\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) =>\n\t\t\tjsonResponse(await clientProvider().subscriptions.deliveries(id)),\n\t);\n\n\tdefineTool<{ id: string }>(\n\t\tserver,\n\t\t\"subscriptions_dead\",\n\t\t\"List a subscription's dead-letter queue — deliveries that exhausted their retries, with the outbox id, payload, and last error. Diagnose the receiver first (subscriptions_get for the URL/auth, subscriptions_test for a live probe), then requeue rows with subscriptions_requeue.\",\n\t\t{ id: z.string().describe(\"Subscription id\") },\n\t\tasync ({ id }) =>\n\t\t\tjsonResponse(await clientProvider().subscriptions.dead(id)),\n\t);\n\n\tdefineTool<{ id: string; outboxId: string }>(\n\t\tserver,\n\t\t\"subscriptions_requeue\",\n\t\t\"Requeue ONE dead-lettered delivery for another attempt, by its outbox id from subscriptions_dead. Fix the receiver first — a requeue against a still-broken endpoint just dies again. Verify with subscriptions_deliveries.\",\n\t\t{\n\t\t\tid: z.string().describe(\"Subscription id\"),\n\t\t\toutboxId: z\n\t\t\t\t.string()\n\t\t\t\t.describe(\"Outbox id of the dead delivery (from subscriptions_dead)\"),\n\t\t},\n\t\tasync ({ id, outboxId }) =>\n\t\t\tjsonResponse(await clientProvider().subscriptions.requeue(id, outboxId)),\n\t);\n\n\tdefineTool<{\n\t\tid: string;\n\t\tfromBlock: number;\n\t\ttoBlock: number;\n\t\tforce?: string;\n\t}>(\n\t\tserver,\n\t\t\"subscriptions_replay\",\n\t\t\"Replay a block range for a subscription. Replays run at 10% of batch capacity — use sparingly. Pass `force` (a short idempotency suffix) to re-run a range that was already replayed.\",\n\t\t{\n\t\t\tid: z.string(),\n\t\t\tfromBlock: z.number().int().nonnegative(),\n\t\t\ttoBlock: z.number().int().nonnegative(),\n\t\t\tforce: z\n\t\t\t\t.string()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Idempotency suffix to force a duplicate replay of the range\",\n\t\t\t\t),\n\t\t},\n\t\tasync ({ id, fromBlock, toBlock, force }) => {\n\t\t\tconst res = await clientProvider().subscriptions.replay(id, {\n\t\t\t\tfromBlock,\n\t\t\t\ttoBlock,\n\t\t\t\t...(force !== undefined ? { force } : {}),\n\t\t\t});\n\t\t\treturn jsonResponse(res);\n\t\t},\n\t);\n}\n"
|
|
19
20
|
],
|
|
20
|
-
"mappings": ";;;AACA;AAAA,kBAGC;AAAA;AAED;;;ACNA;AACA;AACA;AACA;;;ACFA;AACA;AACA;AACA;;;ACJA;AAEA,IAAI,WAA+B;AAQ5B,SAAS,UAAU,GAAuB;AAAA,EAChD,OAAO,cAAc;AAAA;AASf,SAAS,SAAS,GAAgB;AAAA,EACxC,IAAI,CAAC,UAAU;AAAA,IACd,MAAM,SAAS,WAAW;AAAA,IAC1B,MAAM,UACL,QAAQ,IAAI,uBACZ,QAAQ,IAAI,cACZ;AAAA,IACD,MAAM,eAAe,QAAQ,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AAG,EAAE,IAAI,KAAK,UAAU,EAAE,OAAO,qBAAqB,CAAC,CAAC;AAAA;AAAA,CAGzE;AAEA,WAAW,OAAO,MAAM,MAAM;AAAA,EAC7B,QAAQ,MAAM,iDAAiD,MAAM;AAAA,EACrE,IAAI,CAAC;AAAA,IACJ,QAAQ,MACP,kEACD;AAAA,CACD;",
|
|
22
|
+
"debugId": "83999A89E39499BE64756E2164756E21",
|
|
22
23
|
"names": []
|
|
23
24
|
}
|
package/dist/bin.js
CHANGED
|
@@ -9,6 +9,16 @@ import { dirname, join } from "node:path";
|
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
11
|
|
|
12
|
+
// src/lib/hosted.ts
|
|
13
|
+
var HOSTED_ARCHIVE_HOST = "api.secondlayer.tools";
|
|
14
|
+
function isHostedArchiveUrl(url) {
|
|
15
|
+
try {
|
|
16
|
+
return new URL(url).hostname === HOSTED_ARCHIVE_HOST;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
// src/resources.ts
|
|
13
23
|
import { CHAIN_TRIGGER_FIELDS } from "@secondlayer/shared";
|
|
14
24
|
import { TRAIT_STANDARDS } from "@secondlayer/stacks/clarity";
|
|
@@ -188,7 +198,13 @@ var READ_AUTH_TIERS = {
|
|
|
188
198
|
};
|
|
189
199
|
async function buildContext(deps = { clientProvider: getClient }) {
|
|
190
200
|
const unavailable = "unavailable: set INSTANCE_TOKEN";
|
|
191
|
-
const orNull = (
|
|
201
|
+
const orNull = (field) => {
|
|
202
|
+
if (!field)
|
|
203
|
+
return unavailable;
|
|
204
|
+
if (field.value != null)
|
|
205
|
+
return field.value;
|
|
206
|
+
return field.error ? `unavailable: ${field.error.message}` : unavailable;
|
|
207
|
+
};
|
|
192
208
|
const snap = await deps.clientProvider().context().catch(() => null);
|
|
193
209
|
return {
|
|
194
210
|
authState: {
|
|
@@ -198,7 +214,7 @@ async function buildContext(deps = { clientProvider: getClient }) {
|
|
|
198
214
|
account: orNull(snap?.account),
|
|
199
215
|
streamsTip: orNull(snap?.streamsTip),
|
|
200
216
|
indexTip: orNull(snap?.indexTip),
|
|
201
|
-
subgraphs: snap?.subgraphs ? snap.subgraphs.map(formatSubgraphSummary) :
|
|
217
|
+
subgraphs: snap?.subgraphs.value ? snap.subgraphs.value.map(formatSubgraphSummary) : orNull(snap?.subgraphs),
|
|
202
218
|
subscriptions: orNull(snap?.subscriptions),
|
|
203
219
|
activeOperations: orNull(snap?.activeOperations)
|
|
204
220
|
},
|
|
@@ -268,14 +284,13 @@ function registerResources(server) {
|
|
|
268
284
|
// src/tools/account.ts
|
|
269
285
|
import { z } from "zod";
|
|
270
286
|
function registerAccountTools(server) {
|
|
271
|
-
defineTool(server, "account_whoami", "Show the
|
|
287
|
+
defineTool(server, "account_whoami", "Show the archive account email at api.secondlayer.tools, not the self-host instance.", {}, async () => {
|
|
272
288
|
const result = await apiRequest("GET", "/api/accounts/me");
|
|
273
289
|
return jsonResponse(result);
|
|
274
290
|
});
|
|
275
|
-
defineTool(server, "account_create_key", "Mint
|
|
276
|
-
product: z.enum(["streams", "index"]).optional().describe("Key scope (default streams)"),
|
|
291
|
+
defineTool(server, "account_create_key", "Mint an account key (sk-sl_*) for archive credits, quote, and fetch at api.secondlayer.tools. The returned `key` is shown ONCE.", {
|
|
277
292
|
name: z.string().optional().describe("Optional label for the key")
|
|
278
|
-
}, async ({
|
|
293
|
+
}, async ({ name }) => jsonResponse(await apiRequest("POST", "/api/keys", { name })));
|
|
279
294
|
}
|
|
280
295
|
|
|
281
296
|
// src/tools/codegen.ts
|
|
@@ -691,7 +706,10 @@ function createServer() {
|
|
|
691
706
|
registerStreamsTools(server);
|
|
692
707
|
registerContractTools(server);
|
|
693
708
|
registerCodegenTools(server);
|
|
694
|
-
|
|
709
|
+
const baseUrl = process.env.SECONDLAYER_API_URL || process.env.SL_API_URL || "http://127.0.0.1:3800";
|
|
710
|
+
if (isHostedArchiveUrl(baseUrl)) {
|
|
711
|
+
registerAccountTools(server);
|
|
712
|
+
}
|
|
695
713
|
registerResources(server);
|
|
696
714
|
return server;
|
|
697
715
|
}
|
|
@@ -701,5 +719,5 @@ var server = createServer();
|
|
|
701
719
|
var transport = new StdioServerTransport;
|
|
702
720
|
await server.connect(transport);
|
|
703
721
|
|
|
704
|
-
//# debugId=
|
|
722
|
+
//# debugId=A32A9DB8FD9D2A0F64756E2164756E21
|
|
705
723
|
//# sourceMappingURL=bin.js.map
|