@secondlayer/mcp 11.4.0 → 11.5.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/bin.js CHANGED
@@ -21,6 +21,7 @@ function isHostedArchiveUrl(url) {
21
21
  }
22
22
 
23
23
  // src/lib/tool.ts
24
+ import { z } from "zod";
24
25
  var registeredToolNames = new Set;
25
26
  var serverToolNames = new WeakMap;
26
27
  var serverToolFilters = new WeakMap;
@@ -74,7 +75,10 @@ function defineTool(server, name, description, schema, handler) {
74
75
  const names = serverToolNames.get(server) ?? new Set;
75
76
  names.add(name);
76
77
  serverToolNames.set(server, names);
77
- server.tool(name, description, schema, wrappedHandler);
78
+ const registered = server.tool(name, description, schema, wrappedHandler);
79
+ if (registered) {
80
+ registered.inputSchema = z.strictObject(schema);
81
+ }
78
82
  }
79
83
 
80
84
  // src/resources.ts
@@ -454,21 +458,21 @@ async function buildSamplesResource(contractId, clientProvider = getClient) {
454
458
  }
455
459
 
456
460
  // src/tools/account.ts
457
- import { z } from "zod";
461
+ import { z as z2 } from "zod";
458
462
  function registerAccountTools(server, request = apiRequest, currentKey = readApiKey) {
459
463
  defineTool(server, "account_whoami", "Show the archive account email at api.secondlayer.tools, not the self-host instance.", {}, async () => {
460
464
  const result = await request("GET", "/api/accounts/me");
461
465
  return jsonResponse(result);
462
466
  });
463
467
  defineTool(server, "account_create_key", "Mint an account key (sk-sl_*) for archive credits, quote, and fetch at api.secondlayer.tools. The returned `key` is shown ONCE.", {
464
- name: z.string().optional().describe("Optional label for the key")
468
+ name: z2.string().optional().describe("Optional label for the key")
465
469
  }, async ({ name }) => jsonResponse(await request("POST", "/api/keys", { name })));
466
470
  defineTool(server, "account_list_keys", "List this account's active account keys at api.secondlayer.tools: id, prefix, name, last read. Never returns a secret. Use an id with account_rotate_key.", {}, async () => {
467
471
  const keys = await activeAccountKeys(request);
468
472
  return jsonResponse({ keys });
469
473
  });
470
474
  defineTool(server, "account_rotate_key", "Replace an account key's secret at api.secondlayer.tools, keeping its name. The old secret gets 401 at once, with no grace period, so everything using it breaks until updated: get human confirmation first. The returned key is shown ONCE. Refuses the key this server runs on.", {
471
- id: z.string().uuid().describe("Key id from account_list_keys")
475
+ id: z2.string().uuid().describe("Key id from account_list_keys")
472
476
  }, async ({ id }) => {
473
477
  const { keys } = await request("GET", "/api/keys");
474
478
  const row = keys.find((k) => k.id === id);
@@ -484,7 +488,7 @@ async function activeAccountKeys(request) {
484
488
  }
485
489
 
486
490
  // src/tools/archive-cli.ts
487
- import { z as z2 } from "zod";
491
+ import { z as z3 } from "zod";
488
492
 
489
493
  // src/lib/exec-cli.ts
490
494
  import {
@@ -628,9 +632,9 @@ function cliResponse(result) {
628
632
  }
629
633
  function registerArchiveCliTools(server, exec = execSecondlayer) {
630
634
  defineTool(server, "archive_bootstrap", "Restore verified history into this instance (secondlayer bootstrap --against … --yes --json). Metered against the official archive; quote happens inside the CLI. After bootstrap, poll instance_status until decoders ok, then archive_verify, then codegen_index_schema. Do not download parquet.", {
631
- against: z2.string().describe("Archive manifest URL"),
632
- fromBlock: z2.number().int().nonnegative().optional().describe("Restore from this height instead of genesis"),
633
- toBlock: z2.number().int().nonnegative().optional().describe("Stop at this height instead of the archive tip")
635
+ against: z3.string().describe("Archive manifest URL"),
636
+ fromBlock: z3.number().int().nonnegative().optional().describe("Restore from this height instead of genesis"),
637
+ toBlock: z3.number().int().nonnegative().optional().describe("Stop at this height instead of the archive tip")
634
638
  }, async ({ against, fromBlock, toBlock }) => {
635
639
  const args = ["--against", against, "--yes", "--json"];
636
640
  if (fromBlock !== undefined)
@@ -640,10 +644,10 @@ function registerArchiveCliTools(server, exec = execSecondlayer) {
640
644
  return cliResponse(await exec("bootstrap", args));
641
645
  });
642
646
  defineTool(server, "archive_repair", "Plan (default) or apply a repair of local chain data against a signed archive. Metered when apply fetches from the official archive. After apply, poll instance_status until decoders ok, then archive_verify. Do not download parquet.", {
643
- against: z2.string().describe("Archive manifest URL"),
644
- apply: z2.boolean().optional().describe("Write the repair (default plan-only)"),
645
- fromBlock: z2.number().int().nonnegative().optional().describe("First height to consider"),
646
- toBlock: z2.number().int().nonnegative().optional().describe("Last height to consider")
647
+ against: z3.string().describe("Archive manifest URL"),
648
+ apply: z3.boolean().optional().describe("Write the repair (default plan-only)"),
649
+ fromBlock: z3.number().int().nonnegative().optional().describe("First height to consider"),
650
+ toBlock: z3.number().int().nonnegative().optional().describe("Last height to consider")
647
651
  }, async ({ against, apply, fromBlock, toBlock }) => {
648
652
  const args = ["--against", against, "--json"];
649
653
  if (apply)
@@ -657,14 +661,14 @@ function registerArchiveCliTools(server, exec = execSecondlayer) {
657
661
  }
658
662
 
659
663
  // src/tools/archive.ts
660
- import { z as z3 } from "zod";
664
+ import { z as z4 } from "zod";
661
665
  var FLOW = ["bootstrap", "repair"];
662
666
  function registerArchiveTools(server, clientProvider = getClient, archiveOpsClientProvider = getArchiveOpsClient) {
663
667
  defineTool(server, "archive_verify", "Read-only, free compare of this instance against a signed archive (POST /v1/archive/verify). unanchored means pin a key or check the URL — not that the instance is fine. After bootstrap, poll instance_status until decoders ok, then this, then codegen_index_schema. Do not download parquet.", {
664
- against: z3.string().describe("Archive manifest URL"),
665
- fromBlock: z3.number().int().nonnegative().optional().describe("First height (inclusive)"),
666
- toBlock: z3.number().int().nonnegative().optional().describe("Last height (inclusive)"),
667
- target: z3.string().optional().describe("Verify target (default raw)")
668
+ against: z4.string().describe("Archive manifest URL"),
669
+ fromBlock: z4.number().int().nonnegative().optional().describe("First height (inclusive)"),
670
+ toBlock: z4.number().int().nonnegative().optional().describe("Last height (inclusive)"),
671
+ target: z4.string().optional().describe("Verify target (default raw)")
668
672
  }, async ({ against, fromBlock, toBlock, target }) => jsonResponse(await clientProvider().archive.verify({
669
673
  against,
670
674
  fromBlock,
@@ -672,11 +676,11 @@ function registerArchiveTools(server, clientProvider = getClient, archiveOpsClie
672
676
  target
673
677
  })));
674
678
  defineTool(server, "archive_latest", "Signed pointer to the official archive tree (hosted). Needs SECONDLAYER_API_KEY (sk-sl_*), not INSTANCE_TOKEN. Use the returned origin as --against for archive_bootstrap. Do not download parquet.", {
675
- against: z3.string().optional().describe("Override latest.json URL (default official tree)")
679
+ against: z4.string().optional().describe("Override latest.json URL (default official tree)")
676
680
  }, async ({ against }) => jsonResponse(await archiveOpsClientProvider().archive.latest(against)));
677
681
  defineTool(server, "archive_quote", "Price a hosted archive fetch (metered). Needs SECONDLAYER_API_KEY (sk-sl_*), not INSTANCE_TOKEN. Quote happens here; bootstrap/repair also quote inside the CLI. Do not download parquet.", {
678
- paths: z3.array(z3.string()).describe("Partition paths to price"),
679
- flow: z3.enum(FLOW).describe("bootstrap or repair")
682
+ paths: z4.array(z4.string()).describe("Partition paths to price"),
683
+ flow: z4.enum(FLOW).describe("bootstrap or repair")
680
684
  }, async ({ paths, flow }) => jsonResponse(await archiveOpsClientProvider().archive.quote({ paths, flow })));
681
685
  defineTool(server, "credits_balance", "Archive credits balance at api.secondlayer.tools. Needs SECONDLAYER_API_KEY (sk-sl_*); INSTANCE_TOKEN is the instance.", {}, async () => jsonResponse(await archiveOpsClientProvider().archive.credits.balance()));
682
686
  }
@@ -685,14 +689,14 @@ function registerArchiveTools(server, clientProvider = getClient, archiveOpsClie
685
689
  import {
686
690
  generateIndexSchema
687
691
  } from "@secondlayer/subgraphs";
688
- import { z as z4 } from "zod";
692
+ import { z as z5 } from "zod";
689
693
  var TARGETS = ["prisma", "kysely", "drizzle", "json-schema"];
690
694
  function registerCodegenTools(server) {
691
695
  defineTool(server, "codegen_index_schema", "Generate an ORM schema for the Index tables (blocks, transactions, decoded_events, …) — the same output as `sl codegen index`. Returns the file contents as text; write it wherever your project keeps its schema. Use `tables` to emit only what you read.", {
692
- target: z4.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
693
- tables: z4.array(z4.string()).optional().describe("Restrict to these Index tables (default: all)"),
694
- schemaName: z4.string().optional().describe("Postgres schema to qualify table names with"),
695
- datasourceEnv: z4.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
696
+ target: z5.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
697
+ tables: z5.array(z5.string()).optional().describe("Restrict to these Index tables (default: all)"),
698
+ schemaName: z5.string().optional().describe("Postgres schema to qualify table names with"),
699
+ datasourceEnv: z5.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
696
700
  }, ({ target, tables, schemaName, datasourceEnv }) => textResponse(generateIndexSchema(target ?? "kysely", {
697
701
  tables,
698
702
  schemaName,
@@ -701,17 +705,17 @@ function registerCodegenTools(server) {
701
705
  }
702
706
 
703
707
  // src/tools/contracts.ts
704
- import { z as z5 } from "zod";
708
+ import { z as z6 } from "zod";
705
709
  function registerContractTools(server, clientProvider = getClient) {
706
710
  defineTool(server, "contracts_find", 'Discover deployed Stacks contracts conforming to a trait (e.g. "sip-010", "sip-009", "sip-013"). The discovery endpoint for "which contracts implement X". Reads are public.', {
707
- trait: z5.string().describe('Required. Trait to match (e.g. "sip-010").'),
708
- conformance: z5.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
709
- include: z5.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
710
- limit: z5.number().optional().describe("Page size, 1–500 (default 100)"),
711
- cursor: z5.string().optional().describe("Opaque cursor from a prior response's next_cursor")
711
+ trait: z6.string().describe('Required. Trait to match (e.g. "sip-010").'),
712
+ conformance: z6.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
713
+ include: z6.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
714
+ limit: z6.number().optional().describe("Page size, 1–500 (default 100)"),
715
+ cursor: z6.string().optional().describe("Opaque cursor from a prior response's next_cursor")
712
716
  }, async (params) => jsonResponse(await clientProvider().contracts.list(params)));
713
717
  defineTool(server, "contracts_get_abi", "Fetch a single deployed contract's ABI from the registry (prod-safe). Returns the contract's metadata + full ABI (functions, maps, variables, fungible/non-fungible tokens). Returns not_found if the contract isn't in the registry. Use it to inspect a contract before subgraphs_scaffold.", {
714
- contractId: z5.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
718
+ contractId: z6.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
715
719
  }, async ({ contractId }) => {
716
720
  const contract = await clientProvider().contracts.get(contractId, {
717
721
  includeAbi: true
@@ -728,17 +732,17 @@ function registerContractTools(server, clientProvider = getClient) {
728
732
 
729
733
  // src/tools/index.ts
730
734
  import { DECODED_EVENT_TYPES } from "@secondlayer/shared";
731
- import { z as z6 } from "zod";
735
+ import { z as z7 } from "zod";
732
736
  var INDEX_EVENT_TYPES = DECODED_EVENT_TYPES;
733
737
  var rangeFilters = {
734
- contractId: z6.string().optional().describe("Filter by contract id"),
735
- fromHeight: z6.number().optional().describe("Start block height (inclusive)"),
736
- toHeight: z6.number().optional().describe("End block height (inclusive)"),
737
- cursor: z6.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
738
- limit: z6.number().optional().describe("Max rows for this page")
738
+ contractId: z7.string().optional().describe("Filter by contract id"),
739
+ fromHeight: z7.number().optional().describe("Start block height (inclusive)"),
740
+ toHeight: z7.number().optional().describe("End block height (inclusive)"),
741
+ cursor: z7.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
742
+ limit: z7.number().optional().describe("Max rows for this page")
739
743
  };
740
744
  var orderFilter = {
741
- order: z6.enum(["asc", "desc"]).optional().describe("asc (default) reads oldest first; desc reads newest first. A cursor only resumes under the order that issued it.")
745
+ order: z7.enum(["asc", "desc"]).optional().describe("asc (default) reads oldest first; desc reads newest first. A cursor only resumes under the order that issued it.")
742
746
  };
743
747
  var heightFilters = {
744
748
  fromHeight: rangeFilters.fromHeight,
@@ -750,47 +754,47 @@ function registerIndexTools(server, clientProvider = getClient) {
750
754
  defineTool(server, "index_ft_transfers", "List decoded SIP-010 fungible-token transfers from Index. Reads are keyless.", {
751
755
  ...rangeFilters,
752
756
  ...orderFilter,
753
- sender: z6.string().optional().describe("Filter by sender principal"),
754
- recipient: z6.string().optional().describe("Filter by recipient principal"),
755
- assetIdentifier: z6.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
757
+ sender: z7.string().optional().describe("Filter by sender principal"),
758
+ recipient: z7.string().optional().describe("Filter by recipient principal"),
759
+ assetIdentifier: z7.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
756
760
  }, async (params) => jsonResponse(await clientProvider().index.ftTransfers.list(params)));
757
761
  defineTool(server, "index_nft_transfers", "List decoded SIP-009 non-fungible-token transfers from Index. Reads are keyless.", {
758
762
  ...rangeFilters,
759
763
  ...orderFilter,
760
- sender: z6.string().optional().describe("Filter by sender principal"),
761
- recipient: z6.string().optional().describe("Filter by recipient principal"),
762
- assetIdentifier: z6.string().optional().describe("Filter by asset identifier (contract::asset)")
764
+ sender: z7.string().optional().describe("Filter by sender principal"),
765
+ recipient: z7.string().optional().describe("Filter by recipient principal"),
766
+ assetIdentifier: z7.string().optional().describe("Filter by asset identifier (contract::asset)")
763
767
  }, async (params) => jsonResponse(await clientProvider().index.nftTransfers.list(params)));
764
768
  defineTool(server, "index_events", "List decoded chain events from the Index by event type. Use this for event types without a dedicated tool (stx_*, ft_mint/burn, nft_mint/burn, print), and for trait-scoped queries: set `trait` (e.g. sip-010) to match all contracts conforming to a standard — pair with contracts_find to discover traits. For ft/nft transfers without a trait prefer index_ft_transfers / index_nft_transfers.", {
765
- eventType: z6.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
769
+ eventType: z7.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
766
770
  ...rangeFilters,
767
771
  ...orderFilter,
768
- sender: z6.string().optional().describe("Filter by sender principal"),
769
- recipient: z6.string().optional().describe("Filter by recipient principal"),
770
- assetIdentifier: z6.string().optional().describe("Filter by asset identifier where applicable"),
771
- trait: z6.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only."),
772
- txContext: z6.boolean().optional().describe("Join the submitting transaction into each event (tx_sender, tx_type, tx_status, tx_contract_id, tx_function_name). For print events it's the only source of the submitting sender.")
772
+ sender: z7.string().optional().describe("Filter by sender principal"),
773
+ recipient: z7.string().optional().describe("Filter by recipient principal"),
774
+ assetIdentifier: z7.string().optional().describe("Filter by asset identifier where applicable"),
775
+ trait: z7.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only."),
776
+ txContext: z7.boolean().optional().describe("Join the submitting transaction into each event (tx_sender, tx_type, tx_status, tx_contract_id, tx_function_name). For print events it's the only source of the submitting sender.")
773
777
  }, async (params) => jsonResponse(await clientProvider().index.events.list(params)));
774
778
  defineTool(server, "index_contract_calls", "List decoded contract calls from the Index (function name, args, result). Set `trait` (e.g. sip-010) to match calls to all contracts conforming to a standard. Note: contract-call cursors are a SEPARATE keyspace from event cursors — they are not interchangeable.", {
775
779
  ...rangeFilters,
776
- functionName: z6.string().optional().describe("Filter by called function name"),
777
- sender: z6.string().optional().describe("Filter by caller principal"),
778
- trait: z6.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
780
+ functionName: z7.string().optional().describe("Filter by called function name"),
781
+ sender: z7.string().optional().describe("Filter by caller principal"),
782
+ trait: z7.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
779
783
  }, async (params) => jsonResponse(await clientProvider().index.contractCalls.list(params)));
780
784
  defineTool(server, "index_blocks", "List decoded blocks from Index. Reads are keyless.", { ...heightFilters }, async (params) => jsonResponse(await clientProvider().index.blocks.list(params)));
781
785
  defineTool(server, "index_transactions", "List decoded transactions from Index. Filter by type, sender, or contract. Reads are keyless.", {
782
786
  ...rangeFilters,
783
- type: z6.string().optional().describe("Filter by transaction type"),
784
- sender: z6.string().optional().describe("Filter by sender principal")
787
+ type: z7.string().optional().describe("Filter by transaction type"),
788
+ sender: z7.string().optional().describe("Filter by sender principal")
785
789
  }, async (params) => jsonResponse(await clientProvider().index.transactions.list(params)));
786
790
  defineTool(server, "index_print_schema", "Empirical per-topic print payload schemas for a contract, inferred from sampled on-chain events: each topic's fields with observed Clarity types, decoded TS types, subgraph column types, and presence rates. Use before writing print_event subgraph handlers to learn what's on e.data. Anonymous read.", {
787
- contractId: z6.string().describe("Contract id (SP….name) whose print events to profile")
791
+ contractId: z7.string().describe("Contract id (SP….name) whose print events to profile")
788
792
  }, async (params) => jsonResponse(await clientProvider().index.printSchema(params.contractId)));
789
793
  defineTool(server, "index_discover", "Discover the Index vocabulary: every event type and its columns, allowed/equality filters, and required-non-null fields (and which types accept `trait`). Read this before building Index queries instead of guessing filters. Anonymous read.", {}, async () => jsonResponse(await clientProvider().index.discover()));
790
794
  defineTool(server, "batch_query", "Run up to 10 public /v1 reads in one round trip (POST /v1/batch). Each item keeps its own auth/quota/pay-per-call semantics; results return in order with per-item status. Paths must start with /v1/index, /v1/subgraphs, /v1/streams, or /v1/contracts.", {
791
- requests: z6.array(z6.object({
792
- path: z6.string().describe("Public /v1 read path"),
793
- params: z6.record(z6.string(), z6.string()).optional()
795
+ requests: z7.array(z7.object({
796
+ path: z7.string().describe("Public /v1 read path"),
797
+ params: z7.record(z7.string(), z7.string()).optional()
794
798
  })).min(1).max(10).describe("Read descriptors, executed concurrently")
795
799
  }, async (params) => jsonResponse(await clientProvider().batch(params.requests)));
796
800
  }
@@ -811,7 +815,7 @@ import {
811
815
  generateSubgraphCode,
812
816
  generateTokenSubgraphFromAbi
813
817
  } from "@secondlayer/scaffold";
814
- import { z as z7 } from "zod";
818
+ import { z as z8 } from "zod";
815
819
  async function fetchAbi(clientProvider, contractId) {
816
820
  const contract = await clientProvider().contracts.get(contractId, {
817
821
  includeAbi: true
@@ -826,8 +830,8 @@ async function fetchAbi(clientProvider, contractId) {
826
830
  }
827
831
  function registerScaffoldTools(server, clientProvider = getClient) {
828
832
  defineTool(server, "subgraphs_scaffold", "Generate a subgraph from observed print events when available; ABI token transfers or public functions only when the contract has never printed. Review the TypeScript, run subgraphs_test until ok: true with written >= 1, read skipped, then subgraphs_deploy. dryRun is DDL only.", {
829
- contractId: z7.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
830
- subgraphName: z7.string().optional().describe("Override the subgraph name (defaults to contract name)")
833
+ contractId: z8.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
834
+ subgraphName: z8.string().optional().describe("Override the subgraph name (defaults to contract name)")
831
835
  }, async ({ contractId, subgraphName }) => {
832
836
  const printSchema = await clientProvider().index.printSchema(contractId);
833
837
  if (printSchema && printSchema.topics.length > 0) {
@@ -869,7 +873,7 @@ import { DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2 } from "@secondlayer/shared
869
873
  import {
870
874
  runSubgraphTest
871
875
  } from "@secondlayer/subgraphs/testing";
872
- import { z as z8 } from "zod";
876
+ import { z as z9 } from "zod";
873
877
  function eventTypeFor(filter) {
874
878
  if (filter.type === "contract_deploy")
875
879
  return null;
@@ -895,13 +899,13 @@ function registerSubgraphTools(server, clientProvider = getClient) {
895
899
  const { data } = await clientProvider().subgraphs.list();
896
900
  return jsonResponse(data.map(formatSubgraphSummary));
897
901
  });
898
- 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 }) => {
902
+ 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 }) => {
899
903
  const detail = await clientProvider().subgraphs.status(name);
900
904
  return jsonResponse(detail);
901
905
  });
902
906
  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.", {
903
- name: z8.string().describe("Subgraph name"),
904
- format: z8.enum(["agent", "openapi", "markdown"]).optional().describe("agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md")
907
+ name: z9.string().describe("Subgraph name"),
908
+ format: z9.enum(["agent", "openapi", "markdown"]).optional().describe("agent = JSON schema for tool use (default), openapi = OpenAPI JSON, markdown = docs.md")
905
909
  }, async ({ name, format }) => {
906
910
  const client = clientProvider();
907
911
  if (format === "openapi")
@@ -911,15 +915,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
911
915
  return jsonResponse(await client.subgraphs.schema(name));
912
916
  });
913
917
  defineTool(server, "subgraphs_query", 'Query rows from a subgraph table (max 200 rows), reading the open /v1 surface — { rows, next_cursor, tip } envelope, cursor-paginated (no offset). Filters support operators: "amount.gte": "1000", "sender.neq": "SP...", "name.like": "%token%". Available operators: eq, neq, gt, gte, lt, lte, like. Every page with rows returns next_cursor (null only when empty): pass it back as `cursor` to read the next page. To TAIL new rows (no streaming over MCP), poll with cursor = next_cursor ?? the cursor you sent. Fetch one row by id with {"_id": "<id>"}. The same rows are readable over HTTP at GET /v1/subgraphs/<name>/<table>; hand that URL to third parties.', {
914
- name: z8.string().describe("Subgraph name"),
915
- table: z8.string().describe("Table name"),
916
- filters: z8.record(z8.string(), z8.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
917
- sort: z8.string().optional().describe("Column to sort by"),
918
- order: z8.enum(["asc", "desc"]).optional().describe("Sort order"),
919
- limit: z8.number().max(200).optional().describe("Max rows (default 50, max 200)"),
920
- cursor: z8.string().optional().describe("Resume from a previous response's nextCursor"),
921
- fields: z8.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
922
- count: z8.boolean().optional().describe("If true, return row count instead of rows")
918
+ name: z9.string().describe("Subgraph name"),
919
+ table: z9.string().describe("Table name"),
920
+ filters: z9.record(z9.string(), z9.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
921
+ sort: z9.string().optional().describe("Column to sort by"),
922
+ order: z9.enum(["asc", "desc"]).optional().describe("Sort order"),
923
+ limit: z9.number().max(200).optional().describe("Max rows (default 50, max 200)"),
924
+ cursor: z9.string().optional().describe("Resume from a previous response's nextCursor"),
925
+ fields: z9.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
926
+ count: z9.boolean().optional().describe("If true, return row count instead of rows")
923
927
  }, async ({
924
928
  name,
925
929
  table,
@@ -949,15 +953,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
949
953
  return jsonResponse({ ...capped, nextCursor: next_cursor, tip });
950
954
  });
951
955
  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.", {
952
- name: z8.string().describe("Subgraph name")
956
+ name: z9.string().describe("Subgraph name")
953
957
  }, async ({ name }) => {
954
958
  const result = await clientProvider().subgraphs.reindex(name);
955
959
  return jsonResponse(result);
956
960
  });
957
961
  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.", {
958
- name: z8.string().describe("Subgraph name"),
959
- fromBlock: z8.number().int().nonnegative().describe("Start block (inclusive)"),
960
- toBlock: z8.number().int().nonnegative().describe("End block (inclusive)")
962
+ name: z9.string().describe("Subgraph name"),
963
+ fromBlock: z9.number().int().nonnegative().describe("Start block (inclusive)"),
964
+ toBlock: z9.number().int().nonnegative().describe("End block (inclusive)")
961
965
  }, async ({ name, fromBlock, toBlock }) => {
962
966
  const result = await clientProvider().subgraphs.backfill(name, {
963
967
  fromBlock,
@@ -965,15 +969,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
965
969
  });
966
970
  return jsonResponse(result);
967
971
  });
968
- 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 }) => {
972
+ 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 }) => {
969
973
  const result = await clientProvider().subgraphs.stop(name);
970
974
  return jsonResponse(result);
971
975
  });
972
976
  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.", {
973
- name: z8.string().describe("Subgraph name"),
974
- limit: z8.number().int().positive().optional().describe("Max gaps to return"),
975
- offset: z8.number().int().nonnegative().optional().describe("Pagination offset"),
976
- resolved: z8.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
977
+ name: z9.string().describe("Subgraph name"),
978
+ limit: z9.number().int().positive().optional().describe("Max gaps to return"),
979
+ offset: z9.number().int().nonnegative().optional().describe("Pagination offset"),
980
+ resolved: z9.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
977
981
  }, async ({ name, limit, offset, resolved }) => {
978
982
  const result = await clientProvider().subgraphs.gaps(name, {
979
983
  limit,
@@ -983,20 +987,20 @@ function registerSubgraphTools(server, clientProvider = getClient) {
983
987
  return jsonResponse(result);
984
988
  });
985
989
  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.", {
986
- name: z8.string().describe("Subgraph name"),
987
- operationId: z8.string().optional().describe("Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history")
990
+ name: z9.string().describe("Subgraph name"),
991
+ operationId: z9.string().optional().describe("Fetch one operation by id (the operationId returned by reindex/backfill/stop); omit for recent history")
988
992
  }, async ({ name, operationId }) => {
989
993
  const client = clientProvider();
990
994
  return jsonResponse(operationId ? await client.subgraphs.getOperation(name, operationId) : await client.subgraphs.operations(name));
991
995
  });
992
- defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z8.string().describe("Subgraph name") }, async ({ name }) => {
996
+ defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z9.string().describe("Subgraph name") }, async ({ name }) => {
993
997
  const result = await clientProvider().subgraphs.delete(name);
994
998
  return textResponse(result.message);
995
999
  });
996
1000
  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.", {
997
- code: z8.string().describe("TypeScript source code containing a defineSubgraph() call"),
998
- startBlock: z8.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
999
- dryRun: z8.boolean().optional().describe("Validate schema/DDL only — does not run handlers. Use subgraphs_test to prove a mapping writes rows.")
1001
+ code: z9.string().describe("TypeScript source code containing a defineSubgraph() call"),
1002
+ startBlock: z9.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
1003
+ dryRun: z9.boolean().optional().describe("Validate schema/DDL only — does not run handlers. Use subgraphs_test to prove a mapping writes rows.")
1000
1004
  }, async ({ code, startBlock, dryRun }) => {
1001
1005
  const bundled = await bundleSubgraphCode(code);
1002
1006
  const result = await clientProvider().subgraphs.deploy({
@@ -1012,10 +1016,10 @@ function registerSubgraphTools(server, clientProvider = getClient) {
1012
1016
  return jsonResponse(result);
1013
1017
  });
1014
1018
  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.", {
1015
- code: z8.string().describe("TypeScript source containing a defineSubgraph() call"),
1016
- fromHeight: z8.number().int().nonnegative().describe("Start block height (inclusive)"),
1017
- toHeight: z8.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
1018
- limit: z8.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
1019
+ code: z9.string().describe("TypeScript source containing a defineSubgraph() call"),
1020
+ fromHeight: z9.number().int().nonnegative().describe("Start block height (inclusive)"),
1021
+ toHeight: z9.number().int().nonnegative().optional().describe("End block height (inclusive); default fromHeight+100"),
1022
+ limit: z9.number().int().positive().max(200).optional().describe("Max Index rows per source (default 50, max 200)")
1019
1023
  }, async ({ code, fromHeight, toHeight, limit }) => {
1020
1024
  const bundled = await bundleSubgraphCode(code);
1021
1025
  const def = await loadBundledDefinition(bundled.handlerCode);
@@ -1096,36 +1100,36 @@ function registerSubgraphTools(server, clientProvider = getClient) {
1096
1100
 
1097
1101
  // src/tools/webhooks.ts
1098
1102
  import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
1099
- import { z as z9 } from "zod";
1103
+ import { z as z10 } from "zod";
1100
1104
  function registerWebhookTools(server, clientProvider = getClient) {
1101
1105
  defineTool(server, "webhooks_list", "List all webhooks for the current account. Returns summary fields (no secrets).", {}, async () => {
1102
1106
  const { data } = await clientProvider().webhooks.list();
1103
1107
  return jsonResponse(data);
1104
1108
  });
1105
- defineTool(server, "webhooks_get", "Get full detail for a webhook (triggers, auth, retry config, circuit state).", { id: z9.string().describe("Webhook id") }, async ({ id }) => {
1109
+ defineTool(server, "webhooks_get", "Get full detail for a webhook (triggers, auth, retry config, circuit state).", { id: z10.string().describe("Webhook id") }, async ({ id }) => {
1106
1110
  const detail = await clientProvider().webhooks.get(id);
1107
1111
  return jsonResponse(detail);
1108
1112
  });
1109
1113
  defineTool(server, "webhooks_create", "Create a webhook that fires on raw chain events (set triggers). Returns `signingSecret` ONCE — forward it to the user so they can wire it into their receiver.", {
1110
- name: z9.string().describe("Human-readable name, unique per account"),
1111
- triggers: z9.array(z9.object({
1112
- type: z9.enum(CHAIN_TRIGGER_TYPES),
1113
- contractId: z9.string().optional(),
1114
- functionName: z9.string().optional(),
1115
- caller: z9.string().optional(),
1116
- sender: z9.string().optional(),
1117
- recipient: z9.string().optional(),
1118
- assetIdentifier: z9.string().optional(),
1119
- deployer: z9.string().optional(),
1120
- contractName: z9.string().optional(),
1121
- topic: z9.string().optional(),
1122
- lockedAddress: z9.string().optional(),
1123
- trait: z9.string().optional(),
1124
- minAmount: z9.union([z9.string(), z9.number()]).optional(),
1125
- maxAmount: z9.union([z9.string(), z9.number()]).optional()
1114
+ name: z10.string().describe("Human-readable name, unique per account"),
1115
+ triggers: z10.array(z10.object({
1116
+ type: z10.enum(CHAIN_TRIGGER_TYPES),
1117
+ contractId: z10.string().optional(),
1118
+ functionName: z10.string().optional(),
1119
+ caller: z10.string().optional(),
1120
+ sender: z10.string().optional(),
1121
+ recipient: z10.string().optional(),
1122
+ assetIdentifier: z10.string().optional(),
1123
+ deployer: z10.string().optional(),
1124
+ contractName: z10.string().optional(),
1125
+ topic: z10.string().optional(),
1126
+ lockedAddress: z10.string().optional(),
1127
+ trait: z10.string().optional(),
1128
+ minAmount: z10.union([z10.string(), z10.number()]).optional(),
1129
+ maxAmount: z10.union([z10.string(), z10.number()]).optional()
1126
1130
  })).describe("Chain triggers. 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."),
1127
- url: z9.string().describe("Webhook URL"),
1128
- format: z9.enum([
1131
+ url: z10.string().describe("Webhook URL"),
1132
+ format: z10.enum([
1129
1133
  "standard-webhooks",
1130
1134
  "inngest",
1131
1135
  "trigger",
@@ -1133,17 +1137,17 @@ function registerWebhookTools(server, clientProvider = getClient) {
1133
1137
  "cloudevents",
1134
1138
  "raw"
1135
1139
  ]).optional().describe("Wire format (default standard-webhooks)"),
1136
- authConfig: z9.record(z9.string(), z9.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1140
+ authConfig: z10.record(z10.string(), z10.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
1137
1141
  }, async (input) => {
1138
1142
  const res = await clientProvider().webhooks.create(input);
1139
1143
  return jsonResponse(res);
1140
1144
  });
1141
1145
  defineTool(server, "webhooks_update", "Patch a webhook (name, url, authConfig, format, retry, timeout, concurrency).", {
1142
- id: z9.string(),
1143
- name: z9.string().optional().describe("Rename the webhook"),
1144
- url: z9.string().optional(),
1145
- authConfig: z9.record(z9.string(), z9.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1146
- format: z9.enum([
1146
+ id: z10.string(),
1147
+ name: z10.string().optional().describe("Rename the webhook"),
1148
+ url: z10.string().optional(),
1149
+ authConfig: z10.record(z10.string(), z10.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
1150
+ format: z10.enum([
1147
1151
  "standard-webhooks",
1148
1152
  "inngest",
1149
1153
  "trigger",
@@ -1151,35 +1155,35 @@ function registerWebhookTools(server, clientProvider = getClient) {
1151
1155
  "cloudevents",
1152
1156
  "raw"
1153
1157
  ]).optional(),
1154
- maxRetries: z9.number().int().min(0).optional(),
1155
- timeoutMs: z9.number().int().min(100).optional(),
1156
- concurrency: z9.number().int().min(1).optional()
1158
+ maxRetries: z10.number().int().min(0).optional(),
1159
+ timeoutMs: z10.number().int().min(100).optional(),
1160
+ concurrency: z10.number().int().min(1).optional()
1157
1161
  }, async ({ id, ...patch }) => {
1158
1162
  const res = await clientProvider().webhooks.update(id, patch);
1159
1163
  return jsonResponse(res);
1160
1164
  });
1161
- defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z9.string() }, async ({ id }) => {
1165
+ defineTool(server, "webhooks_delete", "Delete a webhook. Pending outbox rows are cascade-deleted.", { id: z10.string() }, async ({ id }) => {
1162
1166
  const res = await clientProvider().webhooks.delete(id);
1163
1167
  return jsonResponse(res);
1164
1168
  });
1165
- 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 }) => {
1169
+ 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 }) => {
1166
1170
  const res = await clientProvider().webhooks.test(id);
1167
1171
  return jsonResponse(res);
1168
1172
  });
1169
- 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)));
1170
- 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)));
1171
- 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)));
1172
- 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)));
1173
- 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)));
1173
+ 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)));
1174
+ 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)));
1175
+ 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)));
1176
+ 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)));
1177
+ 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)));
1174
1178
  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.", {
1175
- id: z9.string().describe("Webhook id"),
1176
- outboxId: z9.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1179
+ id: z10.string().describe("Webhook id"),
1180
+ outboxId: z10.string().describe("Outbox id of the dead delivery (from webhooks_dead)")
1177
1181
  }, async ({ id, outboxId }) => jsonResponse(await clientProvider().webhooks.requeue(id, outboxId)));
1178
1182
  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.", {
1179
- id: z9.string(),
1180
- fromBlock: z9.number().int().nonnegative(),
1181
- toBlock: z9.number().int().nonnegative(),
1182
- force: z9.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1183
+ id: z10.string(),
1184
+ fromBlock: z10.number().int().nonnegative(),
1185
+ toBlock: z10.number().int().nonnegative(),
1186
+ force: z10.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
1183
1187
  }, async ({ id, fromBlock, toBlock, force }) => {
1184
1188
  const res = await clientProvider().webhooks.replay(id, {
1185
1189
  fromBlock,
@@ -1296,5 +1300,5 @@ var server = createServer();
1296
1300
  var transport = new StdioServerTransport;
1297
1301
  await server.connect(transport);
1298
1302
 
1299
- //# debugId=FEFD6ED1EF50B85B64756E2164756E21
1303
+ //# debugId=ACD340D5AE24347564756E2164756E21
1300
1304
  //# sourceMappingURL=bin.js.map