@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/README.md +4 -4
- package/dist/bin-http.js +90 -122
- package/dist/bin-http.js.map +4 -4
- package/dist/bin.js +90 -122
- package/dist/bin.js.map +4 -4
- package/dist/index.js +90 -122
- package/dist/index.js.map +4 -4
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -241,7 +241,7 @@ async function buildContext(deps = { clientProvider: getClient }) {
|
|
|
241
241
|
return field.error ? `unavailable: ${field.error.message}` : unavailable;
|
|
242
242
|
};
|
|
243
243
|
const snap = await deps.clientProvider().context().catch(() => null);
|
|
244
|
-
const
|
|
244
|
+
const instance = snap?.instance?.value ? snap.instance.value : orNull(snap?.instance);
|
|
245
245
|
return {
|
|
246
246
|
authState: {
|
|
247
247
|
apiKeySet: Boolean(readApiKey())
|
|
@@ -253,7 +253,7 @@ async function buildContext(deps = { clientProvider: getClient }) {
|
|
|
253
253
|
subgraphs: snap?.subgraphs.value ? snap.subgraphs.value.map(formatSubgraphSummary) : orNull(snap?.subgraphs),
|
|
254
254
|
webhooks: orNull(snap?.webhooks),
|
|
255
255
|
activeOperations: orNull(snap?.activeOperations),
|
|
256
|
-
instance
|
|
256
|
+
instance
|
|
257
257
|
},
|
|
258
258
|
whatYouCanDo: buildCapabilities(),
|
|
259
259
|
readAuthTiers: READ_AUTH_TIERS,
|
|
@@ -567,13 +567,13 @@ function registerScaffoldTools(server, clientProvider = getClient) {
|
|
|
567
567
|
}, async ({ contractId, subgraphName }) => {
|
|
568
568
|
const printSchema = await clientProvider().index.printSchema(contractId);
|
|
569
569
|
if (printSchema && printSchema.topics.length > 0) {
|
|
570
|
-
const
|
|
570
|
+
const code = generatePrintSchemaSubgraph({
|
|
571
571
|
contractId,
|
|
572
572
|
name: subgraphName,
|
|
573
573
|
topics: printSchema.topics,
|
|
574
574
|
sample: printSchema.sample
|
|
575
575
|
});
|
|
576
|
-
return { content: [{ type: "text", text:
|
|
576
|
+
return { content: [{ type: "text", text: code }] };
|
|
577
577
|
}
|
|
578
578
|
const { functions, abi } = await fetchAbi(clientProvider, contractId);
|
|
579
579
|
const token = generateTokenSubgraphFromAbi({
|
|
@@ -799,40 +799,9 @@ function registerSetupTools(server, exec = execSecondlayer) {
|
|
|
799
799
|
}
|
|
800
800
|
|
|
801
801
|
// src/tools/streams.ts
|
|
802
|
-
import { STREAMS_EVENT_TYPES } from "@secondlayer/shared";
|
|
803
|
-
import { z as z8 } from "zod";
|
|
804
|
-
var filterValue = z8.union([z8.string(), z8.array(z8.string())]);
|
|
805
802
|
function registerStreamsTools(server, clientProvider = getClient) {
|
|
806
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()));
|
|
807
|
-
defineTool(server, "
|
|
808
|
-
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"),
|
|
809
|
-
fromHeight: z8.number().int().nonnegative().optional().describe("Start block height (inclusive)"),
|
|
810
|
-
toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive)"),
|
|
811
|
-
types: z8.array(z8.enum(STREAMS_EVENT_TYPES)).optional().describe("Event types to include"),
|
|
812
|
-
notTypes: z8.array(z8.enum(STREAMS_EVENT_TYPES)).optional().describe("Event types to exclude (applied after types)"),
|
|
813
|
-
contractId: filterValue.optional().describe("Contract id, or a list of contract ids to OR together"),
|
|
814
|
-
sender: filterValue.optional().describe("Sender principal, or a list to OR together"),
|
|
815
|
-
recipient: filterValue.optional().describe("Recipient principal, or a list to OR together"),
|
|
816
|
-
assetIdentifier: z8.string().optional().describe("Asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token"),
|
|
817
|
-
limit: z8.number().int().min(1).max(1000).optional().describe("Page size, 1–1000 (default 100)")
|
|
818
|
-
}, async (params) => jsonResponse(await clientProvider().streams.events.list(params)));
|
|
819
|
-
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.", {
|
|
820
|
-
txId: z8.string().describe("Transaction id (0x-prefixed)")
|
|
821
|
-
}, async ({ txId }) => jsonResponse(await clientProvider().streams.events.byTxId(txId)));
|
|
822
|
-
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.", {
|
|
823
|
-
heightOrHash: z8.union([z8.number().int().nonnegative(), z8.string()]).describe("Block height (number) or block hash (0x-prefixed string)")
|
|
824
|
-
}, async ({ heightOrHash }) => jsonResponse(await clientProvider().streams.blocks.events(heightOrHash)));
|
|
825
|
-
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.", {
|
|
826
|
-
height: z8.number().int().nonnegative().describe("Block height")
|
|
827
|
-
}, async ({ height }) => jsonResponse(await clientProvider().streams.canonical(height)));
|
|
828
|
-
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.", {
|
|
829
|
-
since: z8.string().describe("Required. ISO 8601 timestamp, or a `next_since` resume token from a prior response"),
|
|
830
|
-
limit: z8.number().int().positive().optional().describe("Max reorgs to return")
|
|
831
|
-
}, async ({ since, limit }) => jsonResponse(await clientProvider().streams.reorgs.list({
|
|
832
|
-
since,
|
|
833
|
-
...limit !== undefined ? { limit } : {}
|
|
834
|
-
})));
|
|
835
|
-
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()));
|
|
836
805
|
}
|
|
837
806
|
|
|
838
807
|
// src/tools/subgraphs.ts
|
|
@@ -845,7 +814,7 @@ import { DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2 } from "@secondlayer/shared
|
|
|
845
814
|
import {
|
|
846
815
|
runSubgraphTest
|
|
847
816
|
} from "@secondlayer/subgraphs/testing";
|
|
848
|
-
import { z as
|
|
817
|
+
import { z as z8 } from "zod";
|
|
849
818
|
function eventTypeFor(filter) {
|
|
850
819
|
if (filter.type === "contract_deploy")
|
|
851
820
|
return null;
|
|
@@ -871,13 +840,13 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
871
840
|
const { data } = await clientProvider().subgraphs.list();
|
|
872
841
|
return jsonResponse(data.map(formatSubgraphSummary));
|
|
873
842
|
});
|
|
874
|
-
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:
|
|
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 }) => {
|
|
875
844
|
const detail = await clientProvider().subgraphs.status(name);
|
|
876
845
|
return jsonResponse(detail);
|
|
877
846
|
});
|
|
878
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.", {
|
|
879
|
-
name:
|
|
880
|
-
format:
|
|
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")
|
|
881
850
|
}, async ({ name, format }) => {
|
|
882
851
|
const client = clientProvider();
|
|
883
852
|
if (format === "openapi")
|
|
@@ -887,15 +856,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
887
856
|
return jsonResponse(await client.subgraphs.schema(name));
|
|
888
857
|
});
|
|
889
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.', {
|
|
890
|
-
name:
|
|
891
|
-
table:
|
|
892
|
-
filters:
|
|
893
|
-
sort:
|
|
894
|
-
order:
|
|
895
|
-
limit:
|
|
896
|
-
offset:
|
|
897
|
-
fields:
|
|
898
|
-
count:
|
|
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")
|
|
899
868
|
}, async ({
|
|
900
869
|
name,
|
|
901
870
|
table,
|
|
@@ -908,8 +877,8 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
908
877
|
count
|
|
909
878
|
}) => {
|
|
910
879
|
if (count) {
|
|
911
|
-
const
|
|
912
|
-
return jsonResponse(
|
|
880
|
+
const result = await clientProvider().subgraphs.queryTableCount(name, table, { filters, sort, order });
|
|
881
|
+
return jsonResponse(result);
|
|
913
882
|
}
|
|
914
883
|
const rows = await clientProvider().subgraphs.queryTable(name, table, {
|
|
915
884
|
filters,
|
|
@@ -923,15 +892,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
923
892
|
return jsonResponse(result);
|
|
924
893
|
});
|
|
925
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.", {
|
|
926
|
-
name:
|
|
895
|
+
name: z8.string().describe("Subgraph name")
|
|
927
896
|
}, async ({ name }) => {
|
|
928
897
|
const result = await clientProvider().subgraphs.reindex(name);
|
|
929
898
|
return jsonResponse(result);
|
|
930
899
|
});
|
|
931
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.", {
|
|
932
|
-
name:
|
|
933
|
-
fromBlock:
|
|
934
|
-
toBlock:
|
|
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)")
|
|
935
904
|
}, async ({ name, fromBlock, toBlock }) => {
|
|
936
905
|
const result = await clientProvider().subgraphs.backfill(name, {
|
|
937
906
|
fromBlock,
|
|
@@ -939,15 +908,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
939
908
|
});
|
|
940
909
|
return jsonResponse(result);
|
|
941
910
|
});
|
|
942
|
-
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:
|
|
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 }) => {
|
|
943
912
|
const result = await clientProvider().subgraphs.stop(name);
|
|
944
913
|
return jsonResponse(result);
|
|
945
914
|
});
|
|
946
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.", {
|
|
947
|
-
name:
|
|
948
|
-
limit:
|
|
949
|
-
offset:
|
|
950
|
-
resolved:
|
|
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)")
|
|
951
920
|
}, async ({ name, limit, offset, resolved }) => {
|
|
952
921
|
const result = await clientProvider().subgraphs.gaps(name, {
|
|
953
922
|
limit,
|
|
@@ -957,25 +926,24 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
957
926
|
return jsonResponse(result);
|
|
958
927
|
});
|
|
959
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.", {
|
|
960
|
-
name:
|
|
961
|
-
operationId:
|
|
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")
|
|
962
931
|
}, async ({ name, operationId }) => {
|
|
963
932
|
const client = clientProvider();
|
|
964
933
|
return jsonResponse(operationId ? await client.subgraphs.getOperation(name, operationId) : await client.subgraphs.operations(name));
|
|
965
934
|
});
|
|
966
|
-
defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name:
|
|
935
|
+
defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z8.string().describe("Subgraph name") }, async ({ name }) => {
|
|
967
936
|
const result = await clientProvider().subgraphs.delete(name);
|
|
968
937
|
return textResponse(result.message);
|
|
969
938
|
});
|
|
970
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.", {
|
|
971
|
-
code:
|
|
972
|
-
startBlock:
|
|
973
|
-
dryRun:
|
|
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.")
|
|
974
943
|
}, async ({ code, startBlock, dryRun }) => {
|
|
975
944
|
const bundled = await bundleSubgraphCode(code);
|
|
976
945
|
const result = await clientProvider().subgraphs.deploy({
|
|
977
946
|
name: bundled.name,
|
|
978
|
-
version: bundled.version,
|
|
979
947
|
description: bundled.description,
|
|
980
948
|
sources: bundled.sources,
|
|
981
949
|
schema: bundled.schema,
|
|
@@ -987,10 +955,10 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
987
955
|
return jsonResponse(result);
|
|
988
956
|
});
|
|
989
957
|
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.", {
|
|
990
|
-
code:
|
|
991
|
-
fromHeight:
|
|
992
|
-
toHeight:
|
|
993
|
-
limit:
|
|
958
|
+
code: z8.string().describe("TypeScript source containing a defineSubgraph() call"),
|
|
959
|
+
fromHeight: z8.number().int().nonnegative().describe("Start block height (inclusive)"),
|
|
960
|
+
toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
|
|
961
|
+
limit: z8.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
|
|
994
962
|
}, async ({ code, fromHeight, toHeight, limit }) => {
|
|
995
963
|
const bundled = await bundleSubgraphCode(code);
|
|
996
964
|
const def = await loadBundledDefinition(bundled.handlerCode);
|
|
@@ -1014,7 +982,7 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
1014
982
|
for (const [name, filter] of Object.entries(sources)) {
|
|
1015
983
|
if (filter.type === "contract_call") {
|
|
1016
984
|
sourcesTested++;
|
|
1017
|
-
const
|
|
985
|
+
const envelope = await index.contractCalls.list({
|
|
1018
986
|
...filter.contractId ? {
|
|
1019
987
|
contractId: Array.isArray(filter.contractId) ? filter.contractId : filter.contractId
|
|
1020
988
|
} : {},
|
|
@@ -1023,7 +991,7 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
1023
991
|
toHeight: to,
|
|
1024
992
|
limit: pageLimit
|
|
1025
993
|
});
|
|
1026
|
-
events[name] =
|
|
994
|
+
events[name] = envelope.contract_calls;
|
|
1027
995
|
continue;
|
|
1028
996
|
}
|
|
1029
997
|
const eventType = eventTypeFor(filter);
|
|
@@ -1071,38 +1039,38 @@ function registerSubgraphTools(server, clientProvider = getClient) {
|
|
|
1071
1039
|
|
|
1072
1040
|
// src/tools/webhooks.ts
|
|
1073
1041
|
import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
|
|
1074
|
-
import { z as
|
|
1042
|
+
import { z as z9 } from "zod";
|
|
1075
1043
|
function registerWebhookTools(server, clientProvider = getClient) {
|
|
1076
1044
|
defineTool(server, "webhooks_list", "List all webhooks for the current account. Returns summary fields (no secrets).", {}, async () => {
|
|
1077
1045
|
const { data } = await clientProvider().webhooks.list();
|
|
1078
1046
|
return jsonResponse(data);
|
|
1079
1047
|
});
|
|
1080
|
-
defineTool(server, "webhooks_get", "Get full detail for a webhook (filter, auth, retry config, circuit state).", { id:
|
|
1048
|
+
defineTool(server, "webhooks_get", "Get full detail for a webhook (filter, auth, retry config, circuit state).", { id: z9.string().describe("Webhook id") }, async ({ id }) => {
|
|
1081
1049
|
const detail = await clientProvider().webhooks.get(id);
|
|
1082
1050
|
return jsonResponse(detail);
|
|
1083
1051
|
});
|
|
1084
1052
|
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.", {
|
|
1085
|
-
name:
|
|
1086
|
-
subgraphName:
|
|
1087
|
-
tableName:
|
|
1088
|
-
triggers:
|
|
1089
|
-
type:
|
|
1090
|
-
contractId:
|
|
1091
|
-
functionName:
|
|
1092
|
-
caller:
|
|
1093
|
-
sender:
|
|
1094
|
-
recipient:
|
|
1095
|
-
assetIdentifier:
|
|
1096
|
-
deployer:
|
|
1097
|
-
contractName:
|
|
1098
|
-
topic:
|
|
1099
|
-
lockedAddress:
|
|
1100
|
-
trait:
|
|
1101
|
-
minAmount:
|
|
1102
|
-
maxAmount:
|
|
1053
|
+
name: z9.string().describe("Human-readable name, unique per account"),
|
|
1054
|
+
subgraphName: z9.string().optional().describe("Subgraph to subscribe to (subgraph webhook)"),
|
|
1055
|
+
tableName: z9.string().optional().describe("Table within the subgraph (subgraph webhook)"),
|
|
1056
|
+
triggers: z9.array(z9.object({
|
|
1057
|
+
type: z9.enum(CHAIN_TRIGGER_TYPES),
|
|
1058
|
+
contractId: z9.string().optional(),
|
|
1059
|
+
functionName: z9.string().optional(),
|
|
1060
|
+
caller: z9.string().optional(),
|
|
1061
|
+
sender: z9.string().optional(),
|
|
1062
|
+
recipient: z9.string().optional(),
|
|
1063
|
+
assetIdentifier: z9.string().optional(),
|
|
1064
|
+
deployer: z9.string().optional(),
|
|
1065
|
+
contractName: z9.string().optional(),
|
|
1066
|
+
topic: z9.string().optional(),
|
|
1067
|
+
lockedAddress: z9.string().optional(),
|
|
1068
|
+
trait: z9.string().optional(),
|
|
1069
|
+
minAmount: z9.union([z9.string(), z9.number()]).optional(),
|
|
1070
|
+
maxAmount: z9.union([z9.string(), z9.number()]).optional()
|
|
1103
1071
|
})).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."),
|
|
1104
|
-
url:
|
|
1105
|
-
format:
|
|
1072
|
+
url: z9.string().describe("Webhook URL"),
|
|
1073
|
+
format: z9.enum([
|
|
1106
1074
|
"standard-webhooks",
|
|
1107
1075
|
"inngest",
|
|
1108
1076
|
"trigger",
|
|
@@ -1110,20 +1078,20 @@ function registerWebhookTools(server, clientProvider = getClient) {
|
|
|
1110
1078
|
"cloudevents",
|
|
1111
1079
|
"raw"
|
|
1112
1080
|
]).optional().describe("Wire format (default standard-webhooks)"),
|
|
1113
|
-
runtime:
|
|
1114
|
-
filter:
|
|
1115
|
-
authConfig:
|
|
1081
|
+
runtime: z9.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
|
|
1082
|
+
filter: z9.record(z9.string(), z9.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
|
|
1083
|
+
authConfig: z9.record(z9.string(), z9.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
|
|
1116
1084
|
}, async (input) => {
|
|
1117
1085
|
const res = await clientProvider().webhooks.create(input);
|
|
1118
1086
|
return jsonResponse(res);
|
|
1119
1087
|
});
|
|
1120
1088
|
defineTool(server, "webhooks_update", "Patch a webhook (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
|
|
1121
|
-
id:
|
|
1122
|
-
name:
|
|
1123
|
-
url:
|
|
1124
|
-
filter:
|
|
1125
|
-
authConfig:
|
|
1126
|
-
format:
|
|
1089
|
+
id: z9.string(),
|
|
1090
|
+
name: z9.string().optional().describe("Rename the webhook"),
|
|
1091
|
+
url: z9.string().optional(),
|
|
1092
|
+
filter: z9.record(z9.string(), z9.unknown()).optional(),
|
|
1093
|
+
authConfig: z9.record(z9.string(), z9.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
|
|
1094
|
+
format: z9.enum([
|
|
1127
1095
|
"standard-webhooks",
|
|
1128
1096
|
"inngest",
|
|
1129
1097
|
"trigger",
|
|
@@ -1131,36 +1099,36 @@ function registerWebhookTools(server, clientProvider = getClient) {
|
|
|
1131
1099
|
"cloudevents",
|
|
1132
1100
|
"raw"
|
|
1133
1101
|
]).optional(),
|
|
1134
|
-
runtime:
|
|
1135
|
-
maxRetries:
|
|
1136
|
-
timeoutMs:
|
|
1137
|
-
concurrency:
|
|
1102
|
+
runtime: z9.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
|
|
1103
|
+
maxRetries: z9.number().int().min(0).optional(),
|
|
1104
|
+
timeoutMs: z9.number().int().min(100).optional(),
|
|
1105
|
+
concurrency: z9.number().int().min(1).optional()
|
|
1138
1106
|
}, async ({ id, ...patch }) => {
|
|
1139
1107
|
const res = await clientProvider().webhooks.update(id, patch);
|
|
1140
1108
|
return jsonResponse(res);
|
|
1141
1109
|
});
|
|
1142
|
-
defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id:
|
|
1110
|
+
defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z9.string() }, async ({ id }) => {
|
|
1143
1111
|
const res = await clientProvider().webhooks.delete(id);
|
|
1144
1112
|
return jsonResponse(res);
|
|
1145
1113
|
});
|
|
1146
|
-
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:
|
|
1114
|
+
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 }) => {
|
|
1147
1115
|
const res = await clientProvider().webhooks.test(id);
|
|
1148
1116
|
return jsonResponse(res);
|
|
1149
1117
|
});
|
|
1150
|
-
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:
|
|
1151
|
-
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:
|
|
1152
|
-
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:
|
|
1153
|
-
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:
|
|
1154
|
-
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:
|
|
1118
|
+
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)));
|
|
1119
|
+
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)));
|
|
1120
|
+
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)));
|
|
1121
|
+
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)));
|
|
1122
|
+
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)));
|
|
1155
1123
|
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.", {
|
|
1156
|
-
id:
|
|
1157
|
-
outboxId:
|
|
1124
|
+
id: z9.string().describe("Webhook id"),
|
|
1125
|
+
outboxId: z9.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
|
|
1158
1126
|
}, async ({ id, outboxId }) => jsonResponse(await clientProvider().webhooks.requeue(id, outboxId)));
|
|
1159
1127
|
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.", {
|
|
1160
|
-
id:
|
|
1161
|
-
fromBlock:
|
|
1162
|
-
toBlock:
|
|
1163
|
-
force:
|
|
1128
|
+
id: z9.string(),
|
|
1129
|
+
fromBlock: z9.number().int().nonnegative(),
|
|
1130
|
+
toBlock: z9.number().int().nonnegative(),
|
|
1131
|
+
force: z9.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
|
|
1164
1132
|
}, async ({ id, fromBlock, toBlock, force }) => {
|
|
1165
1133
|
const res = await clientProvider().webhooks.replay(id, {
|
|
1166
1134
|
fromBlock,
|
|
@@ -1200,5 +1168,5 @@ export {
|
|
|
1200
1168
|
createServer
|
|
1201
1169
|
};
|
|
1202
1170
|
|
|
1203
|
-
//# debugId=
|
|
1171
|
+
//# debugId=CEFB75160283ACFC64756E2164756E21
|
|
1204
1172
|
//# sourceMappingURL=index.js.map
|