@secondlayer/mcp 4.5.2 → 5.0.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 CHANGED
@@ -63,17 +63,13 @@ bunx -p @secondlayer/mcp secondlayer-mcp-http
63
63
  | **Streams** (1) | `streams_dumps` |
64
64
  | **Contracts** (2) | `contracts_find`, `get_contract_abi` |
65
65
  | **Scaffold** (1) | `scaffold_from_contract` |
66
- | **Account** (2) | `account_whoami`, `account_create_key` |
67
66
 
68
67
  Periphery surfaces (single block/tx lookups, mempool, stacking, proofs, usage,
69
68
  codegen, billing/caps, projects, live Streams reads, delivery forensics) are
70
69
  REST-only: see the OpenAPI spec at the API host.
71
70
 
72
- `account_create_key` mints a scoped `streams`/`index` read key — requires an
73
- account/owner key and returns the `sk-sl_` key **once**. **Key products:** an
74
- `account` key (dashboard default) grants both `streams:read` and `index:read` and
75
- is the only key that can mint; `streams`/`index` keys are scoped reads and cannot
76
- mint (403).
71
+ Account tools are unmounted. Point the server at your instance with `SL_API_URL`
72
+ (default `http://127.0.0.1:3800`). Writes use `INSTANCE_TOKEN` from `secondlayer init`.
77
73
 
78
74
  ### `subscriptions_create` kinds
79
75
 
package/dist/bin-http.js CHANGED
@@ -66,27 +66,6 @@ function getClient() {
66
66
  }
67
67
  return instance;
68
68
  }
69
- var keyHint = " — set SL_API_KEY to an sk-sl_ API key from " + "https://secondlayer.tools/platform/api-keys for write and account operations";
70
- async function apiRequest(method, path, body) {
71
- const apiKey = readApiKey();
72
- const baseUrl = process.env.SECONDLAYER_API_URL || process.env.SL_API_URL || "http://127.0.0.1:3800";
73
- const res = await fetch(`${baseUrl}${path}`, {
74
- method,
75
- headers: {
76
- "Content-Type": "application/json",
77
- ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
78
- },
79
- body: body ? JSON.stringify(body) : undefined
80
- });
81
- if (!res.ok) {
82
- const text = await res.text().catch(() => "");
83
- const needsKey = !apiKey && (res.status === 401 || res.status === 403);
84
- throw Object.assign(new Error((text || `HTTP ${res.status}`) + (needsKey ? keyHint : "")), { status: res.status });
85
- }
86
- if (res.status === 204)
87
- return;
88
- return res.json();
89
- }
90
69
 
91
70
  // src/lib/format.ts
92
71
  function formatSubgraphSummary(s) {
@@ -247,8 +226,6 @@ async function buildContext(deps = { clientProvider: getClient }) {
247
226
  indexTip: orNull(snap?.indexTip),
248
227
  subgraphs: snap?.subgraphs ? snap.subgraphs.map(formatSubgraphSummary) : unavailable,
249
228
  subscriptions: orNull(snap?.subscriptions),
250
- projects: orNull(snap?.projects),
251
- apiKeys: orNull(snap?.apiKeys),
252
229
  activeOperations: orNull(snap?.activeOperations)
253
230
  },
254
231
  whatYouCanDo: buildCapabilities(),
@@ -315,31 +292,18 @@ function registerResources(server) {
315
292
  }));
316
293
  }
317
294
 
318
- // src/tools/account.ts
319
- import { z } from "zod";
320
- function registerAccountTools(server) {
321
- defineTool(server, "account_whoami", "Show the authenticated account's email and plan.", {}, async () => {
322
- const result = await apiRequest("GET", "/api/accounts/me");
323
- return jsonResponse(result);
324
- });
325
- defineTool(server, "account_create_key", "Mint a scoped streams/index read API key so the agent can self-provision access. Requires an account-level (owner) API key. The returned `key` is shown ONCE — forward it to the user to set as SL_API_KEY.", {
326
- product: z.enum(["streams", "index"]).optional().describe("Key scope (default streams)"),
327
- name: z.string().optional().describe("Optional label for the key")
328
- }, async ({ product, name }) => jsonResponse(await getClient().apiKeys.create({ product, name })));
329
- }
330
-
331
295
  // src/tools/codegen.ts
332
296
  import {
333
297
  generateIndexSchema
334
298
  } from "@secondlayer/subgraphs";
335
- import { z as z2 } from "zod";
299
+ import { z } from "zod";
336
300
  var TARGETS = ["prisma", "kysely", "drizzle", "json-schema"];
337
301
  function registerCodegenTools(server) {
338
302
  defineTool(server, "codegen_index_schema", "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.", {
339
- target: z2.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
340
- tables: z2.array(z2.string()).optional().describe("Restrict to these Index tables (default: all)"),
341
- schemaName: z2.string().optional().describe("Postgres schema to qualify table names with"),
342
- datasourceEnv: z2.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
303
+ target: z.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
304
+ tables: z.array(z.string()).optional().describe("Restrict to these Index tables (default: all)"),
305
+ schemaName: z.string().optional().describe("Postgres schema to qualify table names with"),
306
+ datasourceEnv: z.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
343
307
  }, ({ target, tables, schemaName, datasourceEnv }) => textResponse(generateIndexSchema(target ?? "kysely", {
344
308
  tables,
345
309
  schemaName,
@@ -348,17 +312,17 @@ function registerCodegenTools(server) {
348
312
  }
349
313
 
350
314
  // src/tools/contracts.ts
351
- import { z as z3 } from "zod";
315
+ import { z as z2 } from "zod";
352
316
  function registerContractTools(server, clientProvider = getClient) {
353
317
  defineTool(server, "contracts_find", '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.', {
354
- trait: z3.string().describe('Required. Trait to match (e.g. "sip-010").'),
355
- conformance: z3.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
356
- include: z3.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
357
- limit: z3.number().optional().describe("Page size, 1–500 (default 100)"),
358
- cursor: z3.string().optional().describe("Opaque cursor from a prior response's next_cursor")
318
+ trait: z2.string().describe('Required. Trait to match (e.g. "sip-010").'),
319
+ conformance: z2.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
320
+ include: z2.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
321
+ limit: z2.number().optional().describe("Page size, 1–500 (default 100)"),
322
+ cursor: z2.string().optional().describe("Opaque cursor from a prior response's next_cursor")
359
323
  }, async (params) => jsonResponse(await clientProvider().contracts.list(params)));
360
324
  defineTool(server, "contracts_get_abi", "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 scaffold_from_contract.", {
361
- contractId: z3.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
325
+ contractId: z2.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
362
326
  }, async ({ contractId }) => {
363
327
  const contract = await clientProvider().contracts.get(contractId, {
364
328
  includeAbi: true
@@ -375,14 +339,14 @@ function registerContractTools(server, clientProvider = getClient) {
375
339
 
376
340
  // src/tools/index.ts
377
341
  import { DECODED_EVENT_TYPES } from "@secondlayer/shared";
378
- import { z as z4 } from "zod";
342
+ import { z as z3 } from "zod";
379
343
  var INDEX_EVENT_TYPES = DECODED_EVENT_TYPES;
380
344
  var rangeFilters = {
381
- contractId: z4.string().optional().describe("Filter by contract id"),
382
- fromHeight: z4.number().optional().describe("Start block height (inclusive)"),
383
- toHeight: z4.number().optional().describe("End block height (inclusive)"),
384
- cursor: z4.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
385
- limit: z4.number().optional().describe("Max rows for this page")
345
+ contractId: z3.string().optional().describe("Filter by contract id"),
346
+ fromHeight: z3.number().optional().describe("Start block height (inclusive)"),
347
+ toHeight: z3.number().optional().describe("End block height (inclusive)"),
348
+ cursor: z3.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
349
+ limit: z3.number().optional().describe("Max rows for this page")
386
350
  };
387
351
  var heightFilters = {
388
352
  fromHeight: rangeFilters.fromHeight,
@@ -393,52 +357,52 @@ var heightFilters = {
393
357
  function registerIndexTools(server, clientProvider = getClient) {
394
358
  defineTool(server, "index_ft_transfers", "List decoded SIP-010 fungible-token transfers from the Index (decoded layer). Anonymous reads allowed (free-tier API keys are rejected — Build+ required).", {
395
359
  ...rangeFilters,
396
- sender: z4.string().optional().describe("Filter by sender principal"),
397
- recipient: z4.string().optional().describe("Filter by recipient principal"),
398
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
360
+ sender: z3.string().optional().describe("Filter by sender principal"),
361
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
362
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
399
363
  }, async (params) => jsonResponse(await clientProvider().index.ftTransfers.list(params)));
400
364
  defineTool(server, "index_nft_transfers", "List decoded SIP-009 non-fungible-token transfers from the Index. Anonymous reads allowed (free-tier keys rejected).", {
401
365
  ...rangeFilters,
402
- sender: z4.string().optional().describe("Filter by sender principal"),
403
- recipient: z4.string().optional().describe("Filter by recipient principal"),
404
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier (contract::asset)")
366
+ sender: z3.string().optional().describe("Filter by sender principal"),
367
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
368
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier (contract::asset)")
405
369
  }, async (params) => jsonResponse(await clientProvider().index.nftTransfers.list(params)));
406
370
  defineTool(server, "index_events", "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.", {
407
- eventType: z4.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
371
+ eventType: z3.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
408
372
  ...rangeFilters,
409
- sender: z4.string().optional().describe("Filter by sender principal"),
410
- recipient: z4.string().optional().describe("Filter by recipient principal"),
411
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier where applicable"),
412
- trait: z4.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only."),
413
- txContext: z4.boolean().optional().describe("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.")
373
+ sender: z3.string().optional().describe("Filter by sender principal"),
374
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
375
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier where applicable"),
376
+ trait: z3.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only."),
377
+ txContext: z3.boolean().optional().describe("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.")
414
378
  }, async (params) => jsonResponse(await clientProvider().index.events.list(params)));
415
379
  defineTool(server, "index_contract_calls", "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.", {
416
380
  ...rangeFilters,
417
- functionName: z4.string().optional().describe("Filter by called function name"),
418
- sender: z4.string().optional().describe("Filter by caller principal"),
419
- trait: z4.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
381
+ functionName: z3.string().optional().describe("Filter by called function name"),
382
+ sender: z3.string().optional().describe("Filter by caller principal"),
383
+ trait: z3.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
420
384
  }, async (params) => jsonResponse(await clientProvider().index.contractCalls.list(params)));
421
385
  defineTool(server, "index_blocks", "List decoded blocks from the Index. Anonymous reads allowed (free-tier keys rejected).", { ...heightFilters }, async (params) => jsonResponse(await clientProvider().index.blocks.list(params)));
422
386
  defineTool(server, "index_transactions", "List decoded transactions from the Index. Filter by type, sender, or contract. Anonymous reads allowed (free-tier keys rejected).", {
423
387
  ...rangeFilters,
424
- type: z4.string().optional().describe("Filter by transaction type"),
425
- sender: z4.string().optional().describe("Filter by sender principal")
388
+ type: z3.string().optional().describe("Filter by transaction type"),
389
+ sender: z3.string().optional().describe("Filter by sender principal")
426
390
  }, async (params) => jsonResponse(await clientProvider().index.transactions.list(params)));
427
391
  defineTool(server, "index_print_schema", "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.", {
428
- contractId: z4.string().describe("Contract id (SP….name) whose print events to profile")
392
+ contractId: z3.string().describe("Contract id (SP….name) whose print events to profile")
429
393
  }, async (params) => jsonResponse(await clientProvider().index.printSchema(params.contractId)));
430
394
  defineTool(server, "index_discover", "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.", {}, async () => jsonResponse(await clientProvider().index.discover()));
431
395
  defineTool(server, "batch_query", "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.", {
432
- requests: z4.array(z4.object({
433
- path: z4.string().describe("Public /v1 read path"),
434
- params: z4.record(z4.string(), z4.string()).optional()
396
+ requests: z3.array(z3.object({
397
+ path: z3.string().describe("Public /v1 read path"),
398
+ params: z3.record(z3.string(), z3.string()).optional()
435
399
  })).min(1).max(10).describe("Read descriptors, executed concurrently")
436
400
  }, async (params) => jsonResponse(await clientProvider().batch(params.requests)));
437
401
  }
438
402
 
439
403
  // src/tools/scaffold.ts
440
404
  import { generateSubgraphCode } from "@secondlayer/scaffold";
441
- import { z as z5 } from "zod";
405
+ import { z as z4 } from "zod";
442
406
  async function fetchAbi(clientProvider, contractId) {
443
407
  const contract = await clientProvider().contracts.get(contractId, {
444
408
  includeAbi: true
@@ -453,8 +417,8 @@ async function fetchAbi(clientProvider, contractId) {
453
417
  }
454
418
  function registerScaffoldTools(server, clientProvider = getClient) {
455
419
  defineTool(server, "scaffold_from_contract", "Generate a subgraph scaffold from a deployed Stacks contract. Fetches the ABI automatically.", {
456
- contractId: z5.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
457
- subgraphName: z5.string().optional().describe("Override the subgraph name (defaults to contract name)")
420
+ contractId: z4.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
421
+ subgraphName: z4.string().optional().describe("Override the subgraph name (defaults to contract name)")
458
422
  }, async ({ contractId, subgraphName }) => {
459
423
  const { functions } = await fetchAbi(clientProvider, contractId);
460
424
  const code = generateSubgraphCode(contractId, functions, subgraphName);
@@ -469,27 +433,26 @@ function registerStreamsTools(server, clientProvider = getClient) {
469
433
 
470
434
  // src/tools/subgraphs.ts
471
435
  import { bundleSubgraphCode } from "@secondlayer/bundler";
472
- import { ByoBreakingChangeError } from "@secondlayer/sdk";
473
- import { z as z6 } from "zod";
436
+ import { z as z5 } from "zod";
474
437
  function registerSubgraphTools(server, clientProvider = getClient) {
475
438
  defineTool(server, "subgraphs_list", "List all deployed subgraphs. Returns summary fields only, including visibility — public subgraphs are anon-readable at /v1/subgraphs/<name>.", {}, async () => {
476
439
  const { data } = await clientProvider().subgraphs.list();
477
440
  return jsonResponse(data.map(formatSubgraphSummary));
478
441
  });
479
- defineTool(server, "subgraphs_get", "Get full details of a subgraph including schema, health, and table columns.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
442
+ defineTool(server, "subgraphs_get", "Get full details of a subgraph including schema, health, and table columns.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
480
443
  const detail = await clientProvider().subgraphs.get(name);
481
444
  return jsonResponse(detail);
482
445
  });
483
446
  defineTool(server, "subgraphs_query", '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>"}. Public subgraphs are also keyless 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.', {
484
- name: z6.string().describe("Subgraph name"),
485
- table: z6.string().describe("Table name"),
486
- filters: z6.record(z6.string(), z6.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
487
- sort: z6.string().optional().describe("Column to sort by"),
488
- order: z6.enum(["asc", "desc"]).optional().describe("Sort order"),
489
- limit: z6.number().max(200).optional().describe("Max rows (default 50, max 200)"),
490
- offset: z6.number().optional().describe("Offset for pagination"),
491
- fields: z6.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
492
- count: z6.boolean().optional().describe("If true, return row count instead of rows")
447
+ name: z5.string().describe("Subgraph name"),
448
+ table: z5.string().describe("Table name"),
449
+ filters: z5.record(z5.string(), z5.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
450
+ sort: z5.string().optional().describe("Column to sort by"),
451
+ order: z5.enum(["asc", "desc"]).optional().describe("Sort order"),
452
+ limit: z5.number().max(200).optional().describe("Max rows (default 50, max 200)"),
453
+ offset: z5.number().optional().describe("Offset for pagination"),
454
+ fields: z5.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
455
+ count: z5.boolean().optional().describe("If true, return row count instead of rows")
493
456
  }, async ({
494
457
  name,
495
458
  table,
@@ -517,15 +480,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
517
480
  return jsonResponse(result);
518
481
  });
519
482
  defineTool(server, "subgraphs_reindex", "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_get (health) or the REST operations endpoint to track progress to completion.", {
520
- name: z6.string().describe("Subgraph name")
483
+ name: z5.string().describe("Subgraph name")
521
484
  }, async ({ name }) => {
522
485
  const result = await clientProvider().subgraphs.reindex(name);
523
486
  return jsonResponse(result);
524
487
  });
525
488
  defineTool(server, "subgraphs_backfill", "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_get (health) or the REST operations endpoint to track progress.", {
526
- name: z6.string().describe("Subgraph name"),
527
- fromBlock: z6.number().int().nonnegative().describe("Start block (inclusive)"),
528
- toBlock: z6.number().int().nonnegative().describe("End block (inclusive)")
489
+ name: z5.string().describe("Subgraph name"),
490
+ fromBlock: z5.number().int().nonnegative().describe("Start block (inclusive)"),
491
+ toBlock: z5.number().int().nonnegative().describe("End block (inclusive)")
529
492
  }, async ({ name, fromBlock, toBlock }) => {
530
493
  const result = await clientProvider().subgraphs.backfill(name, {
531
494
  fromBlock,
@@ -533,15 +496,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
533
496
  });
534
497
  return jsonResponse(result);
535
498
  });
536
- defineTool(server, "subgraphs_stop", "Cancel an in-flight reindex or backfill operation for a subgraph. Returns the stop request status; check subgraphs_get (health) or the REST operations endpoint to confirm it reaches a terminal state.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
499
+ defineTool(server, "subgraphs_stop", "Cancel an in-flight reindex or backfill operation for a subgraph. Returns the stop request status; check subgraphs_get (health) or the REST operations endpoint to confirm it reaches a terminal state.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
537
500
  const result = await clientProvider().subgraphs.stop(name);
538
501
  return jsonResponse(result);
539
502
  });
540
503
  defineTool(server, "subgraphs_gaps", "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.", {
541
- name: z6.string().describe("Subgraph name"),
542
- limit: z6.number().int().positive().optional().describe("Max gaps to return"),
543
- offset: z6.number().int().nonnegative().optional().describe("Pagination offset"),
544
- resolved: z6.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
504
+ name: z5.string().describe("Subgraph name"),
505
+ limit: z5.number().int().positive().optional().describe("Max gaps to return"),
506
+ offset: z5.number().int().nonnegative().optional().describe("Pagination offset"),
507
+ resolved: z5.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
545
508
  }, async ({ name, limit, offset, resolved }) => {
546
509
  const result = await clientProvider().subgraphs.gaps(name, {
547
510
  limit,
@@ -550,84 +513,65 @@ function registerSubgraphTools(server, clientProvider = getClient) {
550
513
  });
551
514
  return jsonResponse(result);
552
515
  });
553
- defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
516
+ defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
554
517
  const result = await clientProvider().subgraphs.delete(name);
555
518
  return textResponse(result.message);
556
519
  });
557
- defineTool(server, "subgraphs_deploy", "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. Set databaseUrl to deploy to your own Postgres (BYO data plane) — the server verifies the connection first; with dryRun it returns the DDL + grant script. A breaking BYO schema change is refused and returns a migration plan (drop + rebuild DDL) instead of deploying. Visibility defaults: managed deploys are public (anon-readable at /v1/subgraphs/<name>, name claimed in the global public namespace), BYO deploys are private. Call `subgraphs_reindex` separately if you need a forced reindex.", {
558
- code: z6.string().describe("TypeScript source code containing a defineSubgraph() call"),
559
- startBlock: z6.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
560
- databaseUrl: z6.string().optional().describe("BYO data plane: Postgres connection string to host the subgraph's schema and rows in your own database"),
561
- dryRun: z6.boolean().optional().describe("Validate and preview the deploy (schema/DDL, BYO connection) without writing changes"),
562
- visibility: z6.enum(["public", "private"]).optional().describe("Read visibility: public = anon /v1 reads + global name claim; private = owning account's key only. Defaults: managed → public, BYO → private.")
563
- }, async ({ code, startBlock, databaseUrl, dryRun, visibility }) => {
520
+ defineTool(server, "subgraphs_deploy", "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.", {
521
+ code: z5.string().describe("TypeScript source code containing a defineSubgraph() call"),
522
+ startBlock: z5.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
523
+ dryRun: z5.boolean().optional().describe("Validate and preview the deploy (schema/DDL) without writing changes")
524
+ }, async ({ code, startBlock, dryRun }) => {
564
525
  const bundled = await bundleSubgraphCode(code);
565
- try {
566
- const result = await clientProvider().subgraphs.deploy({
567
- name: bundled.name,
568
- version: bundled.version,
569
- description: bundled.description,
570
- sources: bundled.sources,
571
- schema: bundled.schema,
572
- handlerCode: bundled.handlerCode,
573
- sourceCode: code,
574
- ...startBlock !== undefined ? { startBlock } : {},
575
- ...databaseUrl !== undefined ? { databaseUrl } : {},
576
- ...dryRun !== undefined ? { dryRun } : {},
577
- ...visibility !== undefined ? { visibility } : {}
578
- });
579
- return jsonResponse(result);
580
- } catch (err) {
581
- if (err instanceof ByoBreakingChangeError) {
582
- return jsonResponse({ byoBreakingChange: true, ...err.details });
583
- }
584
- throw err;
585
- }
586
- });
587
- defineTool(server, "subgraphs_publish", "Make a subgraph publicly readable at /v1/subgraphs/<name> — anyone (or any agent) can read it without a key. Claims the name in the global public namespace; fails with PUBLIC_NAME_TAKEN if another account holds it.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
588
- const result = await clientProvider().subgraphs.publish(name);
589
- return jsonResponse(result);
590
- });
591
- defineTool(server, "subgraphs_unpublish", "Make a subgraph private again — /v1 reads then require the owning account's bearer key, and the global public name claim is released.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
592
- const result = await clientProvider().subgraphs.unpublish(name);
526
+ const result = await clientProvider().subgraphs.deploy({
527
+ name: bundled.name,
528
+ version: bundled.version,
529
+ description: bundled.description,
530
+ sources: bundled.sources,
531
+ schema: bundled.schema,
532
+ handlerCode: bundled.handlerCode,
533
+ sourceCode: code,
534
+ ...startBlock !== undefined ? { startBlock } : {},
535
+ ...dryRun !== undefined ? { dryRun } : {}
536
+ });
593
537
  return jsonResponse(result);
594
538
  });
595
539
  }
596
540
 
597
541
  // src/tools/subscriptions.ts
598
542
  import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
599
- import { z as z7 } from "zod";
543
+ import { z as z6 } from "zod";
600
544
  function registerSubscriptionTools(server, clientProvider = getClient) {
601
545
  defineTool(server, "subscriptions_list", "List all subscriptions for the current account. Returns summary fields (no secrets).", {}, async () => {
602
546
  const { data } = await clientProvider().subscriptions.list();
603
547
  return jsonResponse(data);
604
548
  });
605
- defineTool(server, "subscriptions_get", "Get full detail for a subscription (filter, auth, retry config, circuit state).", { id: z7.string().describe("Subscription id") }, async ({ id }) => {
549
+ defineTool(server, "subscriptions_get", "Get full detail for a subscription (filter, auth, retry config, circuit state).", { id: z6.string().describe("Subscription id") }, async ({ id }) => {
606
550
  const detail = await clientProvider().subscriptions.get(id);
607
551
  return jsonResponse(detail);
608
552
  });
609
553
  defineTool(server, "subscriptions_create", "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.", {
610
- name: z7.string().describe("Human-readable name, unique per account"),
611
- subgraphName: z7.string().optional().describe("Subgraph to subscribe to (subgraph subscription)"),
612
- tableName: z7.string().optional().describe("Table within the subgraph (subgraph subscription)"),
613
- triggers: z7.array(z7.object({
614
- type: z7.enum(CHAIN_TRIGGER_TYPES),
615
- contractId: z7.string().optional(),
616
- functionName: z7.string().optional(),
617
- caller: z7.string().optional(),
618
- sender: z7.string().optional(),
619
- recipient: z7.string().optional(),
620
- assetIdentifier: z7.string().optional(),
621
- deployer: z7.string().optional(),
622
- contractName: z7.string().optional(),
623
- topic: z7.string().optional(),
624
- lockedAddress: z7.string().optional(),
625
- trait: z7.string().optional(),
626
- minAmount: z7.union([z7.string(), z7.number()]).optional(),
627
- maxAmount: z7.union([z7.string(), z7.number()]).optional()
554
+ name: z6.string().describe("Human-readable name, unique per account"),
555
+ subgraphName: z6.string().optional().describe("Subgraph to subscribe to (subgraph subscription)"),
556
+ tableName: z6.string().optional().describe("Table within the subgraph (subgraph subscription)"),
557
+ triggers: z6.array(z6.object({
558
+ type: z6.enum(CHAIN_TRIGGER_TYPES),
559
+ contractId: z6.string().optional(),
560
+ functionName: z6.string().optional(),
561
+ caller: z6.string().optional(),
562
+ sender: z6.string().optional(),
563
+ recipient: z6.string().optional(),
564
+ assetIdentifier: z6.string().optional(),
565
+ deployer: z6.string().optional(),
566
+ contractName: z6.string().optional(),
567
+ topic: z6.string().optional(),
568
+ lockedAddress: z6.string().optional(),
569
+ trait: z6.string().optional(),
570
+ minAmount: z6.union([z6.string(), z6.number()]).optional(),
571
+ maxAmount: z6.union([z6.string(), z6.number()]).optional()
628
572
  })).optional().describe("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."),
629
- url: z7.string().describe("Webhook URL"),
630
- format: z7.enum([
573
+ url: z6.string().describe("Webhook URL"),
574
+ format: z6.enum([
631
575
  "standard-webhooks",
632
576
  "inngest",
633
577
  "trigger",
@@ -635,20 +579,20 @@ function registerSubscriptionTools(server, clientProvider = getClient) {
635
579
  "cloudevents",
636
580
  "raw"
637
581
  ]).optional().describe("Wire format (default standard-webhooks)"),
638
- runtime: z7.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
639
- filter: z7.record(z7.string(), z7.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
640
- authConfig: z7.record(z7.string(), z7.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
582
+ runtime: z6.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
583
+ filter: z6.record(z6.string(), z6.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
584
+ authConfig: z6.record(z6.string(), z6.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
641
585
  }, async (input) => {
642
586
  const res = await clientProvider().subscriptions.create(input);
643
587
  return jsonResponse(res);
644
588
  });
645
589
  defineTool(server, "subscriptions_update", "Patch a subscription (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
646
- id: z7.string(),
647
- name: z7.string().optional().describe("Rename the subscription"),
648
- url: z7.string().optional(),
649
- filter: z7.record(z7.string(), z7.unknown()).optional(),
650
- authConfig: z7.record(z7.string(), z7.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
651
- format: z7.enum([
590
+ id: z6.string(),
591
+ name: z6.string().optional().describe("Rename the subscription"),
592
+ url: z6.string().optional(),
593
+ filter: z6.record(z6.string(), z6.unknown()).optional(),
594
+ authConfig: z6.record(z6.string(), z6.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
595
+ format: z6.enum([
652
596
  "standard-webhooks",
653
597
  "inngest",
654
598
  "trigger",
@@ -656,27 +600,27 @@ function registerSubscriptionTools(server, clientProvider = getClient) {
656
600
  "cloudevents",
657
601
  "raw"
658
602
  ]).optional(),
659
- runtime: z7.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
660
- maxRetries: z7.number().int().min(0).optional(),
661
- timeoutMs: z7.number().int().min(100).optional(),
662
- concurrency: z7.number().int().min(1).optional()
603
+ runtime: z6.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
604
+ maxRetries: z6.number().int().min(0).optional(),
605
+ timeoutMs: z6.number().int().min(100).optional(),
606
+ concurrency: z6.number().int().min(1).optional()
663
607
  }, async ({ id, ...patch }) => {
664
608
  const res = await clientProvider().subscriptions.update(id, patch);
665
609
  return jsonResponse(res);
666
610
  });
667
- defineTool(server, "subscriptions_delete", "Delete a subscription. Pending outbox rows are cascade-deleted.", { id: z7.string() }, async ({ id }) => {
611
+ defineTool(server, "subscriptions_delete", "Delete a subscription. Pending outbox rows are cascade-deleted.", { id: z6.string() }, async ({ id }) => {
668
612
  const res = await clientProvider().subscriptions.delete(id);
669
613
  return jsonResponse(res);
670
614
  });
671
- defineTool(server, "subscriptions_test", "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}.", { id: z7.string().describe("Subscription id") }, async ({ id }) => {
615
+ defineTool(server, "subscriptions_test", "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}.", { id: z6.string().describe("Subscription id") }, async ({ id }) => {
672
616
  const res = await clientProvider().subscriptions.test(id);
673
617
  return jsonResponse(res);
674
618
  });
675
619
  defineTool(server, "subscriptions_replay", "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.", {
676
- id: z7.string(),
677
- fromBlock: z7.number().int().nonnegative(),
678
- toBlock: z7.number().int().nonnegative(),
679
- force: z7.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
620
+ id: z6.string(),
621
+ fromBlock: z6.number().int().nonnegative(),
622
+ toBlock: z6.number().int().nonnegative(),
623
+ force: z6.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
680
624
  }, async ({ id, fromBlock, toBlock, force }) => {
681
625
  const res = await clientProvider().subscriptions.replay(id, {
682
626
  fromBlock,
@@ -698,7 +642,6 @@ function createServer() {
698
642
  registerScaffoldTools(server);
699
643
  registerSubgraphTools(server);
700
644
  registerSubscriptionTools(server);
701
- registerAccountTools(server);
702
645
  registerIndexTools(server);
703
646
  registerStreamsTools(server);
704
647
  registerContractTools(server);
@@ -793,5 +736,5 @@ httpServer.listen(port, () => {
793
736
  console.error("Warning: SECONDLAYER_MCP_SECRET not set, authentication disabled");
794
737
  });
795
738
 
796
- //# debugId=2D100D9A45CC426C64756E2164756E21
739
+ //# debugId=F581380AB233EEAA64756E2164756E21
797
740
  //# sourceMappingURL=bin-http.js.map