@secondlayer/mcp 7.5.1 → 8.0.1

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/dist/bin.js CHANGED
@@ -246,7 +246,7 @@ async function buildContext(deps = { clientProvider: getClient }) {
246
246
  return field.error ? `unavailable: ${field.error.message}` : unavailable;
247
247
  };
248
248
  const snap = await deps.clientProvider().context().catch(() => null);
249
- const instance2 = snap?.instance?.value ? snap.instance.value : orNull(snap?.instance);
249
+ const instance = snap?.instance?.value ? snap.instance.value : orNull(snap?.instance);
250
250
  return {
251
251
  authState: {
252
252
  apiKeySet: Boolean(readApiKey())
@@ -258,7 +258,7 @@ async function buildContext(deps = { clientProvider: getClient }) {
258
258
  subgraphs: snap?.subgraphs.value ? snap.subgraphs.value.map(formatSubgraphSummary) : orNull(snap?.subgraphs),
259
259
  webhooks: orNull(snap?.webhooks),
260
260
  activeOperations: orNull(snap?.activeOperations),
261
- instance: instance2
261
+ instance
262
262
  },
263
263
  whatYouCanDo: buildCapabilities(),
264
264
  readAuthTiers: READ_AUTH_TIERS,
@@ -572,13 +572,13 @@ function registerScaffoldTools(server, clientProvider = getClient) {
572
572
  }, async ({ contractId, subgraphName }) => {
573
573
  const printSchema = await clientProvider().index.printSchema(contractId);
574
574
  if (printSchema && printSchema.topics.length > 0) {
575
- const code2 = generatePrintSchemaSubgraph({
575
+ const code = generatePrintSchemaSubgraph({
576
576
  contractId,
577
577
  name: subgraphName,
578
578
  topics: printSchema.topics,
579
579
  sample: printSchema.sample
580
580
  });
581
- return { content: [{ type: "text", text: code2 }] };
581
+ return { content: [{ type: "text", text: code }] };
582
582
  }
583
583
  const { functions, abi } = await fetchAbi(clientProvider, contractId);
584
584
  const token = generateTokenSubgraphFromAbi({
@@ -804,40 +804,9 @@ function registerSetupTools(server, exec = execSecondlayer) {
804
804
  }
805
805
 
806
806
  // src/tools/streams.ts
807
- import { STREAMS_EVENT_TYPES } from "@secondlayer/shared";
808
- import { z as z8 } from "zod";
809
- var filterValue = z8.union([z8.string(), z8.array(z8.string())]);
810
807
  function registerStreamsTools(server, clientProvider = getClient) {
811
808
  defineTool(server, "streams_tip", "Current canonical chain tip as Streams sees it: block height/hash, burn height, finalized_height, lag_seconds, and the oldest seekable height/cursor for this key's retention window. Call it before a cursor walk to know where the stream ends, and after an ingest to check lag.", {}, async () => jsonResponse(await clientProvider().streams.tip()));
812
- defineTool(server, "streams_events", "List raw chain events from Streams — ONE page per call, newest filters applied server-side. Returns { events, next_cursor, tip, reorgs }. To follow the chain live, poll this tool with `cursor` set to the previous response's `next_cursor` (input is exclusive, so no duplicates); there is no open-stream tool because a tool call cannot hold a connection. ALWAYS narrow with types/contractId/sender/recipient — an unfiltered page is the full firehose.", {
813
- cursor: z8.string().optional().describe("Resume strictly after this cursor (`<block_height>:<event_index>`, e.g. 951475:3) — pass a prior response's next_cursor"),
814
- fromHeight: z8.number().int().nonnegative().optional().describe("Start block height (inclusive)"),
815
- toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive)"),
816
- types: z8.array(z8.enum(STREAMS_EVENT_TYPES)).optional().describe("Event types to include"),
817
- notTypes: z8.array(z8.enum(STREAMS_EVENT_TYPES)).optional().describe("Event types to exclude (applied after types)"),
818
- contractId: filterValue.optional().describe("Contract id, or a list of contract ids to OR together"),
819
- sender: filterValue.optional().describe("Sender principal, or a list to OR together"),
820
- recipient: filterValue.optional().describe("Recipient principal, or a list to OR together"),
821
- assetIdentifier: z8.string().optional().describe("Asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token"),
822
- limit: z8.number().int().min(1).max(1000).optional().describe("Page size, 1–1000 (default 100)")
823
- }, async (params) => jsonResponse(await clientProvider().streams.events.list(params)));
824
- defineTool(server, "streams_events_by_tx", "List every event emitted by a single transaction, in emission order. Use it to explain one transaction end to end after finding it in streams_events or the Index.", {
825
- txId: z8.string().describe("Transaction id (0x-prefixed)")
826
- }, async ({ txId }) => jsonResponse(await clientProvider().streams.events.byTxId(txId)));
827
- defineTool(server, "streams_block_events", "List every event in one block, addressed by block height or block hash. Use it to audit a block a consumer flagged, or to diff what a reorg replaced.", {
828
- heightOrHash: z8.union([z8.number().int().nonnegative(), z8.string()]).describe("Block height (number) or block hash (0x-prefixed string)")
829
- }, async ({ heightOrHash }) => jsonResponse(await clientProvider().streams.blocks.events(heightOrHash)));
830
- defineTool(server, "streams_canonical", "Get the canonical block at a height: hash, burn block hash, parent, and whether the height is still canonical. Use it to confirm a height you already consumed was not reorged away before you trust derived state.", {
831
- height: z8.number().int().nonnegative().describe("Block height")
832
- }, async ({ height }) => jsonResponse(await clientProvider().streams.canonical(height)));
833
- defineTool(server, "streams_reorgs", "List reorgs detected since a point in time, newest last, with the new canonical tip for each. Returns { reorgs, next_since } — resume with next_since. Call it when a consumer's derived state disagrees with streams_canonical, or on a schedule to know which heights to reprocess.", {
834
- since: z8.string().describe("Required. ISO 8601 timestamp, or a `next_since` resume token from a prior response"),
835
- limit: z8.number().int().positive().optional().describe("Max reorgs to return")
836
- }, async ({ since, limit }) => jsonResponse(await clientProvider().streams.reorgs.list({
837
- since,
838
- ...limit !== undefined ? { limit } : {}
839
- })));
840
- defineTool(server, "streams_dumps", "List the Streams bulk parquet dumps manifest — coverage range, latest_finalized_cursor, and per-file metadata (block range, row count, size, sha256, signed URL). This is the cold backfill path for downloading all raw data; fetch the file URLs directly (e.g. with DuckDB). Requires the dumps base URL to be configured (SL_STREAMS_DUMPS_URL). For live reads use streams_events (cursor-paginated) and streams_tip.", {}, async () => jsonResponse(await clientProvider().streams.dumps.list()));
809
+ defineTool(server, "streams_dumps", "List the Streams bulk parquet dumps manifest — coverage range, latest_finalized_cursor, and per-file metadata (block range, row count, size, sha256, signed URL). This is the cold backfill path for downloading all raw data; fetch the file URLs directly (e.g. with DuckDB). Requires the dumps base URL to be configured (SL_STREAMS_DUMPS_URL). For live reads use REST GET /v1/streams/events; for tip/lag use streams_tip.", {}, async () => jsonResponse(await clientProvider().streams.dumps.list()));
841
810
  }
842
811
 
843
812
  // src/tools/subgraphs.ts
@@ -850,7 +819,7 @@ import { DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2 } from "@secondlayer/shared
850
819
  import {
851
820
  runSubgraphTest
852
821
  } from "@secondlayer/subgraphs/testing";
853
- import { z as z9 } from "zod";
822
+ import { z as z8 } from "zod";
854
823
  function eventTypeFor(filter) {
855
824
  if (filter.type === "contract_deploy")
856
825
  return null;
@@ -876,13 +845,13 @@ function registerSubgraphTools(server, clientProvider = getClient) {
876
845
  const { data } = await clientProvider().subgraphs.list();
877
846
  return jsonResponse(data.map(formatSubgraphSummary));
878
847
  });
879
- defineTool(server, "subgraphs_status", "Get full details of a subgraph including schema, health (incl. health.emptyMapping when processed events wrote 0 rows), and table columns.", { name: z9.string().describe("Subgraph name") }, async ({ name }) => {
848
+ defineTool(server, "subgraphs_status", "Get full details of a subgraph including schema, health (incl. health.emptyMapping when processed events wrote 0 rows), and table columns.", { name: z8.string().describe("Subgraph name") }, async ({ name }) => {
880
849
  const detail = await clientProvider().subgraphs.status(name);
881
850
  return jsonResponse(detail);
882
851
  });
883
852
  defineTool(server, "subgraphs_spec", "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.", {
884
- name: z9.string().describe("Subgraph name"),
885
- format: z9.enum(["agent", "openapi", "markdown"]).optional().describe("agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md")
853
+ name: z8.string().describe("Subgraph name"),
854
+ format: z8.enum(["agent", "openapi", "markdown"]).optional().describe("agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md")
886
855
  }, async ({ name, format }) => {
887
856
  const client = clientProvider();
888
857
  if (format === "openapi")
@@ -892,15 +861,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
892
861
  return jsonResponse(await client.subgraphs.schema(name));
893
862
  });
894
863
  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>"}. 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.', {
895
- name: z9.string().describe("Subgraph name"),
896
- table: z9.string().describe("Table name"),
897
- filters: z9.record(z9.string(), z9.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
898
- sort: z9.string().optional().describe("Column to sort by"),
899
- order: z9.enum(["asc", "desc"]).optional().describe("Sort order"),
900
- limit: z9.number().max(200).optional().describe("Max rows (default 50, max 200)"),
901
- offset: z9.number().optional().describe("Offset for pagination"),
902
- fields: z9.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
903
- count: z9.boolean().optional().describe("If true, return row count instead of rows")
864
+ name: z8.string().describe("Subgraph name"),
865
+ table: z8.string().describe("Table name"),
866
+ filters: z8.record(z8.string(), z8.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
867
+ sort: z8.string().optional().describe("Column to sort by"),
868
+ order: z8.enum(["asc", "desc"]).optional().describe("Sort order"),
869
+ limit: z8.number().max(200).optional().describe("Max rows (default 50, max 200)"),
870
+ offset: z8.number().optional().describe("Offset for pagination"),
871
+ fields: z8.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
872
+ count: z8.boolean().optional().describe("If true, return row count instead of rows")
904
873
  }, async ({
905
874
  name,
906
875
  table,
@@ -913,8 +882,8 @@ function registerSubgraphTools(server, clientProvider = getClient) {
913
882
  count
914
883
  }) => {
915
884
  if (count) {
916
- const result2 = await clientProvider().subgraphs.queryTableCount(name, table, { filters, sort, order });
917
- return jsonResponse(result2);
885
+ const result = await clientProvider().subgraphs.queryTableCount(name, table, { filters, sort, order });
886
+ return jsonResponse(result);
918
887
  }
919
888
  const rows = await clientProvider().subgraphs.queryTable(name, table, {
920
889
  filters,
@@ -928,15 +897,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
928
897
  return jsonResponse(result);
929
898
  });
930
899
  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_status (health) or the REST operations endpoint to track progress to completion.", {
931
- name: z9.string().describe("Subgraph name")
900
+ name: z8.string().describe("Subgraph name")
932
901
  }, async ({ name }) => {
933
902
  const result = await clientProvider().subgraphs.reindex(name);
934
903
  return jsonResponse(result);
935
904
  });
936
905
  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_status (health) or the REST operations endpoint to track progress.", {
937
- name: z9.string().describe("Subgraph name"),
938
- fromBlock: z9.number().int().nonnegative().describe("Start block (inclusive)"),
939
- toBlock: z9.number().int().nonnegative().describe("End block (inclusive)")
906
+ name: z8.string().describe("Subgraph name"),
907
+ fromBlock: z8.number().int().nonnegative().describe("Start block (inclusive)"),
908
+ toBlock: z8.number().int().nonnegative().describe("End block (inclusive)")
940
909
  }, async ({ name, fromBlock, toBlock }) => {
941
910
  const result = await clientProvider().subgraphs.backfill(name, {
942
911
  fromBlock,
@@ -944,15 +913,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
944
913
  });
945
914
  return jsonResponse(result);
946
915
  });
947
- defineTool(server, "subgraphs_stop", "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.", { name: z9.string().describe("Subgraph name") }, async ({ name }) => {
916
+ defineTool(server, "subgraphs_stop", "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.", { name: z8.string().describe("Subgraph name") }, async ({ name }) => {
948
917
  const result = await clientProvider().subgraphs.stop(name);
949
918
  return jsonResponse(result);
950
919
  });
951
920
  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.", {
952
- name: z9.string().describe("Subgraph name"),
953
- limit: z9.number().int().positive().optional().describe("Max gaps to return"),
954
- offset: z9.number().int().nonnegative().optional().describe("Pagination offset"),
955
- resolved: z9.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
921
+ name: z8.string().describe("Subgraph name"),
922
+ limit: z8.number().int().positive().optional().describe("Max gaps to return"),
923
+ offset: z8.number().int().nonnegative().optional().describe("Pagination offset"),
924
+ resolved: z8.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
956
925
  }, async ({ name, limit, offset, resolved }) => {
957
926
  const result = await clientProvider().subgraphs.gaps(name, {
958
927
  limit,
@@ -962,25 +931,24 @@ function registerSubgraphTools(server, clientProvider = getClient) {
962
931
  return jsonResponse(result);
963
932
  });
964
933
  defineTool(server, "subgraphs_operations", "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.", {
965
- name: z9.string().describe("Subgraph name"),
966
- operationId: z9.string().optional().describe("Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history")
934
+ name: z8.string().describe("Subgraph name"),
935
+ operationId: z8.string().optional().describe("Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history")
967
936
  }, async ({ name, operationId }) => {
968
937
  const client = clientProvider();
969
938
  return jsonResponse(operationId ? await client.subgraphs.getOperation(name, operationId) : await client.subgraphs.operations(name));
970
939
  });
971
- defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z9.string().describe("Subgraph name") }, async ({ name }) => {
940
+ defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z8.string().describe("Subgraph name") }, async ({ name }) => {
972
941
  const result = await clientProvider().subgraphs.delete(name);
973
942
  return textResponse(result.message);
974
943
  });
975
944
  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. dryRun validates schema/DDL only and does not run handlers — call subgraphs_test first and deploy only when it returns ok: true with written >= 1. Call subgraphs_reindex separately if you need a forced reindex.", {
976
- code: z9.string().describe("TypeScript source code containing a defineSubgraph() call"),
977
- startBlock: z9.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
978
- dryRun: z9.boolean().optional().describe("Validate schema/DDL only — does not run handlers. Use subgraphs_test to prove a mapping writes rows.")
945
+ code: z8.string().describe("TypeScript source code containing a defineSubgraph() call"),
946
+ startBlock: z8.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
947
+ dryRun: z8.boolean().optional().describe("Validate schema/DDL only — does not run handlers. Use subgraphs_test to prove a mapping writes rows.")
979
948
  }, async ({ code, startBlock, dryRun }) => {
980
949
  const bundled = await bundleSubgraphCode(code);
981
950
  const result = await clientProvider().subgraphs.deploy({
982
951
  name: bundled.name,
983
- version: bundled.version,
984
952
  description: bundled.description,
985
953
  sources: bundled.sources,
986
954
  schema: bundled.schema,
@@ -992,10 +960,10 @@ function registerSubgraphTools(server, clientProvider = getClient) {
992
960
  return jsonResponse(result);
993
961
  });
994
962
  defineTool(server, "subgraphs_test", "Prove a subgraph mapping writes rows against Index data before deploy. Pass full defineSubgraph() source plus a height range. Returns ok/written/tables; EMPTY_MAPPING means events matched but 0 rows were written — read hint for observed event.data keys and do not invent fields. subgraphs_deploy dryRun is DDL only; do not deploy until ok: true with written >= 1.", {
995
- code: z9.string().describe("TypeScript source containing a defineSubgraph() call"),
996
- fromHeight: z9.number().int().nonnegative().describe("Start block height (inclusive)"),
997
- toHeight: z9.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
998
- limit: z9.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
963
+ code: z8.string().describe("TypeScript source containing a defineSubgraph() call"),
964
+ fromHeight: z8.number().int().nonnegative().describe("Start block height (inclusive)"),
965
+ toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
966
+ limit: z8.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
999
967
  }, async ({ code, fromHeight, toHeight, limit }) => {
1000
968
  const bundled = await bundleSubgraphCode(code);
1001
969
  const def = await loadBundledDefinition(bundled.handlerCode);
@@ -1019,7 +987,7 @@ function registerSubgraphTools(server, clientProvider = getClient) {
1019
987
  for (const [name, filter] of Object.entries(sources)) {
1020
988
  if (filter.type === "contract_call") {
1021
989
  sourcesTested++;
1022
- const envelope2 = await index.contractCalls.list({
990
+ const envelope = await index.contractCalls.list({
1023
991
  ...filter.contractId ? {
1024
992
  contractId: Array.isArray(filter.contractId) ? filter.contractId : filter.contractId
1025
993
  } : {},
@@ -1028,7 +996,7 @@ function registerSubgraphTools(server, clientProvider = getClient) {
1028
996
  toHeight: to,
1029
997
  limit: pageLimit
1030
998
  });
1031
- events[name] = envelope2.contract_calls;
999
+ events[name] = envelope.contract_calls;
1032
1000
  continue;
1033
1001
  }
1034
1002
  const eventType = eventTypeFor(filter);
@@ -1076,38 +1044,38 @@ function registerSubgraphTools(server, clientProvider = getClient) {
1076
1044
 
1077
1045
  // src/tools/webhooks.ts
1078
1046
  import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
1079
- import { z as z10 } from "zod";
1047
+ import { z as z9 } from "zod";
1080
1048
  function registerWebhookTools(server, clientProvider = getClient) {
1081
1049
  defineTool(server, "webhooks_list", "List all webhooks for the current account. Returns summary fields (no secrets).", {}, async () => {
1082
1050
  const { data } = await clientProvider().webhooks.list();
1083
1051
  return jsonResponse(data);
1084
1052
  });
1085
- defineTool(server, "webhooks_get", "Get full detail for a webhook (filter, auth, retry config, circuit state).", { id: z10.string().describe("Webhook id") }, async ({ id }) => {
1053
+ defineTool(server, "webhooks_get", "Get full detail for a webhook (filter, auth, retry config, circuit state).", { id: z9.string().describe("Webhook id") }, async ({ id }) => {
1086
1054
  const detail = await clientProvider().webhooks.get(id);
1087
1055
  return jsonResponse(detail);
1088
1056
  });
1089
1057
  defineTool(server, "webhooks_create", "Create a webhook. Two kinds (mutually exclusive): a SUBGRAPH webhook fires on a subgraph table's rows (set subgraphName + tableName + optional filter); a CHAIN webhook 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.", {
1090
- name: z10.string().describe("Human-readable name, unique per account"),
1091
- subgraphName: z10.string().optional().describe("Subgraph to subscribe to (subgraph webhook)"),
1092
- tableName: z10.string().optional().describe("Table within the subgraph (subgraph webhook)"),
1093
- triggers: z10.array(z10.object({
1094
- type: z10.enum(CHAIN_TRIGGER_TYPES),
1095
- contractId: z10.string().optional(),
1096
- functionName: z10.string().optional(),
1097
- caller: z10.string().optional(),
1098
- sender: z10.string().optional(),
1099
- recipient: z10.string().optional(),
1100
- assetIdentifier: z10.string().optional(),
1101
- deployer: z10.string().optional(),
1102
- contractName: z10.string().optional(),
1103
- topic: z10.string().optional(),
1104
- lockedAddress: z10.string().optional(),
1105
- trait: z10.string().optional(),
1106
- minAmount: z10.union([z10.string(), z10.number()]).optional(),
1107
- maxAmount: z10.union([z10.string(), z10.number()]).optional()
1058
+ name: z9.string().describe("Human-readable name, unique per account"),
1059
+ subgraphName: z9.string().optional().describe("Subgraph to subscribe to (subgraph webhook)"),
1060
+ tableName: z9.string().optional().describe("Table within the subgraph (subgraph webhook)"),
1061
+ triggers: z9.array(z9.object({
1062
+ type: z9.enum(CHAIN_TRIGGER_TYPES),
1063
+ contractId: z9.string().optional(),
1064
+ functionName: z9.string().optional(),
1065
+ caller: z9.string().optional(),
1066
+ sender: z9.string().optional(),
1067
+ recipient: z9.string().optional(),
1068
+ assetIdentifier: z9.string().optional(),
1069
+ deployer: z9.string().optional(),
1070
+ contractName: z9.string().optional(),
1071
+ topic: z9.string().optional(),
1072
+ lockedAddress: z9.string().optional(),
1073
+ trait: z9.string().optional(),
1074
+ minAmount: z9.union([z9.string(), z9.number()]).optional(),
1075
+ maxAmount: z9.union([z9.string(), z9.number()]).optional()
1108
1076
  })).optional().describe("Chain triggers (chain webhook) — 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."),
1109
- url: z10.string().describe("Webhook URL"),
1110
- format: z10.enum([
1077
+ url: z9.string().describe("Webhook URL"),
1078
+ format: z9.enum([
1111
1079
  "standard-webhooks",
1112
1080
  "inngest",
1113
1081
  "trigger",
@@ -1115,20 +1083,20 @@ function registerWebhookTools(server, clientProvider = getClient) {
1115
1083
  "cloudevents",
1116
1084
  "raw"
1117
1085
  ]).optional().describe("Wire format (default standard-webhooks)"),
1118
- runtime: z10.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
1119
- filter: z10.record(z10.string(), z10.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
1120
- authConfig: z10.record(z10.string(), z10.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1086
+ runtime: z9.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
1087
+ filter: z9.record(z9.string(), z9.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
1088
+ authConfig: z9.record(z9.string(), z9.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1121
1089
  }, async (input) => {
1122
1090
  const res = await clientProvider().webhooks.create(input);
1123
1091
  return jsonResponse(res);
1124
1092
  });
1125
1093
  defineTool(server, "webhooks_update", "Patch a webhook (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
1126
- id: z10.string(),
1127
- name: z10.string().optional().describe("Rename the webhook"),
1128
- url: z10.string().optional(),
1129
- filter: z10.record(z10.string(), z10.unknown()).optional(),
1130
- authConfig: z10.record(z10.string(), z10.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1131
- format: z10.enum([
1094
+ id: z9.string(),
1095
+ name: z9.string().optional().describe("Rename the webhook"),
1096
+ url: z9.string().optional(),
1097
+ filter: z9.record(z9.string(), z9.unknown()).optional(),
1098
+ authConfig: z9.record(z9.string(), z9.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1099
+ format: z9.enum([
1132
1100
  "standard-webhooks",
1133
1101
  "inngest",
1134
1102
  "trigger",
@@ -1136,36 +1104,36 @@ function registerWebhookTools(server, clientProvider = getClient) {
1136
1104
  "cloudevents",
1137
1105
  "raw"
1138
1106
  ]).optional(),
1139
- runtime: z10.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
1140
- maxRetries: z10.number().int().min(0).optional(),
1141
- timeoutMs: z10.number().int().min(100).optional(),
1142
- concurrency: z10.number().int().min(1).optional()
1107
+ runtime: z9.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
1108
+ maxRetries: z9.number().int().min(0).optional(),
1109
+ timeoutMs: z9.number().int().min(100).optional(),
1110
+ concurrency: z9.number().int().min(1).optional()
1143
1111
  }, async ({ id, ...patch }) => {
1144
1112
  const res = await clientProvider().webhooks.update(id, patch);
1145
1113
  return jsonResponse(res);
1146
1114
  });
1147
- defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z10.string() }, async ({ id }) => {
1115
+ defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z9.string() }, async ({ id }) => {
1148
1116
  const res = await clientProvider().webhooks.delete(id);
1149
1117
  return jsonResponse(res);
1150
1118
  });
1151
- defineTool(server, "webhooks_test", "Send a one-off test webhook to a webhook's URL (built for its format, SSRF-guarded). Logged as a delivery row. Returns {ok, statusCode, error, durationMs, deliveryId}.", { id: z10.string().describe("Webhook id") }, async ({ id }) => {
1119
+ defineTool(server, "webhooks_test", "Send a one-off test webhook to a webhook's URL (built for its format, SSRF-guarded). Logged as a delivery row. Returns {ok, statusCode, error, durationMs, deliveryId}.", { id: z9.string().describe("Webhook id") }, async ({ id }) => {
1152
1120
  const res = await clientProvider().webhooks.test(id);
1153
1121
  return jsonResponse(res);
1154
1122
  });
1155
- defineTool(server, "webhooks_pause", "Pause a webhook: stops delivery attempts and stops queueing new ones. Nothing is deleted — resume picks the webhook back up from the tip. Verify with webhooks_get (status).", { id: z10.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.pause(id)));
1156
- defineTool(server, "webhooks_resume", "Resume a paused webhook (also clears a tripped circuit breaker). Deliveries restart from the current tip — use webhooks_replay for the blocks missed while paused. Verify with webhooks_get (status).", { id: z10.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.resume(id)));
1157
- defineTool(server, "webhooks_rotate_secret", "Rotate a webhook's 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.", { id: z10.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.rotateSecret(id)));
1158
- defineTool(server, "webhooks_deliveries", "List recent delivery attempts for a webhook — status code, attempt count, error, duration, timestamps. THIS IS THE VERIFY CALL: after webhooks_create, webhooks_test, or webhooks_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.", { id: z10.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.deliveries(id)));
1159
- defineTool(server, "webhooks_dead", "List a webhook's dead-letter queue — deliveries that exhausted their retries, with the outbox id, payload, and last error. Diagnose the receiver first (webhooks_get for the URL/auth, webhooks_test for a live probe), then requeue rows with webhooks_requeue.", { id: z10.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.dead(id)));
1123
+ defineTool(server, "webhooks_pause", "Pause a webhook: stops delivery attempts and stops queueing new ones. Nothing is deleted — resume picks the webhook back up from the tip. Verify with webhooks_get (status).", { id: z9.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.pause(id)));
1124
+ defineTool(server, "webhooks_resume", "Resume a paused webhook (also clears a tripped circuit breaker). Deliveries restart from the current tip — use webhooks_replay for the blocks missed while paused. Verify with webhooks_get (status).", { id: z9.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.resume(id)));
1125
+ defineTool(server, "webhooks_rotate_secret", "Rotate a webhook's 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.", { id: z9.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.rotateSecret(id)));
1126
+ defineTool(server, "webhooks_deliveries", "List recent delivery attempts for a webhook — status code, attempt count, error, duration, timestamps. THIS IS THE VERIFY CALL: after webhooks_create, webhooks_test, or webhooks_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.", { id: z9.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.deliveries(id)));
1127
+ defineTool(server, "webhooks_dead", "List a webhook's dead-letter queue — deliveries that exhausted their retries, with the outbox id, payload, and last error. Diagnose the receiver first (webhooks_get for the URL/auth, webhooks_test for a live probe), then requeue rows with webhooks_requeue.", { id: z9.string().describe("Webhook id") }, async ({ id }) => jsonResponse(await clientProvider().webhooks.dead(id)));
1160
1128
  defineTool(server, "webhooks_requeue", "Requeue ONE dead-lettered delivery for another attempt, by its outbox id from webhooks_dead. Fix the receiver first — a requeue against a still-broken endpoint just dies again. Verify with webhooks_deliveries.", {
1161
- id: z10.string().describe("Webhook id"),
1162
- outboxId: z10.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1129
+ id: z9.string().describe("Webhook id"),
1130
+ outboxId: z9.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1163
1131
  }, async ({ id, outboxId }) => jsonResponse(await clientProvider().webhooks.requeue(id, outboxId)));
1164
1132
  defineTool(server, "webhooks_replay", "Replay a block range for a webhook. Replays run at 10% of batch capacity — use sparingly. Pass `force` (a short idempotency suffix) to re-run a range that was already replayed.", {
1165
- id: z10.string(),
1166
- fromBlock: z10.number().int().nonnegative(),
1167
- toBlock: z10.number().int().nonnegative(),
1168
- force: z10.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1133
+ id: z9.string(),
1134
+ fromBlock: z9.number().int().nonnegative(),
1135
+ toBlock: z9.number().int().nonnegative(),
1136
+ force: z9.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1169
1137
  }, async ({ id, fromBlock, toBlock, force }) => {
1170
1138
  const res = await clientProvider().webhooks.replay(id, {
1171
1139
  fromBlock,
@@ -1207,5 +1175,5 @@ var server = createServer();
1207
1175
  var transport = new StdioServerTransport;
1208
1176
  await server.connect(transport);
1209
1177
 
1210
- //# debugId=BF3C06F4132ED1AF64756E2164756E21
1178
+ //# debugId=8C3036C6B0121D3464756E2164756E21
1211
1179
  //# sourceMappingURL=bin.js.map