@secondlayer/mcp 7.5.0 → 8.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/dist/index.js CHANGED
@@ -183,7 +183,6 @@ var PRODUCT_BLURBS = {
183
183
  contracts: "trait-based contract discovery and ABIs",
184
184
  subgraphs: "author/scaffold/deploy/query custom indexes",
185
185
  webhooks: "a signed POST to a URL you run, on subgraph rows or raw chain events",
186
- subscriptions: "a signed POST to a URL you run, on subgraph rows or raw chain events",
187
186
  account: "identity and self-provisioned API keys",
188
187
  codegen: "ORM schemas for the tables you read",
189
188
  instance: "decoder health and empty-index diagnosis",
@@ -197,7 +196,6 @@ var PRODUCT_ORDER = [
197
196
  "contracts",
198
197
  "subgraphs",
199
198
  "webhooks",
200
- "subscriptions",
201
199
  "account",
202
200
  "codegen",
203
201
  "instance",
@@ -254,7 +252,6 @@ async function buildContext(deps = { clientProvider: getClient }) {
254
252
  indexTip: orNull(snap?.indexTip),
255
253
  subgraphs: snap?.subgraphs.value ? snap.subgraphs.value.map(formatSubgraphSummary) : orNull(snap?.subgraphs),
256
254
  webhooks: orNull(snap?.webhooks),
257
- subscriptions: orNull(snap?.webhooks),
258
255
  activeOperations: orNull(snap?.activeOperations),
259
256
  instance: instance2
260
257
  },
@@ -802,40 +799,9 @@ function registerSetupTools(server, exec = execSecondlayer) {
802
799
  }
803
800
 
804
801
  // src/tools/streams.ts
805
- import { STREAMS_EVENT_TYPES } from "@secondlayer/shared";
806
- import { z as z8 } from "zod";
807
- var filterValue = z8.union([z8.string(), z8.array(z8.string())]);
808
802
  function registerStreamsTools(server, clientProvider = getClient) {
809
803
  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()));
810
- 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.", {
811
- 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"),
812
- fromHeight: z8.number().int().nonnegative().optional().describe("Start block height (inclusive)"),
813
- toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive)"),
814
- types: z8.array(z8.enum(STREAMS_EVENT_TYPES)).optional().describe("Event types to include"),
815
- notTypes: z8.array(z8.enum(STREAMS_EVENT_TYPES)).optional().describe("Event types to exclude (applied after types)"),
816
- contractId: filterValue.optional().describe("Contract id, or a list of contract ids to OR together"),
817
- sender: filterValue.optional().describe("Sender principal, or a list to OR together"),
818
- recipient: filterValue.optional().describe("Recipient principal, or a list to OR together"),
819
- assetIdentifier: z8.string().optional().describe("Asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token"),
820
- limit: z8.number().int().min(1).max(1000).optional().describe("Page size, 1–1000 (default 100)")
821
- }, async (params) => jsonResponse(await clientProvider().streams.events.list(params)));
822
- 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.", {
823
- txId: z8.string().describe("Transaction id (0x-prefixed)")
824
- }, async ({ txId }) => jsonResponse(await clientProvider().streams.events.byTxId(txId)));
825
- 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.", {
826
- heightOrHash: z8.union([z8.number().int().nonnegative(), z8.string()]).describe("Block height (number) or block hash (0x-prefixed string)")
827
- }, async ({ heightOrHash }) => jsonResponse(await clientProvider().streams.blocks.events(heightOrHash)));
828
- 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.", {
829
- height: z8.number().int().nonnegative().describe("Block height")
830
- }, async ({ height }) => jsonResponse(await clientProvider().streams.canonical(height)));
831
- 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.", {
832
- since: z8.string().describe("Required. ISO 8601 timestamp, or a `next_since` resume token from a prior response"),
833
- limit: z8.number().int().positive().optional().describe("Max reorgs to return")
834
- }, async ({ since, limit }) => jsonResponse(await clientProvider().streams.reorgs.list({
835
- since,
836
- ...limit !== undefined ? { limit } : {}
837
- })));
838
- 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()));
804
+ 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()));
839
805
  }
840
806
 
841
807
  // src/tools/subgraphs.ts
@@ -848,7 +814,7 @@ import { DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2 } from "@secondlayer/shared
848
814
  import {
849
815
  runSubgraphTest
850
816
  } from "@secondlayer/subgraphs/testing";
851
- import { z as z9 } from "zod";
817
+ import { z as z8 } from "zod";
852
818
  function eventTypeFor(filter) {
853
819
  if (filter.type === "contract_deploy")
854
820
  return null;
@@ -874,13 +840,13 @@ function registerSubgraphTools(server, clientProvider = getClient) {
874
840
  const { data } = await clientProvider().subgraphs.list();
875
841
  return jsonResponse(data.map(formatSubgraphSummary));
876
842
  });
877
- 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 }) => {
843
+ 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 }) => {
878
844
  const detail = await clientProvider().subgraphs.status(name);
879
845
  return jsonResponse(detail);
880
846
  });
881
847
  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.", {
882
- name: z9.string().describe("Subgraph name"),
883
- format: z9.enum(["agent", "openapi", "markdown"]).optional().describe("agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md")
848
+ name: z8.string().describe("Subgraph name"),
849
+ format: z8.enum(["agent", "openapi", "markdown"]).optional().describe("agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md")
884
850
  }, async ({ name, format }) => {
885
851
  const client = clientProvider();
886
852
  if (format === "openapi")
@@ -890,15 +856,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
890
856
  return jsonResponse(await client.subgraphs.schema(name));
891
857
  });
892
858
  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.', {
893
- name: z9.string().describe("Subgraph name"),
894
- table: z9.string().describe("Table name"),
895
- filters: z9.record(z9.string(), z9.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
896
- sort: z9.string().optional().describe("Column to sort by"),
897
- order: z9.enum(["asc", "desc"]).optional().describe("Sort order"),
898
- limit: z9.number().max(200).optional().describe("Max rows (default 50, max 200)"),
899
- offset: z9.number().optional().describe("Offset for pagination"),
900
- fields: z9.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
901
- count: z9.boolean().optional().describe("If true, return row count instead of rows")
859
+ name: z8.string().describe("Subgraph name"),
860
+ table: z8.string().describe("Table name"),
861
+ filters: z8.record(z8.string(), z8.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
862
+ sort: z8.string().optional().describe("Column to sort by"),
863
+ order: z8.enum(["asc", "desc"]).optional().describe("Sort order"),
864
+ limit: z8.number().max(200).optional().describe("Max rows (default 50, max 200)"),
865
+ offset: z8.number().optional().describe("Offset for pagination"),
866
+ fields: z8.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
867
+ count: z8.boolean().optional().describe("If true, return row count instead of rows")
902
868
  }, async ({
903
869
  name,
904
870
  table,
@@ -926,15 +892,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
926
892
  return jsonResponse(result);
927
893
  });
928
894
  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.", {
929
- name: z9.string().describe("Subgraph name")
895
+ name: z8.string().describe("Subgraph name")
930
896
  }, async ({ name }) => {
931
897
  const result = await clientProvider().subgraphs.reindex(name);
932
898
  return jsonResponse(result);
933
899
  });
934
900
  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.", {
935
- name: z9.string().describe("Subgraph name"),
936
- fromBlock: z9.number().int().nonnegative().describe("Start block (inclusive)"),
937
- toBlock: z9.number().int().nonnegative().describe("End block (inclusive)")
901
+ name: z8.string().describe("Subgraph name"),
902
+ fromBlock: z8.number().int().nonnegative().describe("Start block (inclusive)"),
903
+ toBlock: z8.number().int().nonnegative().describe("End block (inclusive)")
938
904
  }, async ({ name, fromBlock, toBlock }) => {
939
905
  const result = await clientProvider().subgraphs.backfill(name, {
940
906
  fromBlock,
@@ -942,15 +908,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
942
908
  });
943
909
  return jsonResponse(result);
944
910
  });
945
- 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 }) => {
911
+ 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 }) => {
946
912
  const result = await clientProvider().subgraphs.stop(name);
947
913
  return jsonResponse(result);
948
914
  });
949
915
  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.", {
950
- name: z9.string().describe("Subgraph name"),
951
- limit: z9.number().int().positive().optional().describe("Max gaps to return"),
952
- offset: z9.number().int().nonnegative().optional().describe("Pagination offset"),
953
- resolved: z9.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
916
+ name: z8.string().describe("Subgraph name"),
917
+ limit: z8.number().int().positive().optional().describe("Max gaps to return"),
918
+ offset: z8.number().int().nonnegative().optional().describe("Pagination offset"),
919
+ resolved: z8.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
954
920
  }, async ({ name, limit, offset, resolved }) => {
955
921
  const result = await clientProvider().subgraphs.gaps(name, {
956
922
  limit,
@@ -960,20 +926,20 @@ function registerSubgraphTools(server, clientProvider = getClient) {
960
926
  return jsonResponse(result);
961
927
  });
962
928
  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.", {
963
- name: z9.string().describe("Subgraph name"),
964
- operationId: z9.string().optional().describe("Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history")
929
+ name: z8.string().describe("Subgraph name"),
930
+ operationId: z8.string().optional().describe("Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history")
965
931
  }, async ({ name, operationId }) => {
966
932
  const client = clientProvider();
967
933
  return jsonResponse(operationId ? await client.subgraphs.getOperation(name, operationId) : await client.subgraphs.operations(name));
968
934
  });
969
- defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z9.string().describe("Subgraph name") }, async ({ name }) => {
935
+ defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z8.string().describe("Subgraph name") }, async ({ name }) => {
970
936
  const result = await clientProvider().subgraphs.delete(name);
971
937
  return textResponse(result.message);
972
938
  });
973
939
  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.", {
974
- code: z9.string().describe("TypeScript source code containing a defineSubgraph() call"),
975
- startBlock: z9.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
976
- dryRun: z9.boolean().optional().describe("Validate schema/DDL only — does not run handlers. Use subgraphs_test to prove a mapping writes rows.")
940
+ code: z8.string().describe("TypeScript source code containing a defineSubgraph() call"),
941
+ startBlock: z8.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
942
+ dryRun: z8.boolean().optional().describe("Validate schema/DDL only — does not run handlers. Use subgraphs_test to prove a mapping writes rows.")
977
943
  }, async ({ code, startBlock, dryRun }) => {
978
944
  const bundled = await bundleSubgraphCode(code);
979
945
  const result = await clientProvider().subgraphs.deploy({
@@ -990,10 +956,10 @@ function registerSubgraphTools(server, clientProvider = getClient) {
990
956
  return jsonResponse(result);
991
957
  });
992
958
  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.", {
993
- code: z9.string().describe("TypeScript source containing a defineSubgraph() call"),
994
- fromHeight: z9.number().int().nonnegative().describe("Start block height (inclusive)"),
995
- toHeight: z9.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
996
- limit: z9.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
959
+ code: z8.string().describe("TypeScript source containing a defineSubgraph() call"),
960
+ fromHeight: z8.number().int().nonnegative().describe("Start block height (inclusive)"),
961
+ toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
962
+ limit: z8.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
997
963
  }, async ({ code, fromHeight, toHeight, limit }) => {
998
964
  const bundled = await bundleSubgraphCode(code);
999
965
  const def = await loadBundledDefinition(bundled.handlerCode);
@@ -1074,38 +1040,38 @@ function registerSubgraphTools(server, clientProvider = getClient) {
1074
1040
 
1075
1041
  // src/tools/webhooks.ts
1076
1042
  import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
1077
- import { z as z10 } from "zod";
1043
+ import { z as z9 } from "zod";
1078
1044
  function registerWebhookTools(server, clientProvider = getClient) {
1079
1045
  defineTool(server, "webhooks_list", "List all webhooks for the current account. Returns summary fields (no secrets).", {}, async () => {
1080
1046
  const { data } = await clientProvider().webhooks.list();
1081
1047
  return jsonResponse(data);
1082
1048
  });
1083
- defineTool(server, "webhooks_get", "Get full detail for a webhook (filter, auth, retry config, circuit state).", { id: z10.string().describe("Webhook id") }, async ({ id }) => {
1049
+ defineTool(server, "webhooks_get", "Get full detail for a webhook (filter, auth, retry config, circuit state).", { id: z9.string().describe("Webhook id") }, async ({ id }) => {
1084
1050
  const detail = await clientProvider().webhooks.get(id);
1085
1051
  return jsonResponse(detail);
1086
1052
  });
1087
1053
  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.", {
1088
- name: z10.string().describe("Human-readable name, unique per account"),
1089
- subgraphName: z10.string().optional().describe("Subgraph to subscribe to (subgraph webhook)"),
1090
- tableName: z10.string().optional().describe("Table within the subgraph (subgraph webhook)"),
1091
- triggers: z10.array(z10.object({
1092
- type: z10.enum(CHAIN_TRIGGER_TYPES),
1093
- contractId: z10.string().optional(),
1094
- functionName: z10.string().optional(),
1095
- caller: z10.string().optional(),
1096
- sender: z10.string().optional(),
1097
- recipient: z10.string().optional(),
1098
- assetIdentifier: z10.string().optional(),
1099
- deployer: z10.string().optional(),
1100
- contractName: z10.string().optional(),
1101
- topic: z10.string().optional(),
1102
- lockedAddress: z10.string().optional(),
1103
- trait: z10.string().optional(),
1104
- minAmount: z10.union([z10.string(), z10.number()]).optional(),
1105
- maxAmount: z10.union([z10.string(), z10.number()]).optional()
1054
+ name: z9.string().describe("Human-readable name, unique per account"),
1055
+ subgraphName: z9.string().optional().describe("Subgraph to subscribe to (subgraph webhook)"),
1056
+ tableName: z9.string().optional().describe("Table within the subgraph (subgraph webhook)"),
1057
+ triggers: z9.array(z9.object({
1058
+ type: z9.enum(CHAIN_TRIGGER_TYPES),
1059
+ contractId: z9.string().optional(),
1060
+ functionName: z9.string().optional(),
1061
+ caller: z9.string().optional(),
1062
+ sender: z9.string().optional(),
1063
+ recipient: z9.string().optional(),
1064
+ assetIdentifier: z9.string().optional(),
1065
+ deployer: z9.string().optional(),
1066
+ contractName: z9.string().optional(),
1067
+ topic: z9.string().optional(),
1068
+ lockedAddress: z9.string().optional(),
1069
+ trait: z9.string().optional(),
1070
+ minAmount: z9.union([z9.string(), z9.number()]).optional(),
1071
+ maxAmount: z9.union([z9.string(), z9.number()]).optional()
1106
1072
  })).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."),
1107
- url: z10.string().describe("Webhook URL"),
1108
- format: z10.enum([
1073
+ url: z9.string().describe("Webhook URL"),
1074
+ format: z9.enum([
1109
1075
  "standard-webhooks",
1110
1076
  "inngest",
1111
1077
  "trigger",
@@ -1113,20 +1079,20 @@ function registerWebhookTools(server, clientProvider = getClient) {
1113
1079
  "cloudevents",
1114
1080
  "raw"
1115
1081
  ]).optional().describe("Wire format (default standard-webhooks)"),
1116
- runtime: z10.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
1117
- filter: z10.record(z10.string(), z10.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
1118
- authConfig: z10.record(z10.string(), z10.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1082
+ runtime: z9.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
1083
+ filter: z9.record(z9.string(), z9.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
1084
+ authConfig: z9.record(z9.string(), z9.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1119
1085
  }, async (input) => {
1120
1086
  const res = await clientProvider().webhooks.create(input);
1121
1087
  return jsonResponse(res);
1122
1088
  });
1123
1089
  defineTool(server, "webhooks_update", "Patch a webhook (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
1124
- id: z10.string(),
1125
- name: z10.string().optional().describe("Rename the webhook"),
1126
- url: z10.string().optional(),
1127
- filter: z10.record(z10.string(), z10.unknown()).optional(),
1128
- authConfig: z10.record(z10.string(), z10.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1129
- format: z10.enum([
1090
+ id: z9.string(),
1091
+ name: z9.string().optional().describe("Rename the webhook"),
1092
+ url: z9.string().optional(),
1093
+ filter: z9.record(z9.string(), z9.unknown()).optional(),
1094
+ authConfig: z9.record(z9.string(), z9.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1095
+ format: z9.enum([
1130
1096
  "standard-webhooks",
1131
1097
  "inngest",
1132
1098
  "trigger",
@@ -1134,132 +1100,36 @@ function registerWebhookTools(server, clientProvider = getClient) {
1134
1100
  "cloudevents",
1135
1101
  "raw"
1136
1102
  ]).optional(),
1137
- runtime: z10.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
1138
- maxRetries: z10.number().int().min(0).optional(),
1139
- timeoutMs: z10.number().int().min(100).optional(),
1140
- concurrency: z10.number().int().min(1).optional()
1103
+ runtime: z9.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
1104
+ maxRetries: z9.number().int().min(0).optional(),
1105
+ timeoutMs: z9.number().int().min(100).optional(),
1106
+ concurrency: z9.number().int().min(1).optional()
1141
1107
  }, async ({ id, ...patch }) => {
1142
1108
  const res = await clientProvider().webhooks.update(id, patch);
1143
1109
  return jsonResponse(res);
1144
1110
  });
1145
- defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z10.string() }, async ({ id }) => {
1111
+ defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z9.string() }, async ({ id }) => {
1146
1112
  const res = await clientProvider().webhooks.delete(id);
1147
1113
  return jsonResponse(res);
1148
1114
  });
1149
- 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 }) => {
1115
+ 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 }) => {
1150
1116
  const res = await clientProvider().webhooks.test(id);
1151
1117
  return jsonResponse(res);
1152
1118
  });
1153
- 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)));
1154
- 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)));
1155
- 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)));
1156
- 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)));
1157
- 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)));
1119
+ 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)));
1120
+ 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)));
1121
+ 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)));
1122
+ 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)));
1123
+ 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)));
1158
1124
  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.", {
1159
- id: z10.string().describe("Webhook id"),
1160
- outboxId: z10.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1125
+ id: z9.string().describe("Webhook id"),
1126
+ outboxId: z9.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1161
1127
  }, async ({ id, outboxId }) => jsonResponse(await clientProvider().webhooks.requeue(id, outboxId)));
1162
1128
  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.", {
1163
- id: z10.string(),
1164
- fromBlock: z10.number().int().nonnegative(),
1165
- toBlock: z10.number().int().nonnegative(),
1166
- force: z10.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1167
- }, async ({ id, fromBlock, toBlock, force }) => {
1168
- const res = await clientProvider().webhooks.replay(id, {
1169
- fromBlock,
1170
- toBlock,
1171
- ...force !== undefined ? { force } : {}
1172
- });
1173
- return jsonResponse(res);
1174
- });
1175
- defineTool(server, "subscriptions_list", "Deprecated alias of webhooks_list. Removed next minor. List all webhooks for the current account. Returns summary fields (no secrets).", {}, async () => {
1176
- const { data } = await clientProvider().webhooks.list();
1177
- return jsonResponse(data);
1178
- });
1179
- defineTool(server, "subscriptions_get", "Deprecated alias of webhooks_get. Removed next minor. Get full detail for a webhook (filter, auth, retry config, circuit state).", { id: z10.string().describe("Webhook id") }, async ({ id }) => {
1180
- const detail = await clientProvider().webhooks.get(id);
1181
- return jsonResponse(detail);
1182
- });
1183
- defineTool(server, "subscriptions_create", "Deprecated alias of webhooks_create. Removed next minor. 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.", {
1184
- name: z10.string().describe("Human-readable name, unique per account"),
1185
- subgraphName: z10.string().optional().describe("Subgraph to subscribe to (subgraph webhook)"),
1186
- tableName: z10.string().optional().describe("Table within the subgraph (subgraph webhook)"),
1187
- triggers: z10.array(z10.object({
1188
- type: z10.enum(CHAIN_TRIGGER_TYPES),
1189
- contractId: z10.string().optional(),
1190
- functionName: z10.string().optional(),
1191
- caller: z10.string().optional(),
1192
- sender: z10.string().optional(),
1193
- recipient: z10.string().optional(),
1194
- assetIdentifier: z10.string().optional(),
1195
- deployer: z10.string().optional(),
1196
- contractName: z10.string().optional(),
1197
- topic: z10.string().optional(),
1198
- lockedAddress: z10.string().optional(),
1199
- trait: z10.string().optional(),
1200
- minAmount: z10.union([z10.string(), z10.number()]).optional(),
1201
- maxAmount: z10.union([z10.string(), z10.number()]).optional()
1202
- })).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."),
1203
- url: z10.string().describe("Webhook URL"),
1204
- format: z10.enum([
1205
- "standard-webhooks",
1206
- "inngest",
1207
- "trigger",
1208
- "cloudflare",
1209
- "cloudevents",
1210
- "raw"
1211
- ]).optional().describe("Wire format (default standard-webhooks)"),
1212
- runtime: z10.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
1213
- filter: z10.record(z10.string(), z10.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
1214
- authConfig: z10.record(z10.string(), z10.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1215
- }, async (input) => {
1216
- const res = await clientProvider().webhooks.create(input);
1217
- return jsonResponse(res);
1218
- });
1219
- defineTool(server, "subscriptions_update", "Deprecated alias of webhooks_update. Removed next minor. Patch a webhook (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
1220
- id: z10.string(),
1221
- name: z10.string().optional().describe("Rename the webhook"),
1222
- url: z10.string().optional(),
1223
- filter: z10.record(z10.string(), z10.unknown()).optional(),
1224
- authConfig: z10.record(z10.string(), z10.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1225
- format: z10.enum([
1226
- "standard-webhooks",
1227
- "inngest",
1228
- "trigger",
1229
- "cloudflare",
1230
- "cloudevents",
1231
- "raw"
1232
- ]).optional(),
1233
- runtime: z10.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
1234
- maxRetries: z10.number().int().min(0).optional(),
1235
- timeoutMs: z10.number().int().min(100).optional(),
1236
- concurrency: z10.number().int().min(1).optional()
1237
- }, async ({ id, ...patch }) => {
1238
- const res = await clientProvider().webhooks.update(id, patch);
1239
- return jsonResponse(res);
1240
- });
1241
- defineTool(server, "subscriptions_delete", "Deprecated alias of webhooks_delete. Removed next minor. Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z10.string() }, async ({ id }) => {
1242
- const res = await clientProvider().webhooks.delete(id);
1243
- return jsonResponse(res);
1244
- });
1245
- defineTool(server, "subscriptions_test", "Deprecated alias of webhooks_test. Removed next minor. 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 }) => {
1246
- const res = await clientProvider().webhooks.test(id);
1247
- return jsonResponse(res);
1248
- });
1249
- defineTool(server, "subscriptions_pause", "Deprecated alias of webhooks_pause. Removed next minor. 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)));
1250
- defineTool(server, "subscriptions_resume", "Deprecated alias of webhooks_resume. Removed next minor. 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)));
1251
- defineTool(server, "subscriptions_rotate_secret", "Deprecated alias of webhooks_rotate_secret. Removed next minor. 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)));
1252
- defineTool(server, "subscriptions_deliveries", "Deprecated alias of webhooks_deliveries. Removed next minor. 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)));
1253
- defineTool(server, "subscriptions_dead", "Deprecated alias of webhooks_dead. Removed next minor. 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)));
1254
- defineTool(server, "subscriptions_requeue", "Deprecated alias of webhooks_requeue. Removed next minor. 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.", {
1255
- id: z10.string().describe("Webhook id"),
1256
- outboxId: z10.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1257
- }, async ({ id, outboxId }) => jsonResponse(await clientProvider().webhooks.requeue(id, outboxId)));
1258
- defineTool(server, "subscriptions_replay", "Deprecated alias of webhooks_replay. Removed next minor. 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.", {
1259
- id: z10.string(),
1260
- fromBlock: z10.number().int().nonnegative(),
1261
- toBlock: z10.number().int().nonnegative(),
1262
- force: z10.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1129
+ id: z9.string(),
1130
+ fromBlock: z9.number().int().nonnegative(),
1131
+ toBlock: z9.number().int().nonnegative(),
1132
+ force: z9.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1263
1133
  }, async ({ id, fromBlock, toBlock, force }) => {
1264
1134
  const res = await clientProvider().webhooks.replay(id, {
1265
1135
  fromBlock,
@@ -1299,5 +1169,5 @@ export {
1299
1169
  createServer
1300
1170
  };
1301
1171
 
1302
- //# debugId=BBE82EA735BFF52764756E2164756E21
1172
+ //# debugId=F5721B841F975CC764756E2164756E21
1303
1173
  //# sourceMappingURL=index.js.map