@secondlayer/mcp 4.5.2 → 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/bin.js CHANGED
@@ -63,27 +63,6 @@ function getClient() {
63
63
  }
64
64
  return instance;
65
65
  }
66
- var keyHint = " — set SL_API_KEY to an sk-sl_ API key from " + "https://secondlayer.tools/platform/api-keys for write and account operations";
67
- async function apiRequest(method, path, body) {
68
- const apiKey = readApiKey();
69
- const baseUrl = process.env.SECONDLAYER_API_URL || process.env.SL_API_URL || "http://127.0.0.1:3800";
70
- const res = await fetch(`${baseUrl}${path}`, {
71
- method,
72
- headers: {
73
- "Content-Type": "application/json",
74
- ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
75
- },
76
- body: body ? JSON.stringify(body) : undefined
77
- });
78
- if (!res.ok) {
79
- const text = await res.text().catch(() => "");
80
- const needsKey = !apiKey && (res.status === 401 || res.status === 403);
81
- throw Object.assign(new Error((text || `HTTP ${res.status}`) + (needsKey ? keyHint : "")), { status: res.status });
82
- }
83
- if (res.status === 204)
84
- return;
85
- return res.json();
86
- }
87
66
 
88
67
  // src/lib/format.ts
89
68
  function formatSubgraphSummary(s) {
@@ -312,31 +291,18 @@ function registerResources(server) {
312
291
  }));
313
292
  }
314
293
 
315
- // src/tools/account.ts
316
- import { z } from "zod";
317
- function registerAccountTools(server) {
318
- defineTool(server, "account_whoami", "Show the authenticated account's email and plan.", {}, async () => {
319
- const result = await apiRequest("GET", "/api/accounts/me");
320
- return jsonResponse(result);
321
- });
322
- 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.", {
323
- product: z.enum(["streams", "index"]).optional().describe("Key scope (default streams)"),
324
- name: z.string().optional().describe("Optional label for the key")
325
- }, async ({ product, name }) => jsonResponse(await getClient().apiKeys.create({ product, name })));
326
- }
327
-
328
294
  // src/tools/codegen.ts
329
295
  import {
330
296
  generateIndexSchema
331
297
  } from "@secondlayer/subgraphs";
332
- import { z as z2 } from "zod";
298
+ import { z } from "zod";
333
299
  var TARGETS = ["prisma", "kysely", "drizzle", "json-schema"];
334
300
  function registerCodegenTools(server) {
335
301
  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.", {
336
- target: z2.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
337
- tables: z2.array(z2.string()).optional().describe("Restrict to these Index tables (default: all)"),
338
- schemaName: z2.string().optional().describe("Postgres schema to qualify table names with"),
339
- datasourceEnv: z2.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
302
+ target: z.enum(TARGETS).optional().describe("Output flavor (default kysely)"),
303
+ tables: z.array(z.string()).optional().describe("Restrict to these Index tables (default: all)"),
304
+ schemaName: z.string().optional().describe("Postgres schema to qualify table names with"),
305
+ datasourceEnv: z.string().optional().describe("Prisma only: datasource url env var (default DATABASE_URL)")
340
306
  }, ({ target, tables, schemaName, datasourceEnv }) => textResponse(generateIndexSchema(target ?? "kysely", {
341
307
  tables,
342
308
  schemaName,
@@ -345,17 +311,17 @@ function registerCodegenTools(server) {
345
311
  }
346
312
 
347
313
  // src/tools/contracts.ts
348
- import { z as z3 } from "zod";
314
+ import { z as z2 } from "zod";
349
315
  function registerContractTools(server, clientProvider = getClient) {
350
316
  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.', {
351
- trait: z3.string().describe('Required. Trait to match (e.g. "sip-010").'),
352
- conformance: z3.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
353
- include: z3.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
354
- limit: z3.number().optional().describe("Page size, 1–500 (default 100)"),
355
- cursor: z3.string().optional().describe("Opaque cursor from a prior response's next_cursor")
317
+ trait: z2.string().describe('Required. Trait to match (e.g. "sip-010").'),
318
+ conformance: z2.enum(["declared", "inferred", "any"]).optional().describe("declared = parsed from source, inferred = ABI shape-match, any = either (default)"),
319
+ include: z2.literal("abi").optional().describe(`Set to "abi" to include each contract's full ABI`),
320
+ limit: z2.number().optional().describe("Page size, 1–500 (default 100)"),
321
+ cursor: z2.string().optional().describe("Opaque cursor from a prior response's next_cursor")
356
322
  }, async (params) => jsonResponse(await clientProvider().contracts.list(params)));
357
323
  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.", {
358
- contractId: z3.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
324
+ contractId: z2.string().describe("Fully qualified contract id (e.g. SP….amm-pool-v2-01)")
359
325
  }, async ({ contractId }) => {
360
326
  const contract = await clientProvider().contracts.get(contractId, {
361
327
  includeAbi: true
@@ -372,14 +338,14 @@ function registerContractTools(server, clientProvider = getClient) {
372
338
 
373
339
  // src/tools/index.ts
374
340
  import { DECODED_EVENT_TYPES } from "@secondlayer/shared";
375
- import { z as z4 } from "zod";
341
+ import { z as z3 } from "zod";
376
342
  var INDEX_EVENT_TYPES = DECODED_EVENT_TYPES;
377
343
  var rangeFilters = {
378
- contractId: z4.string().optional().describe("Filter by contract id"),
379
- fromHeight: z4.number().optional().describe("Start block height (inclusive)"),
380
- toHeight: z4.number().optional().describe("End block height (inclusive)"),
381
- cursor: z4.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
382
- limit: z4.number().optional().describe("Max rows for this page")
344
+ contractId: z3.string().optional().describe("Filter by contract id"),
345
+ fromHeight: z3.number().optional().describe("Start block height (inclusive)"),
346
+ toHeight: z3.number().optional().describe("End block height (inclusive)"),
347
+ cursor: z3.string().optional().describe("Opaque cursor from a prior response's next_cursor"),
348
+ limit: z3.number().optional().describe("Max rows for this page")
383
349
  };
384
350
  var heightFilters = {
385
351
  fromHeight: rangeFilters.fromHeight,
@@ -390,52 +356,52 @@ var heightFilters = {
390
356
  function registerIndexTools(server, clientProvider = getClient) {
391
357
  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).", {
392
358
  ...rangeFilters,
393
- sender: z4.string().optional().describe("Filter by sender principal"),
394
- recipient: z4.string().optional().describe("Filter by recipient principal"),
395
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
359
+ sender: z3.string().optional().describe("Filter by sender principal"),
360
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
361
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier (contract::asset), e.g. SP…sbtc-token::sbtc-token")
396
362
  }, async (params) => jsonResponse(await clientProvider().index.ftTransfers.list(params)));
397
363
  defineTool(server, "index_nft_transfers", "List decoded SIP-009 non-fungible-token transfers from the Index. Anonymous reads allowed (free-tier keys rejected).", {
398
364
  ...rangeFilters,
399
- sender: z4.string().optional().describe("Filter by sender principal"),
400
- recipient: z4.string().optional().describe("Filter by recipient principal"),
401
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier (contract::asset)")
365
+ sender: z3.string().optional().describe("Filter by sender principal"),
366
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
367
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier (contract::asset)")
402
368
  }, async (params) => jsonResponse(await clientProvider().index.nftTransfers.list(params)));
403
369
  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.", {
404
- eventType: z4.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
370
+ eventType: z3.enum(INDEX_EVENT_TYPES).describe("Required. Decoded event type to list."),
405
371
  ...rangeFilters,
406
- sender: z4.string().optional().describe("Filter by sender principal"),
407
- recipient: z4.string().optional().describe("Filter by recipient principal"),
408
- assetIdentifier: z4.string().optional().describe("Filter by asset identifier where applicable"),
409
- 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."),
410
- 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.")
372
+ sender: z3.string().optional().describe("Filter by sender principal"),
373
+ recipient: z3.string().optional().describe("Filter by recipient principal"),
374
+ assetIdentifier: z3.string().optional().describe("Filter by asset identifier where applicable"),
375
+ 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."),
376
+ 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.")
411
377
  }, async (params) => jsonResponse(await clientProvider().index.events.list(params)));
412
378
  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.", {
413
379
  ...rangeFilters,
414
- functionName: z4.string().optional().describe("Filter by called function name"),
415
- sender: z4.string().optional().describe("Filter by caller principal"),
416
- trait: z4.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
380
+ functionName: z3.string().optional().describe("Filter by called function name"),
381
+ sender: z3.string().optional().describe("Filter by caller principal"),
382
+ trait: z3.string().optional().describe("Match contracts conforming to a trait/standard (e.g. sip-010). Mutually exclusive with contractId.")
417
383
  }, async (params) => jsonResponse(await clientProvider().index.contractCalls.list(params)));
418
384
  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)));
419
385
  defineTool(server, "index_transactions", "List decoded transactions from the Index. Filter by type, sender, or contract. Anonymous reads allowed (free-tier keys rejected).", {
420
386
  ...rangeFilters,
421
- type: z4.string().optional().describe("Filter by transaction type"),
422
- sender: z4.string().optional().describe("Filter by sender principal")
387
+ type: z3.string().optional().describe("Filter by transaction type"),
388
+ sender: z3.string().optional().describe("Filter by sender principal")
423
389
  }, async (params) => jsonResponse(await clientProvider().index.transactions.list(params)));
424
390
  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.", {
425
- contractId: z4.string().describe("Contract id (SP….name) whose print events to profile")
391
+ contractId: z3.string().describe("Contract id (SP….name) whose print events to profile")
426
392
  }, async (params) => jsonResponse(await clientProvider().index.printSchema(params.contractId)));
427
393
  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()));
428
394
  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.", {
429
- requests: z4.array(z4.object({
430
- path: z4.string().describe("Public /v1 read path"),
431
- params: z4.record(z4.string(), z4.string()).optional()
395
+ requests: z3.array(z3.object({
396
+ path: z3.string().describe("Public /v1 read path"),
397
+ params: z3.record(z3.string(), z3.string()).optional()
432
398
  })).min(1).max(10).describe("Read descriptors, executed concurrently")
433
399
  }, async (params) => jsonResponse(await clientProvider().batch(params.requests)));
434
400
  }
435
401
 
436
402
  // src/tools/scaffold.ts
437
403
  import { generateSubgraphCode } from "@secondlayer/scaffold";
438
- import { z as z5 } from "zod";
404
+ import { z as z4 } from "zod";
439
405
  async function fetchAbi(clientProvider, contractId) {
440
406
  const contract = await clientProvider().contracts.get(contractId, {
441
407
  includeAbi: true
@@ -450,8 +416,8 @@ async function fetchAbi(clientProvider, contractId) {
450
416
  }
451
417
  function registerScaffoldTools(server, clientProvider = getClient) {
452
418
  defineTool(server, "scaffold_from_contract", "Generate a subgraph scaffold from a deployed Stacks contract. Fetches the ABI automatically.", {
453
- contractId: z5.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
454
- subgraphName: z5.string().optional().describe("Override the subgraph name (defaults to contract name)")
419
+ contractId: z4.string().describe("Fully qualified contract ID (e.g. SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01)"),
420
+ subgraphName: z4.string().optional().describe("Override the subgraph name (defaults to contract name)")
455
421
  }, async ({ contractId, subgraphName }) => {
456
422
  const { functions } = await fetchAbi(clientProvider, contractId);
457
423
  const code = generateSubgraphCode(contractId, functions, subgraphName);
@@ -467,26 +433,26 @@ function registerStreamsTools(server, clientProvider = getClient) {
467
433
  // src/tools/subgraphs.ts
468
434
  import { bundleSubgraphCode } from "@secondlayer/bundler";
469
435
  import { ByoBreakingChangeError } from "@secondlayer/sdk";
470
- import { z as z6 } from "zod";
436
+ import { z as z5 } from "zod";
471
437
  function registerSubgraphTools(server, clientProvider = getClient) {
472
438
  defineTool(server, "subgraphs_list", "List all deployed subgraphs. Returns summary fields only, including visibility — public subgraphs are anon-readable at /v1/subgraphs/<name>.", {}, async () => {
473
439
  const { data } = await clientProvider().subgraphs.list();
474
440
  return jsonResponse(data.map(formatSubgraphSummary));
475
441
  });
476
- defineTool(server, "subgraphs_get", "Get full details of a subgraph including schema, health, and table columns.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
442
+ defineTool(server, "subgraphs_get", "Get full details of a subgraph including schema, health, and table columns.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
477
443
  const detail = await clientProvider().subgraphs.get(name);
478
444
  return jsonResponse(detail);
479
445
  });
480
446
  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.', {
481
- name: z6.string().describe("Subgraph name"),
482
- table: z6.string().describe("Table name"),
483
- filters: z6.record(z6.string(), z6.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
484
- sort: z6.string().optional().describe("Column to sort by"),
485
- order: z6.enum(["asc", "desc"]).optional().describe("Sort order"),
486
- limit: z6.number().max(200).optional().describe("Max rows (default 50, max 200)"),
487
- offset: z6.number().optional().describe("Offset for pagination"),
488
- fields: z6.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
489
- count: z6.boolean().optional().describe("If true, return row count instead of rows")
447
+ name: z5.string().describe("Subgraph name"),
448
+ table: z5.string().describe("Table name"),
449
+ filters: z5.record(z5.string(), z5.string()).optional().describe('Column filters — plain values or with operators (e.g. {"amount.gte": "1000", "sender": "SP..."})'),
450
+ sort: z5.string().optional().describe("Column to sort by"),
451
+ order: z5.enum(["asc", "desc"]).optional().describe("Sort order"),
452
+ limit: z5.number().max(200).optional().describe("Max rows (default 50, max 200)"),
453
+ offset: z5.number().optional().describe("Offset for pagination"),
454
+ fields: z5.string().optional().describe('Comma-separated column list to return (e.g. "sender,amount")'),
455
+ count: z5.boolean().optional().describe("If true, return row count instead of rows")
490
456
  }, async ({
491
457
  name,
492
458
  table,
@@ -514,15 +480,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
514
480
  return jsonResponse(result);
515
481
  });
516
482
  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.", {
517
- name: z6.string().describe("Subgraph name")
483
+ name: z5.string().describe("Subgraph name")
518
484
  }, async ({ name }) => {
519
485
  const result = await clientProvider().subgraphs.reindex(name);
520
486
  return jsonResponse(result);
521
487
  });
522
488
  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.", {
523
- name: z6.string().describe("Subgraph name"),
524
- fromBlock: z6.number().int().nonnegative().describe("Start block (inclusive)"),
525
- toBlock: z6.number().int().nonnegative().describe("End block (inclusive)")
489
+ name: z5.string().describe("Subgraph name"),
490
+ fromBlock: z5.number().int().nonnegative().describe("Start block (inclusive)"),
491
+ toBlock: z5.number().int().nonnegative().describe("End block (inclusive)")
526
492
  }, async ({ name, fromBlock, toBlock }) => {
527
493
  const result = await clientProvider().subgraphs.backfill(name, {
528
494
  fromBlock,
@@ -530,15 +496,15 @@ function registerSubgraphTools(server, clientProvider = getClient) {
530
496
  });
531
497
  return jsonResponse(result);
532
498
  });
533
- 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 }) => {
499
+ 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 }) => {
534
500
  const result = await clientProvider().subgraphs.stop(name);
535
501
  return jsonResponse(result);
536
502
  });
537
503
  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.", {
538
- name: z6.string().describe("Subgraph name"),
539
- limit: z6.number().int().positive().optional().describe("Max gaps to return"),
540
- offset: z6.number().int().nonnegative().optional().describe("Pagination offset"),
541
- resolved: z6.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
504
+ name: z5.string().describe("Subgraph name"),
505
+ limit: z5.number().int().positive().optional().describe("Max gaps to return"),
506
+ offset: z5.number().int().nonnegative().optional().describe("Pagination offset"),
507
+ resolved: z5.boolean().optional().describe("Filter by resolved state (omit for unresolved only)")
542
508
  }, async ({ name, limit, offset, resolved }) => {
543
509
  const result = await clientProvider().subgraphs.gaps(name, {
544
510
  limit,
@@ -547,16 +513,16 @@ function registerSubgraphTools(server, clientProvider = getClient) {
547
513
  });
548
514
  return jsonResponse(result);
549
515
  });
550
- defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z6.string().describe("Subgraph name") }, async ({ name }) => {
516
+ defineTool(server, "subgraphs_delete", "Delete a subgraph permanently.", { name: z5.string().describe("Subgraph name") }, async ({ name }) => {
551
517
  const result = await clientProvider().subgraphs.delete(name);
552
518
  return textResponse(result.message);
553
519
  });
554
520
  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.", {
555
- code: z6.string().describe("TypeScript source code containing a defineSubgraph() call"),
556
- startBlock: z6.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
557
- databaseUrl: z6.string().optional().describe("BYO data plane: Postgres connection string to host the subgraph's schema and rows in your own database"),
558
- dryRun: z6.boolean().optional().describe("Validate and preview the deploy (schema/DDL, BYO connection) without writing changes"),
559
- 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.")
521
+ code: z5.string().describe("TypeScript source code containing a defineSubgraph() call"),
522
+ startBlock: z5.number().int().nonnegative().optional().describe("Override the definition startBlock for this deploy"),
523
+ databaseUrl: z5.string().optional().describe("BYO data plane: Postgres connection string to host the subgraph's schema and rows in your own database"),
524
+ dryRun: z5.boolean().optional().describe("Validate and preview the deploy (schema/DDL, BYO connection) without writing changes"),
525
+ 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.")
560
526
  }, async ({ code, startBlock, databaseUrl, dryRun, visibility }) => {
561
527
  const bundled = await bundleSubgraphCode(code);
562
528
  try {
@@ -581,11 +547,11 @@ function registerSubgraphTools(server, clientProvider = getClient) {
581
547
  throw err;
582
548
  }
583
549
  });
584
- 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 }) => {
550
+ 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 }) => {
585
551
  const result = await clientProvider().subgraphs.publish(name);
586
552
  return jsonResponse(result);
587
553
  });
588
- 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 }) => {
554
+ 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 }) => {
589
555
  const result = await clientProvider().subgraphs.unpublish(name);
590
556
  return jsonResponse(result);
591
557
  });
@@ -593,38 +559,38 @@ function registerSubgraphTools(server, clientProvider = getClient) {
593
559
 
594
560
  // src/tools/subscriptions.ts
595
561
  import { CHAIN_TRIGGER_TYPES } from "@secondlayer/shared";
596
- import { z as z7 } from "zod";
562
+ import { z as z6 } from "zod";
597
563
  function registerSubscriptionTools(server, clientProvider = getClient) {
598
564
  defineTool(server, "subscriptions_list", "List all subscriptions for the current account. Returns summary fields (no secrets).", {}, async () => {
599
565
  const { data } = await clientProvider().subscriptions.list();
600
566
  return jsonResponse(data);
601
567
  });
602
- defineTool(server, "subscriptions_get", "Get full detail for a subscription (filter, auth, retry config, circuit state).", { id: z7.string().describe("Subscription id") }, async ({ id }) => {
568
+ defineTool(server, "subscriptions_get", "Get full detail for a subscription (filter, auth, retry config, circuit state).", { id: z6.string().describe("Subscription id") }, async ({ id }) => {
603
569
  const detail = await clientProvider().subscriptions.get(id);
604
570
  return jsonResponse(detail);
605
571
  });
606
572
  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.", {
607
- name: z7.string().describe("Human-readable name, unique per account"),
608
- subgraphName: z7.string().optional().describe("Subgraph to subscribe to (subgraph subscription)"),
609
- tableName: z7.string().optional().describe("Table within the subgraph (subgraph subscription)"),
610
- triggers: z7.array(z7.object({
611
- type: z7.enum(CHAIN_TRIGGER_TYPES),
612
- contractId: z7.string().optional(),
613
- functionName: z7.string().optional(),
614
- caller: z7.string().optional(),
615
- sender: z7.string().optional(),
616
- recipient: z7.string().optional(),
617
- assetIdentifier: z7.string().optional(),
618
- deployer: z7.string().optional(),
619
- contractName: z7.string().optional(),
620
- topic: z7.string().optional(),
621
- lockedAddress: z7.string().optional(),
622
- trait: z7.string().optional(),
623
- minAmount: z7.union([z7.string(), z7.number()]).optional(),
624
- maxAmount: z7.union([z7.string(), z7.number()]).optional()
573
+ name: z6.string().describe("Human-readable name, unique per account"),
574
+ subgraphName: z6.string().optional().describe("Subgraph to subscribe to (subgraph subscription)"),
575
+ tableName: z6.string().optional().describe("Table within the subgraph (subgraph subscription)"),
576
+ triggers: z6.array(z6.object({
577
+ type: z6.enum(CHAIN_TRIGGER_TYPES),
578
+ contractId: z6.string().optional(),
579
+ functionName: z6.string().optional(),
580
+ caller: z6.string().optional(),
581
+ sender: z6.string().optional(),
582
+ recipient: z6.string().optional(),
583
+ assetIdentifier: z6.string().optional(),
584
+ deployer: z6.string().optional(),
585
+ contractName: z6.string().optional(),
586
+ topic: z6.string().optional(),
587
+ lockedAddress: z6.string().optional(),
588
+ trait: z6.string().optional(),
589
+ minAmount: z6.union([z6.string(), z6.number()]).optional(),
590
+ maxAmount: z6.union([z6.string(), z6.number()]).optional()
625
591
  })).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."),
626
- url: z7.string().describe("Webhook URL"),
627
- format: z7.enum([
592
+ url: z6.string().describe("Webhook URL"),
593
+ format: z6.enum([
628
594
  "standard-webhooks",
629
595
  "inngest",
630
596
  "trigger",
@@ -632,20 +598,20 @@ function registerSubscriptionTools(server, clientProvider = getClient) {
632
598
  "cloudevents",
633
599
  "raw"
634
600
  ]).optional().describe("Wire format (default standard-webhooks)"),
635
- runtime: z7.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
636
- filter: z7.record(z7.string(), z7.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
637
- authConfig: z7.record(z7.string(), z7.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
601
+ runtime: z6.enum(["inngest", "trigger", "cloudflare", "node"]).optional().describe("Receiver runtime label (display only)"),
602
+ filter: z6.record(z6.string(), z6.unknown()).optional().describe('Scalar filter DSL, e.g. {"amount": {"gte": 100}, "sender": "SP..."}'),
603
+ authConfig: z6.record(z6.string(), z6.unknown()).optional().describe('Receiver auth sent with each delivery, e.g. {"type": "bearer", "token": "..."}')
638
604
  }, async (input) => {
639
605
  const res = await clientProvider().subscriptions.create(input);
640
606
  return jsonResponse(res);
641
607
  });
642
608
  defineTool(server, "subscriptions_update", "Patch a subscription (name, url, filter, authConfig, format, runtime, retry, timeout, concurrency).", {
643
- id: z7.string(),
644
- name: z7.string().optional().describe("Rename the subscription"),
645
- url: z7.string().optional(),
646
- filter: z7.record(z7.string(), z7.unknown()).optional(),
647
- authConfig: z7.record(z7.string(), z7.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
648
- format: z7.enum([
609
+ id: z6.string(),
610
+ name: z6.string().optional().describe("Rename the subscription"),
611
+ url: z6.string().optional(),
612
+ filter: z6.record(z6.string(), z6.unknown()).optional(),
613
+ authConfig: z6.record(z6.string(), z6.unknown()).optional().describe("Receiver auth sent with each delivery (bearer/etc.)"),
614
+ format: z6.enum([
649
615
  "standard-webhooks",
650
616
  "inngest",
651
617
  "trigger",
@@ -653,27 +619,27 @@ function registerSubscriptionTools(server, clientProvider = getClient) {
653
619
  "cloudevents",
654
620
  "raw"
655
621
  ]).optional(),
656
- runtime: z7.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
657
- maxRetries: z7.number().int().min(0).optional(),
658
- timeoutMs: z7.number().int().min(100).optional(),
659
- concurrency: z7.number().int().min(1).optional()
622
+ runtime: z6.enum(["inngest", "trigger", "cloudflare", "node"]).nullable().optional(),
623
+ maxRetries: z6.number().int().min(0).optional(),
624
+ timeoutMs: z6.number().int().min(100).optional(),
625
+ concurrency: z6.number().int().min(1).optional()
660
626
  }, async ({ id, ...patch }) => {
661
627
  const res = await clientProvider().subscriptions.update(id, patch);
662
628
  return jsonResponse(res);
663
629
  });
664
- defineTool(server, "subscriptions_delete", "Delete a subscription. Pending outbox rows are cascade-deleted.", { id: z7.string() }, async ({ id }) => {
630
+ defineTool(server, "subscriptions_delete", "Delete a subscription. Pending outbox rows are cascade-deleted.", { id: z6.string() }, async ({ id }) => {
665
631
  const res = await clientProvider().subscriptions.delete(id);
666
632
  return jsonResponse(res);
667
633
  });
668
- 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 }) => {
634
+ 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 }) => {
669
635
  const res = await clientProvider().subscriptions.test(id);
670
636
  return jsonResponse(res);
671
637
  });
672
638
  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.", {
673
- id: z7.string(),
674
- fromBlock: z7.number().int().nonnegative(),
675
- toBlock: z7.number().int().nonnegative(),
676
- force: z7.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
639
+ id: z6.string(),
640
+ fromBlock: z6.number().int().nonnegative(),
641
+ toBlock: z6.number().int().nonnegative(),
642
+ force: z6.string().optional().describe("Idempotency suffix to force a duplicate replay of the range")
677
643
  }, async ({ id, fromBlock, toBlock, force }) => {
678
644
  const res = await clientProvider().subscriptions.replay(id, {
679
645
  fromBlock,
@@ -695,7 +661,6 @@ function createServer() {
695
661
  registerScaffoldTools(server);
696
662
  registerSubgraphTools(server);
697
663
  registerSubscriptionTools(server);
698
- registerAccountTools(server);
699
664
  registerIndexTools(server);
700
665
  registerStreamsTools(server);
701
666
  registerContractTools(server);
@@ -709,5 +674,5 @@ var server = createServer();
709
674
  var transport = new StdioServerTransport;
710
675
  await server.connect(transport);
711
676
 
712
- //# debugId=C1C2366FC5BE60CA64756E2164756E21
677
+ //# debugId=E3771A06F85F470464756E2164756E21
713
678
  //# sourceMappingURL=bin.js.map