@secondlayer/mcp 4.5.1 → 4.5.3

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
@@ -45,44 +45,23 @@ function buildFetchImpl() {
45
45
  function getClient() {
46
46
  if (!instance) {
47
47
  const apiKey = readApiKey();
48
- const baseUrl = process.env.SECONDLAYER_API_URL;
48
+ const baseUrl = process.env.SECONDLAYER_API_URL || process.env.SL_API_URL || "http://127.0.0.1:3800";
49
49
  const dumpsBaseUrl = process.env.SL_STREAMS_DUMPS_URL;
50
50
  const fetchImpl = buildFetchImpl();
51
51
  instance = new SecondLayer({
52
52
  ...apiKey ? { apiKey } : {},
53
53
  origin: "mcp",
54
- ...baseUrl ? { baseUrl } : {},
54
+ baseUrl,
55
55
  ...dumpsBaseUrl ? { dumpsBaseUrl } : {},
56
56
  ...fetchImpl ? { fetchImpl } : {}
57
57
  });
58
58
  }
59
59
  return instance;
60
60
  }
61
- var keyHint = " — set SL_API_KEY to an sk-sl_ API key from " + "https://secondlayer.tools/platform/api-keys for write and account operations";
62
- async function apiRequest(method, path, body) {
63
- const apiKey = readApiKey();
64
- const baseUrl = process.env.SECONDLAYER_API_URL || "https://api.secondlayer.tools";
65
- const res = await fetch(`${baseUrl}${path}`, {
66
- method,
67
- headers: {
68
- "Content-Type": "application/json",
69
- ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
70
- },
71
- body: body ? JSON.stringify(body) : undefined
72
- });
73
- if (!res.ok) {
74
- const text = await res.text().catch(() => "");
75
- const needsKey = !apiKey && (res.status === 401 || res.status === 403);
76
- throw Object.assign(new Error((text || `HTTP ${res.status}`) + (needsKey ? keyHint : "")), { status: res.status });
77
- }
78
- if (res.status === 204)
79
- return;
80
- return res.json();
81
- }
82
61
 
83
62
  // src/lib/format.ts
84
63
  function formatSubgraphSummary(s) {
85
- const apiUrl = process.env.SECONDLAYER_API_URL || "https://api.secondlayer.tools";
64
+ const apiUrl = process.env.SECONDLAYER_API_URL || process.env.SL_API_URL || "http://127.0.0.1:3800";
86
65
  return {
87
66
  name: s.name,
88
67
  status: s.status,
@@ -307,31 +286,18 @@ function registerResources(server) {
307
286
  }));
308
287
  }
309
288
 
310
- // src/tools/account.ts
311
- import { z } from "zod";
312
- function registerAccountTools(server) {
313
- defineTool(server, "account_whoami", "Show the authenticated account's email and plan.", {}, async () => {
314
- const result = await apiRequest("GET", "/api/accounts/me");
315
- return jsonResponse(result);
316
- });
317
- defineTool(server, "account_create_key", "Mint a scoped streams/index read API key so the agent can self-provision access. Requires an account-level (owner) API key. The returned `key` is shown ONCE — forward it to the user to set as SL_API_KEY.", {
318
- product: z.enum(["streams", "index"]).optional().describe("Key scope (default streams)"),
319
- name: z.string().optional().describe("Optional label for the key")
320
- }, async ({ product, name }) => jsonResponse(await getClient().apiKeys.create({ product, name })));
321
- }
322
-
323
289
  // src/tools/codegen.ts
324
290
  import {
325
291
  generateIndexSchema
326
292
  } from "@secondlayer/subgraphs";
327
- import { z as z2 } from "zod";
293
+ import { z } from "zod";
328
294
  var TARGETS = ["prisma", "kysely", "drizzle", "json-schema"];
329
295
  function registerCodegenTools(server) {
330
296
  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.", {
331
- target: z2.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
332
- tables: z2.array(z2.string()).optional().describe("Restrict to these Index tables (default: all)"),
333
- schemaName: z2.string().optional().describe("Postgres schema to qualify table names with"),
334
- datasourceEnv: z2.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
297
+ target: z.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
298
+ tables: z.array(z.string()).optional().describe("Restrict to these Index tables (default: all)"),
299
+ schemaName: z.string().optional().describe("Postgres schema to qualify table names with"),
300
+ datasourceEnv: z.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
335
301
  }, ({ target, tables, schemaName, datasourceEnv }) => textResponse(generateIndexSchema(target ?? "kysely", {
336
302
  tables,
337
303
  schemaName,
@@ -340,17 +306,17 @@ function registerCodegenTools(server) {
340
306
  }
341
307
 
342
308
  // src/tools/contracts.ts
343
- import { z as z3 } from "zod";
309
+ import { z as z2 } from "zod";
344
310
  function registerContractTools(server, clientProvider = getClient) {
345
311
  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.', {
346
- trait: z3.string().describe('Required. Trait to match (e.g. "sip-010").'),
347
- conformance: z3.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
348
- include: z3.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
349
- limit: z3.number().optional().describe("Page size, 1–500 (default 100)"),
350
- cursor: z3.string().optional().describe("Opaque cursor from a prior response's next_cursor")
312
+ trait: z2.string().describe('Required. Trait to match (e.g. "sip-010").'),
313
+ conformance: z2.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
314
+ include: z2.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
315
+ limit: z2.number().optional().describe("Page size, 1–500 (default 100)"),
316
+ cursor: z2.string().optional().describe("Opaque cursor from a prior response's next_cursor")
351
317
  }, async (params) => jsonResponse(await clientProvider().contracts.list(params)));
352
318
  defineTool(server, "contracts_get_abi", "Fetch a single deployed contract's ABI from the registry (prod-safe). Returns the contract's metadata + full ABI (functions, maps, variables, fungible/non-fungible tokens). Returns not_found if the contract isn't in the registry. Use it to inspect a contract before scaffold_from_contract.", {
353
- contractId: z3.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
319
+ contractId: z2.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
354
320
  }, async ({ contractId }) => {
355
321
  const contract = await clientProvider().contracts.get(contractId, {
356
322
  includeAbi: true
@@ -367,14 +333,14 @@ function registerContractTools(server, clientProvider = getClient) {
367
333
 
368
334
  // src/tools/index.ts
369
335
  import { DECODED_EVENT_TYPES } from "@secondlayer/shared";
370
- import { z as z4 } from "zod";
336
+ import { z as z3 } from "zod";
371
337
  var INDEX_EVENT_TYPES = DECODED_EVENT_TYPES;
372
338
  var rangeFilters = {
373
- contractId: z4.string().optional().describe("Filter by contract id"),
374
- fromHeight: z4.number().optional().describe("Start block height (inclusive)"),
375
- toHeight: z4.number().optional().describe("End block height (inclusive)"),
376
- cursor: z4.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
377
- limit: z4.number().optional().describe("Max rows for this page")
339
+ contractId: z3.string().optional().describe("Filter by contract id"),
340
+ fromHeight: z3.number().optional().describe("Start block height (inclusive)"),
341
+ toHeight: z3.number().optional().describe("End block height (inclusive)"),
342
+ cursor: z3.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
343
+ limit: z3.number().optional().describe("Max rows for this page")
378
344
  };
379
345
  var heightFilters = {
380
346
  fromHeight: rangeFilters.fromHeight,
@@ -385,52 +351,52 @@ var heightFilters = {
385
351
  function registerIndexTools(server, clientProvider = getClient) {
386
352
  defineTool(server, "index_ft_transfers", "List decoded SIP-010 fungible-token transfers from the Index (decoded layer). Anonymous reads allowed (free-tier API keys are rejected — Build+ required).", {
387
353
  ...rangeFilters,
388
- sender: z4.string().optional().describe("Filter by sender principal"),
389
- recipient: z4.string().optional().describe("Filter by recipient principal"),
390
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
354
+ sender: z3.string().optional().describe("Filter by sender principal"),
355
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
356
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
391
357
  }, async (params) => jsonResponse(await clientProvider().index.ftTransfers.list(params)));
392
358
  defineTool(server, "index_nft_transfers", "List decoded SIP-009 non-fungible-token transfers from the Index. Anonymous reads allowed (free-tier keys rejected).", {
393
359
  ...rangeFilters,
394
- sender: z4.string().optional().describe("Filter by sender principal"),
395
- recipient: z4.string().optional().describe("Filter by recipient principal"),
396
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier (contract::asset)")
360
+ sender: z3.string().optional().describe("Filter by sender principal"),
361
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
362
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier (contract::asset)")
397
363
  }, async (params) => jsonResponse(await clientProvider().index.nftTransfers.list(params)));
398
364
  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.", {
399
- eventType: z4.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
365
+ eventType: z3.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
400
366
  ...rangeFilters,
401
- sender: z4.string().optional().describe("Filter by sender principal"),
402
- recipient: z4.string().optional().describe("Filter by recipient principal"),
403
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier where applicable"),
404
- trait: z4.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only."),
405
- txContext: z4.boolean().optional().describe("Join the submitting transaction into each event (tx_sender, tx_type, tx_status, tx_contract_id, tx_function_name). For print events it's the only source of the submitting sender.")
367
+ sender: z3.string().optional().describe("Filter by sender principal"),
368
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
369
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier where applicable"),
370
+ trait: z3.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId; contract-keyed event types only."),
371
+ txContext: z3.boolean().optional().describe("Join the submitting transaction into each event (tx_sender, tx_type, tx_status, tx_contract_id, tx_function_name). For print events it's the only source of the submitting sender.")
406
372
  }, async (params) => jsonResponse(await clientProvider().index.events.list(params)));
407
373
  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.", {
408
374
  ...rangeFilters,
409
- functionName: z4.string().optional().describe("Filter by called function name"),
410
- sender: z4.string().optional().describe("Filter by caller principal"),
411
- trait: z4.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
375
+ functionName: z3.string().optional().describe("Filter by called function name"),
376
+ sender: z3.string().optional().describe("Filter by caller principal"),
377
+ trait: z3.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
412
378
  }, async (params) => jsonResponse(await clientProvider().index.contractCalls.list(params)));
413
379
  defineTool(server, "index_blocks", "List decoded blocks from the Index. Anonymous reads allowed (free-tier keys rejected).", { ...heightFilters }, async (params) => jsonResponse(await clientProvider().index.blocks.list(params)));
414
380
  defineTool(server, "index_transactions", "List decoded transactions from the Index. Filter by type, sender, or contract. Anonymous reads allowed (free-tier keys rejected).", {
415
381
  ...rangeFilters,
416
- type: z4.string().optional().describe("Filter by transaction type"),
417
- sender: z4.string().optional().describe("Filter by sender principal")
382
+ type: z3.string().optional().describe("Filter by transaction type"),
383
+ sender: z3.string().optional().describe("Filter by sender principal")
418
384
  }, async (params) => jsonResponse(await clientProvider().index.transactions.list(params)));
419
385
  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.", {
420
- contractId: z4.string().describe("Contract id (SP….name) whose print events to profile")
386
+ contractId: z3.string().describe("Contract id (SP….name) whose print events to profile")
421
387
  }, async (params) => jsonResponse(await clientProvider().index.printSchema(params.contractId)));
422
388
  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()));
423
389
  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.", {
424
- requests: z4.array(z4.object({
425
- path: z4.string().describe("Public /v1 read path"),
426
- params: z4.record(z4.string(), z4.string()).optional()
390
+ requests: z3.array(z3.object({
391
+ path: z3.string().describe("Public /v1 read path"),
392
+ params: z3.record(z3.string(), z3.string()).optional()
427
393
  })).min(1).max(10).describe("Read descriptors, executed concurrently")
428
394
  }, async (params) => jsonResponse(await clientProvider().batch(params.requests)));
429
395
  }
430
396
 
431
397
  // src/tools/scaffold.ts
432
398
  import { generateSubgraphCode } from "@secondlayer/scaffold";
433
- import { z as z5 } from "zod";
399
+ import { z as z4 } from "zod";
434
400
  async function fetchAbi(clientProvider, contractId) {
435
401
  const contract = await clientProvider().contracts.get(contractId, {
436
402
  includeAbi: true
@@ -445,8 +411,8 @@ async function fetchAbi(clientProvider, contractId) {
445
411
  }
446
412
  function registerScaffoldTools(server, clientProvider = getClient) {
447
413
  defineTool(server, "scaffold_from_contract", "Generate a subgraph scaffold from a deployed Stacks contract. Fetches the ABI automatically.", {
448
- contractId: z5.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
449
- subgraphName: z5.string().optional().describe("Override the subgraph name (defaults to contract name)")
414
+ contractId: z4.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
415
+ subgraphName: z4.string().optional().describe("Override the subgraph name (defaults to contract name)")
450
416
  }, async ({ contractId, subgraphName }) => {
451
417
  const { functions } = await fetchAbi(clientProvider, contractId);
452
418
  const code = generateSubgraphCode(contractId, functions, subgraphName);
@@ -462,26 +428,26 @@ function registerStreamsTools(server, clientProvider = getClient) {
462
428
  // src/tools/subgraphs.ts
463
429
  import { bundleSubgraphCode } from "@secondlayer/bundler";
464
430
  import { ByoBreakingChangeError } from "@secondlayer/sdk";
465
- import { z as z6 } from "zod";
431
+ import { z as z5 } from "zod";
466
432
  function registerSubgraphTools(server, clientProvider = getClient) {
467
433
  defineTool(server, "subgraphs_list", "List all deployed subgraphs. Returns summary fields only, including visibility — public subgraphs are anon-readable at /v1/subgraphs/<name>.", {}, async () => {
468
434
  const { data } = await clientProvider().subgraphs.list();
469
435
  return jsonResponse(data.map(formatSubgraphSummary));
470
436
  });
471
- defineTool(server, "subgraphs_get", "Get full details of a subgraph including schema, health, and table columns.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
437
+ defineTool(server, "subgraphs_get", "Get full details of a subgraph including schema, health, and table columns.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
472
438
  const detail = await clientProvider().subgraphs.get(name);
473
439
  return jsonResponse(detail);
474
440
  });
475
441
  defineTool(server, "subgraphs_query", 'Query rows from a subgraph table (max 200 rows). Filters support operators: "amount.gte": "1000", "sender.neq": "SP...", "name.like": "%token%". Available operators: eq, neq, gt, gte, lt, lte, like. To TAIL new rows (no streaming over MCP): sort=_id, order=desc for the latest, then poll forward with the filter {"_id.gt": "<last _id seen>"}, order=asc — when tailing with a `fields` list, include "_id" in it or the next poll filter cannot be formed. Fetch one row by id with {"_id": "<id>"}. Public subgraphs are also keyless over HTTP at GET /v1/subgraphs/<name>/<table> — { rows, next_cursor, tip } envelope, resume with ?cursor=<next_cursor> + _order=asc|desc (no _offset/_sort on /v1); hand that URL to third parties.', {
476
- name: z6.string().describe("Subgraph name"),
477
- table: z6.string().describe("Table name"),
478
- filters: z6.record(z6.string(), z6.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
479
- sort: z6.string().optional().describe("Column to sort by"),
480
- order: z6.enum(["asc", "desc"]).optional().describe("Sort order"),
481
- limit: z6.number().max(200).optional().describe("Max rows (default 50, max 200)"),
482
- offset: z6.number().optional().describe("Offset for pagination"),
483
- fields: z6.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
484
- count: z6.boolean().optional().describe("If true, return row count instead of rows")
442
+ name: z5.string().describe("Subgraph name"),
443
+ table: z5.string().describe("Table name"),
444
+ filters: z5.record(z5.string(), z5.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
445
+ sort: z5.string().optional().describe("Column to sort by"),
446
+ order: z5.enum(["asc", "desc"]).optional().describe("Sort order"),
447
+ limit: z5.number().max(200).optional().describe("Max rows (default 50, max 200)"),
448
+ offset: z5.number().optional().describe("Offset for pagination"),
449
+ fields: z5.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
450
+ count: z5.boolean().optional().describe("If true, return row count instead of rows")
485
451
  }, async ({
486
452
  name,
487
453
  table,
@@ -509,15 +475,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
509
475
  return jsonResponse(result);
510
476
  });
511
477
  defineTool(server, "subgraphs_reindex", "Reindex a subgraph: drops and rebuilds the whole subgraph from its start block to chain tip. Takes no block range — use subgraphs_backfill to process a specific range. Returns an operationId — check subgraphs_get (health) or the REST operations endpoint to track progress to completion.", {
512
- name: z6.string().describe("Subgraph name")
478
+ name: z5.string().describe("Subgraph name")
513
479
  }, async ({ name }) => {
514
480
  const result = await clientProvider().subgraphs.reindex(name);
515
481
  return jsonResponse(result);
516
482
  });
517
483
  defineTool(server, "subgraphs_backfill", "Backfill a subgraph over a block range. Non-destructive forward fill (does not drop existing data) — unlike subgraphs_reindex, and the only data-fill path for BYO subgraphs (reindex is blocked there). Both blocks required. Returns an operationId — check subgraphs_get (health) or the REST operations endpoint to track progress.", {
518
- name: z6.string().describe("Subgraph name"),
519
- fromBlock: z6.number().int().nonnegative().describe("Start block (inclusive)"),
520
- toBlock: z6.number().int().nonnegative().describe("End block (inclusive)")
484
+ name: z5.string().describe("Subgraph name"),
485
+ fromBlock: z5.number().int().nonnegative().describe("Start block (inclusive)"),
486
+ toBlock: z5.number().int().nonnegative().describe("End block (inclusive)")
521
487
  }, async ({ name, fromBlock, toBlock }) => {
522
488
  const result = await clientProvider().subgraphs.backfill(name, {
523
489
  fromBlock,
@@ -525,15 +491,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
525
491
  });
526
492
  return jsonResponse(result);
527
493
  });
528
- defineTool(server, "subgraphs_stop", "Cancel an in-flight reindex or backfill operation for a subgraph. Returns the stop request status; check subgraphs_get (health) or the REST operations endpoint to confirm it reaches a terminal state.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
494
+ defineTool(server, "subgraphs_stop", "Cancel an in-flight reindex or backfill operation for a subgraph. Returns the stop request status; check subgraphs_get (health) or the REST operations endpoint to confirm it reaches a terminal state.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
529
495
  const result = await clientProvider().subgraphs.stop(name);
530
496
  return jsonResponse(result);
531
497
  });
532
498
  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.", {
533
- name: z6.string().describe("Subgraph name"),
534
- limit: z6.number().int().positive().optional().describe("Max gaps to return"),
535
- offset: z6.number().int().nonnegative().optional().describe("Pagination offset"),
536
- resolved: z6.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
499
+ name: z5.string().describe("Subgraph name"),
500
+ limit: z5.number().int().positive().optional().describe("Max gaps to return"),
501
+ offset: z5.number().int().nonnegative().optional().describe("Pagination offset"),
502
+ resolved: z5.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
537
503
  }, async ({ name, limit, offset, resolved }) => {
538
504
  const result = await clientProvider().subgraphs.gaps(name, {
539
505
  limit,
@@ -542,16 +508,16 @@ function registerSubgraphTools(server, clientProvider = getClient) {
542
508
  });
543
509
  return jsonResponse(result);
544
510
  });
545
- defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
511
+ defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
546
512
  const result = await clientProvider().subgraphs.delete(name);
547
513
  return textResponse(result.message);
548
514
  });
549
515
  defineTool(server, "subgraphs_deploy", "Deploy a subgraph from TypeScript code. Pass the full defineSubgraph() source — it will be bundled, validated, and deployed. Optional startBlock overrides the source definition for this deploy. Set dryRun to validate and preview the schema/DDL without writing anything. Set databaseUrl to deploy to your own Postgres (BYO data plane) — the server verifies the connection first; with dryRun it returns the DDL + grant script. A breaking BYO schema change is refused and returns a migration plan (drop + rebuild DDL) instead of deploying. Visibility defaults: managed deploys are public (anon-readable at /v1/subgraphs/<name>, name claimed in the global public namespace), BYO deploys are private. Call `subgraphs_reindex` separately if you need a forced reindex.", {
550
- code: z6.string().describe("TypeScript source code containing a defineSubgraph() call"),
551
- startBlock: z6.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
552
- databaseUrl: z6.string().optional().describe("BYO data plane: Postgres connection string to host the subgraph's schema and rows in your own database"),
553
- dryRun: z6.boolean().optional().describe("Validate and preview the deploy (schema/DDL, BYO connection) without writing changes"),
554
- visibility: z6.enum(["public", "private"]).optional().describe("Read visibility: public = anon /v1 reads + global name claim; private = owning account's key only. Defaults: managed → public, BYO → private.")
516
+ code: z5.string().describe("TypeScript source code containing a defineSubgraph() call"),
517
+ startBlock: z5.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
518
+ databaseUrl: z5.string().optional().describe("BYO data plane: Postgres connection string to host the subgraph's schema and rows in your own database"),
519
+ dryRun: z5.boolean().optional().describe("Validate and preview the deploy (schema/DDL, BYO connection) without writing changes"),
520
+ visibility: z5.enum(["public", "private"]).optional().describe("Read visibility: public = anon /v1 reads + global name claim; private = owning account's key only. Defaults: managed → public, BYO → private.")
555
521
  }, async ({ code, startBlock, databaseUrl, dryRun, visibility }) => {
556
522
  const bundled = await bundleSubgraphCode(code);
557
523
  try {
@@ -576,11 +542,11 @@ function registerSubgraphTools(server, clientProvider = getClient) {
576
542
  throw err;
577
543
  }
578
544
  });
579
- defineTool(server, "subgraphs_publish", "Make a subgraph publicly readable at /v1/subgraphs/<name> — anyone (or any agent) can read it without a key. Claims the name in the global public namespace; fails with PUBLIC_NAME_TAKEN if another account holds it.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
545
+ defineTool(server, "subgraphs_publish", "Make a subgraph publicly readable at /v1/subgraphs/<name> — anyone (or any agent) can read it without a key. Claims the name in the global public namespace; fails with PUBLIC_NAME_TAKEN if another account holds it.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
580
546
  const result = await clientProvider().subgraphs.publish(name);
581
547
  return jsonResponse(result);
582
548
  });
583
- defineTool(server, "subgraphs_unpublish", "Make a subgraph private again — /v1 reads then require the owning account's bearer key, and the global public name claim is released.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
549
+ defineTool(server, "subgraphs_unpublish", "Make a subgraph private again — /v1 reads then require the owning account's bearer key, and the global public name claim is released.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
584
550
  const result = await clientProvider().subgraphs.unpublish(name);
585
551
  return jsonResponse(result);
586
552
  });
@@ -588,38 +554,38 @@ function registerSubgraphTools(server, clientProvider = getClient) {
588
554
 
589
555
  // src/tools/subscriptions.ts
590
556
  import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
591
- import { z as z7 } from "zod";
557
+ import { z as z6 } from "zod";
592
558
  function registerSubscriptionTools(server, clientProvider = getClient) {
593
559
  defineTool(server, "subscriptions_list", "List all subscriptions for the current account. Returns summary fields (no secrets).", {}, async () => {
594
560
  const { data } = await clientProvider().subscriptions.list();
595
561
  return jsonResponse(data);
596
562
  });
597
- defineTool(server, "subscriptions_get", "Get full detail for a subscription (filter, auth, retry config, circuit state).", { id: z7.string().describe("Subscription id") }, async ({ id }) => {
563
+ defineTool(server, "subscriptions_get", "Get full detail for a subscription (filter, auth, retry config, circuit state).", { id: z6.string().describe("Subscription id") }, async ({ id }) => {
598
564
  const detail = await clientProvider().subscriptions.get(id);
599
565
  return jsonResponse(detail);
600
566
  });
601
567
  defineTool(server, "subscriptions_create", "Create a subscription. Two kinds (mutually exclusive): a SUBGRAPH subscription fires on a subgraph table's rows (set subgraphName + tableName + optional filter); a CHAIN subscription fires on raw chain events with no subgraph (set triggers). Returns `signingSecret` ONCE — forward it to the user so they can wire it into their receiver.", {
602
- name: z7.string().describe("Human-readable name, unique per account"),
603
- subgraphName: z7.string().optional().describe("Subgraph to subscribe to (subgraph subscription)"),
604
- tableName: z7.string().optional().describe("Table within the subgraph (subgraph subscription)"),
605
- triggers: z7.array(z7.object({
606
- type: z7.enum(CHAIN_TRIGGER_TYPES),
607
- contractId: z7.string().optional(),
608
- functionName: z7.string().optional(),
609
- caller: z7.string().optional(),
610
- sender: z7.string().optional(),
611
- recipient: z7.string().optional(),
612
- assetIdentifier: z7.string().optional(),
613
- deployer: z7.string().optional(),
614
- contractName: z7.string().optional(),
615
- topic: z7.string().optional(),
616
- lockedAddress: z7.string().optional(),
617
- trait: z7.string().optional(),
618
- minAmount: z7.union([z7.string(), z7.number()]).optional(),
619
- maxAmount: z7.union([z7.string(), z7.number()]).optional()
568
+ name: z6.string().describe("Human-readable name, unique per account"),
569
+ subgraphName: z6.string().optional().describe("Subgraph to subscribe to (subgraph subscription)"),
570
+ tableName: z6.string().optional().describe("Table within the subgraph (subgraph subscription)"),
571
+ triggers: z6.array(z6.object({
572
+ type: z6.enum(CHAIN_TRIGGER_TYPES),
573
+ contractId: z6.string().optional(),
574
+ functionName: z6.string().optional(),
575
+ caller: z6.string().optional(),
576
+ sender: z6.string().optional(),
577
+ recipient: z6.string().optional(),
578
+ assetIdentifier: z6.string().optional(),
579
+ deployer: z6.string().optional(),
580
+ contractName: z6.string().optional(),
581
+ topic: z6.string().optional(),
582
+ lockedAddress: z6.string().optional(),
583
+ trait: z6.string().optional(),
584
+ minAmount: z6.union([z6.string(), z6.number()]).optional(),
585
+ maxAmount: z6.union([z6.string(), z6.number()]).optional()
620
586
  })).optional().describe("Chain triggers (chain subscription) — provide INSTEAD of subgraphName/tableName. Each targets a raw chain event/tx; string fields accept `*` wildcards, `trait` scopes to a SIP/trait. Per-type accepted fields: see the secondlayer://chain-triggers resource. Forward-looking: starts at chain tip, no backfill."),
621
- url: z7.string().describe("Webhook URL"),
622
- format: z7.enum([
587
+ url: z6.string().describe("Webhook URL"),
588
+ format: z6.enum([
623
589
  "standard-webhooks",
624
590
  "inngest",
625
591
  "trigger",
@@ -627,20 +593,20 @@ function registerSubscriptionTools(server, clientProvider = getClient) {
627
593
  "cloudevents",
628
594
  "raw"
629
595
  ]).optional().describe("Wire format (default standard-webhooks)"),
630
- runtime: z7.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
631
- filter: z7.record(z7.string(), z7.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
632
- authConfig: z7.record(z7.string(), z7.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
596
+ runtime: z6.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
597
+ filter: z6.record(z6.string(), z6.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
598
+ authConfig: z6.record(z6.string(), z6.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
633
599
  }, async (input) => {
634
600
  const res = await clientProvider().subscriptions.create(input);
635
601
  return jsonResponse(res);
636
602
  });
637
603
  defineTool(server, "subscriptions_update", "Patch a subscription (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
638
- id: z7.string(),
639
- name: z7.string().optional().describe("Rename the subscription"),
640
- url: z7.string().optional(),
641
- filter: z7.record(z7.string(), z7.unknown()).optional(),
642
- authConfig: z7.record(z7.string(), z7.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
643
- format: z7.enum([
604
+ id: z6.string(),
605
+ name: z6.string().optional().describe("Rename the subscription"),
606
+ url: z6.string().optional(),
607
+ filter: z6.record(z6.string(), z6.unknown()).optional(),
608
+ authConfig: z6.record(z6.string(), z6.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
609
+ format: z6.enum([
644
610
  "standard-webhooks",
645
611
  "inngest",
646
612
  "trigger",
@@ -648,27 +614,27 @@ function registerSubscriptionTools(server, clientProvider = getClient) {
648
614
  "cloudevents",
649
615
  "raw"
650
616
  ]).optional(),
651
- runtime: z7.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
652
- maxRetries: z7.number().int().min(0).optional(),
653
- timeoutMs: z7.number().int().min(100).optional(),
654
- concurrency: z7.number().int().min(1).optional()
617
+ runtime: z6.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
618
+ maxRetries: z6.number().int().min(0).optional(),
619
+ timeoutMs: z6.number().int().min(100).optional(),
620
+ concurrency: z6.number().int().min(1).optional()
655
621
  }, async ({ id, ...patch }) => {
656
622
  const res = await clientProvider().subscriptions.update(id, patch);
657
623
  return jsonResponse(res);
658
624
  });
659
- defineTool(server, "subscriptions_delete", "Delete a subscription. Pending outbox rows are cascade-deleted.", { id: z7.string() }, async ({ id }) => {
625
+ defineTool(server, "subscriptions_delete", "Delete a subscription. Pending outbox rows are cascade-deleted.", { id: z6.string() }, async ({ id }) => {
660
626
  const res = await clientProvider().subscriptions.delete(id);
661
627
  return jsonResponse(res);
662
628
  });
663
- defineTool(server, "subscriptions_test", "Send a one-off test webhook to a subscription's URL (built for its format, SSRF-guarded). Logged as a delivery row. Returns {ok, statusCode, error, durationMs, deliveryId}.", { id: z7.string().describe("Subscription id") }, async ({ id }) => {
629
+ defineTool(server, "subscriptions_test", "Send a one-off test webhook to a subscription's URL (built for its format, SSRF-guarded). Logged as a delivery row. Returns {ok, statusCode, error, durationMs, deliveryId}.", { id: z6.string().describe("Subscription id") }, async ({ id }) => {
664
630
  const res = await clientProvider().subscriptions.test(id);
665
631
  return jsonResponse(res);
666
632
  });
667
633
  defineTool(server, "subscriptions_replay", "Replay a block range for a subscription. Replays run at 10% of batch capacity — use sparingly. Pass `force` (a short idempotency suffix) to re-run a range that was already replayed.", {
668
- id: z7.string(),
669
- fromBlock: z7.number().int().nonnegative(),
670
- toBlock: z7.number().int().nonnegative(),
671
- force: z7.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
634
+ id: z6.string(),
635
+ fromBlock: z6.number().int().nonnegative(),
636
+ toBlock: z6.number().int().nonnegative(),
637
+ force: z6.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
672
638
  }, async ({ id, fromBlock, toBlock, force }) => {
673
639
  const res = await clientProvider().subscriptions.replay(id, {
674
640
  fromBlock,
@@ -690,7 +656,6 @@ function createServer() {
690
656
  registerScaffoldTools(server);
691
657
  registerSubgraphTools(server);
692
658
  registerSubscriptionTools(server);
693
- registerAccountTools(server);
694
659
  registerIndexTools(server);
695
660
  registerStreamsTools(server);
696
661
  registerContractTools(server);
@@ -702,5 +667,5 @@ export {
702
667
  createServer
703
668
  };
704
669
 
705
- //# debugId=3D7EFA413AF93E3B64756E2164756E21
670
+ //# debugId=C29B31CC375B0A8E64756E2164756E21
706
671
  //# sourceMappingURL=index.js.map