@oobe-protocol-labs/sap-mcp-server 0.9.0 → 0.9.2

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.
Files changed (113) hide show
  1. package/.env.example +30 -0
  2. package/CHANGELOG.md +43 -2
  3. package/README.md +19 -2
  4. package/USER_DOCS/00_START_HERE.md +1 -0
  5. package/USER_DOCS/01_HOSTED_REMOTE_MCP.md +17 -3
  6. package/USER_DOCS/04_CLIENT_CONFIGS.md +3 -3
  7. package/USER_DOCS/05_SKILLS_AND_TOOLS.md +27 -3
  8. package/USER_DOCS/06_DESKTOP_GUI_WIZARD.md +5 -5
  9. package/USER_DOCS/07_SMITHERY_AND_MARKETPLACES.md +163 -0
  10. package/assets/logos/claude.png +0 -0
  11. package/assets/logos/codex.webp +0 -0
  12. package/assets/logos/hermes.png +0 -0
  13. package/assets/logos/openclaw.svg +22 -0
  14. package/config.schema.json +5 -0
  15. package/dist/config/env.d.ts +4 -0
  16. package/dist/config/env.d.ts.map +1 -1
  17. package/dist/config/env.js +3 -0
  18. package/dist/config/env.js.map +1 -1
  19. package/dist/core/constants.d.ts +6 -1
  20. package/dist/core/constants.d.ts.map +1 -1
  21. package/dist/core/constants.js +14 -1
  22. package/dist/core/constants.js.map +1 -1
  23. package/dist/payments/pricing.d.ts +1 -1
  24. package/dist/payments/pricing.d.ts.map +1 -1
  25. package/dist/payments/pricing.js +20 -3
  26. package/dist/payments/pricing.js.map +1 -1
  27. package/dist/policy/local-policy-engine.js +1 -1
  28. package/dist/policy/local-policy-engine.js.map +1 -1
  29. package/dist/prompts/context/sap-agent-context.prompt.js +6 -0
  30. package/dist/prompts/context/sap-agent-context.prompt.js.map +1 -1
  31. package/dist/prompts/context/sap-agent-start.prompt.d.ts +14 -0
  32. package/dist/prompts/context/sap-agent-start.prompt.d.ts.map +1 -0
  33. package/dist/prompts/context/sap-agent-start.prompt.js +96 -0
  34. package/dist/prompts/context/sap-agent-start.prompt.js.map +1 -0
  35. package/dist/prompts/developer/generate-sap-integration.prompt.js +1 -1
  36. package/dist/prompts/developer/generate-sap-integration.prompt.js.map +1 -1
  37. package/dist/prompts/payments/explain-x402-settlement.prompt.d.ts.map +1 -1
  38. package/dist/prompts/payments/explain-x402-settlement.prompt.js +13 -10
  39. package/dist/prompts/payments/explain-x402-settlement.prompt.js.map +1 -1
  40. package/dist/prompts/register-prompts.d.ts.map +1 -1
  41. package/dist/prompts/register-prompts.js +3 -1
  42. package/dist/prompts/register-prompts.js.map +1 -1
  43. package/dist/remote/public-home/index.d.ts.map +1 -1
  44. package/dist/remote/public-home/index.js +2 -1
  45. package/dist/remote/public-home/index.js.map +1 -1
  46. package/dist/remote/public-home/scripts.d.ts +1 -1
  47. package/dist/remote/public-home/scripts.d.ts.map +1 -1
  48. package/dist/remote/public-home/scripts.js +29 -0
  49. package/dist/remote/public-home/scripts.js.map +1 -1
  50. package/dist/remote/public-home/sections.d.ts +5 -0
  51. package/dist/remote/public-home/sections.d.ts.map +1 -1
  52. package/dist/remote/public-home/sections.js +73 -6
  53. package/dist/remote/public-home/sections.js.map +1 -1
  54. package/dist/remote/public-home/styles.d.ts +1 -1
  55. package/dist/remote/public-home/styles.d.ts.map +1 -1
  56. package/dist/remote/public-home/styles.js +460 -16
  57. package/dist/remote/public-home/styles.js.map +1 -1
  58. package/dist/remote/rate-limiter.d.ts +2 -0
  59. package/dist/remote/rate-limiter.d.ts.map +1 -1
  60. package/dist/remote/rate-limiter.js +23 -0
  61. package/dist/remote/rate-limiter.js.map +1 -1
  62. package/dist/remote/server.d.ts +70 -1
  63. package/dist/remote/server.d.ts.map +1 -1
  64. package/dist/remote/server.js +412 -15
  65. package/dist/remote/server.js.map +1 -1
  66. package/dist/runtime/module-resolution.d.ts.map +1 -1
  67. package/dist/runtime/module-resolution.js +41 -8
  68. package/dist/runtime/module-resolution.js.map +1 -1
  69. package/dist/schemas/settlement.schema.d.ts +2 -2
  70. package/dist/security/tool-permissions.d.ts.map +1 -1
  71. package/dist/security/tool-permissions.js +1 -6
  72. package/dist/security/tool-permissions.js.map +1 -1
  73. package/dist/server/create-server.d.ts.map +1 -1
  74. package/dist/server/create-server.js +2 -1
  75. package/dist/server/create-server.js.map +1 -1
  76. package/dist/tools/agent-start-tool.d.ts +12 -0
  77. package/dist/tools/agent-start-tool.d.ts.map +1 -0
  78. package/dist/tools/agent-start-tool.js +156 -0
  79. package/dist/tools/agent-start-tool.js.map +1 -0
  80. package/dist/tools/client-sdk-tools.d.ts +7 -0
  81. package/dist/tools/client-sdk-tools.d.ts.map +1 -1
  82. package/dist/tools/client-sdk-tools.js +80 -4
  83. package/dist/tools/client-sdk-tools.js.map +1 -1
  84. package/dist/tools/index.d.ts +1 -0
  85. package/dist/tools/index.d.ts.map +1 -1
  86. package/dist/tools/index.js +3 -1
  87. package/dist/tools/index.js.map +1 -1
  88. package/dist/tools/register-tools.d.ts.map +1 -1
  89. package/dist/tools/register-tools.js +5 -1
  90. package/dist/tools/register-tools.js.map +1 -1
  91. package/dist/tools/sap-sdk-tools.d.ts +2 -2
  92. package/dist/tools/sap-sdk-tools.d.ts.map +1 -1
  93. package/dist/tools/sap-sdk-tools.js +111 -108
  94. package/dist/tools/sap-sdk-tools.js.map +1 -1
  95. package/dist/tools/sap-sns-tools.d.ts +4 -4
  96. package/dist/tools/sap-sns-tools.js +4 -4
  97. package/dist/tools/skills-tools.js +1 -1
  98. package/dist/tools/skills-tools.js.map +1 -1
  99. package/docs/05_REMOTE_VPS_DEPLOYMENT.md +32 -0
  100. package/docs/06_PAYMENTS_X402_AND_PAYSH.md +11 -0
  101. package/docs/07_ENDPOINTS_AND_CLIENTS.md +1 -1
  102. package/docs/09_TOOLS_SKILLS_AND_AGENT_GUIDE.md +42 -11
  103. package/docs/14_DESKTOP_WIZARD_RELEASE.md +1 -1
  104. package/docs/README.md +6 -3
  105. package/docs/_sidebar.md +1 -0
  106. package/package.json +3 -2
  107. package/server.json +3 -3
  108. package/skills/README.md +2 -2
  109. package/skills/sap-escrow-settlement/SKILL.md +15 -11
  110. package/skills/sap-mcp/SKILL.md +26 -11
  111. package/skills/sap-mcp/TOOL_REFERENCE.md +6 -5
  112. package/skills/sap-operations/SKILL.md +6 -7
  113. package/smithery.config.schema.json +59 -0
@@ -2,7 +2,7 @@
2
2
  * SAP SDK MCP tools.
3
3
  *
4
4
  * This module intentionally wraps only methods that exist on
5
- * `@oobe-protocol-labs/synapse-sap-sdk@0.21.x`. It does not create local
5
+ * `@oobe-protocol-labs/synapse-sap-sdk@1.0.x`. It does not create local
6
6
  * facades for missing SDK namespaces and it does not fabricate network data.
7
7
  */
8
8
  import { PublicKey } from '@solana/web3.js';
@@ -13,6 +13,61 @@ import { createTextResponse } from '../adapters/mcp/tool-response.js';
13
13
  import { registerTool } from '../adapters/mcp/sdk-compat.js';
14
14
  import { getSapClient, isSapClientInitialized } from '../sap/sap-client-manager.js';
15
15
  import { logger } from '../core/logger.js';
16
+ const ESCROW_AMOUNT_DESCRIPTION = 'Amount in the escrow token smallest unit: lamports for SOL, micro-USDC for USDC, or base units for the configured SPL token.';
17
+ const ESCROW_V2_COSIGNED_MODE = 1;
18
+ const ESCROW_V2_DISPUTE_WINDOW_MODE = 2;
19
+ const DEFAULT_ESCROW_V2_DISPUTE_WINDOW_SLOTS = new BN(2160);
20
+ const escrowV2CreateInputSchema = {
21
+ agentWallet: {
22
+ type: 'string',
23
+ description: 'Agent owner wallet public key (base58). The V2 escrow PDA is derived from this wallet plus nonce.',
24
+ },
25
+ pricePerCall: {
26
+ type: 'string',
27
+ description: `Price per served call as a decimal string. ${ESCROW_AMOUNT_DESCRIPTION}`,
28
+ },
29
+ maxCalls: {
30
+ type: 'string',
31
+ description: 'Maximum number of calls covered by the escrow as a decimal string. Use 0 for unlimited when supported by policy.',
32
+ },
33
+ initialDeposit: {
34
+ type: 'string',
35
+ description: `Initial escrow deposit as a decimal string. ${ESCROW_AMOUNT_DESCRIPTION}`,
36
+ },
37
+ nonce: {
38
+ type: 'string',
39
+ description: 'Optional escrow nonce as a decimal string. Defaults to 0.',
40
+ },
41
+ expiresAt: {
42
+ type: 'string',
43
+ description: 'Optional expiry timestamp in unix seconds as a decimal string. Defaults to 0 (no expiry).',
44
+ },
45
+ tokenMint: {
46
+ type: 'string',
47
+ description: 'Optional SPL payment token mint. Omit/null for native SOL. Use EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v for mainnet USDC x402 escrows.',
48
+ },
49
+ tokenDecimals: {
50
+ type: 'number',
51
+ description: 'Payment token decimals. Defaults to 6 when tokenMint is set, otherwise 9 for native SOL.',
52
+ },
53
+ settlementSecurity: {
54
+ type: 'number',
55
+ enum: [1, 2],
56
+ description: 'V2 settlement security mode. 1=CoSigned (requires coSigner). 2=DisputeWindow (recommended default; requires disputeWindowSlots > 0). SelfReport/0 is deprecated and rejected on-chain.',
57
+ },
58
+ disputeWindowSlots: {
59
+ type: 'string',
60
+ description: 'Required positive dispute window in slots for settlementSecurity=2. Defaults to 2160 (~15 minutes).',
61
+ },
62
+ coSigner: {
63
+ type: 'string',
64
+ description: 'Required co-signer wallet public key when settlementSecurity=1 (CoSigned).',
65
+ },
66
+ arbiter: {
67
+ type: 'string',
68
+ description: 'Optional arbiter public key kept for IDL compatibility and dispute workflows.',
69
+ },
70
+ };
16
71
  /**
17
72
  * @name jsonReplacer
18
73
  * @description Serializes SDK values such as PublicKey, BN, bigint, Buffer, and Uint8Array into JSON-safe output.
@@ -436,24 +491,9 @@ function parseUpdateAgentArgs(input) {
436
491
  x402Endpoint: optionalString(input, 'x402Endpoint') ?? null,
437
492
  };
438
493
  }
439
- /**
440
- * @name parseEscrowArgs
441
- * @description Builds typed V1 escrow creation args from MCP JSON input.
442
- */
443
- function parseEscrowArgs(input) {
444
- return {
445
- pricePerCall: requiredBn(input, 'pricePerCall'),
446
- maxCalls: requiredBn(input, 'maxCalls'),
447
- initialDeposit: requiredBn(input, 'initialDeposit'),
448
- expiresAt: optionalBn(input, 'expiresAt', new BN(0)),
449
- volumeCurve: [],
450
- tokenMint: optionalPublicKey(input, 'tokenMint') ?? null,
451
- tokenDecimals: optionalNumber(input, 'tokenDecimals') ?? 9,
452
- };
453
- }
454
494
  /**
455
495
  * @name parseX402PreparePaymentOptions
456
- * @description Builds typed V1 x402 payment preparation options from MCP JSON input.
496
+ * @description Builds typed x402 payment preparation options from MCP JSON input.
457
497
  */
458
498
  function parseX402PreparePaymentOptions(input) {
459
499
  return {
@@ -465,6 +505,7 @@ function parseX402PreparePaymentOptions(input) {
465
505
  afterCalls: point.afterCalls,
466
506
  pricePerCall: point.pricePerCall,
467
507
  })),
508
+ nonce: optionalString(input, 'nonce'),
468
509
  tokenMint: optionalPublicKey(input, 'tokenMint') ?? null,
469
510
  tokenDecimals: optionalNumber(input, 'tokenDecimals'),
470
511
  networkIdentifier: optionalString(input, 'networkIdentifier'),
@@ -482,6 +523,7 @@ function parsePaymentContext(input) {
482
523
  depositorWallet: requiredPublicKey(input, 'depositorWallet'),
483
524
  pricePerCall: requiredBn(input, 'pricePerCall'),
484
525
  maxCalls: requiredBn(input, 'maxCalls'),
526
+ nonce: optionalBn(input, 'nonce', new BN(0)),
485
527
  txSignature: requiredString(input, 'txSignature'),
486
528
  networkIdentifier: requiredString(input, 'networkIdentifier'),
487
529
  };
@@ -535,6 +577,22 @@ function parseX402BatchSettlementEntries(value) {
535
577
  * @description Builds typed V2 escrow creation args from MCP JSON input.
536
578
  */
537
579
  function parseEscrowV2Args(input) {
580
+ const tokenMint = optionalPublicKey(input, 'tokenMint') ?? null;
581
+ const settlementSecurity = optionalNumber(input, 'settlementSecurity') ?? ESCROW_V2_DISPUTE_WINDOW_MODE;
582
+ if (settlementSecurity === 0) {
583
+ throw new Error('settlementSecurity=0 / SelfReport is deprecated and rejected by the current SAP program. Use 1 (CoSigned) or 2 (DisputeWindow).');
584
+ }
585
+ if (settlementSecurity !== ESCROW_V2_COSIGNED_MODE && settlementSecurity !== ESCROW_V2_DISPUTE_WINDOW_MODE) {
586
+ throw new Error('settlementSecurity must be 1 (CoSigned) or 2 (DisputeWindow).');
587
+ }
588
+ const coSigner = optionalPublicKey(input, 'coSigner') ?? null;
589
+ if (settlementSecurity === ESCROW_V2_COSIGNED_MODE && !coSigner) {
590
+ throw new Error('coSigner is required when settlementSecurity=1 (CoSigned).');
591
+ }
592
+ const disputeWindowSlots = optionalBn(input, 'disputeWindowSlots', settlementSecurity === ESCROW_V2_DISPUTE_WINDOW_MODE ? DEFAULT_ESCROW_V2_DISPUTE_WINDOW_SLOTS : new BN(0));
593
+ if (settlementSecurity === ESCROW_V2_DISPUTE_WINDOW_MODE && disputeWindowSlots.lte(new BN(0))) {
594
+ throw new Error('disputeWindowSlots must be positive when settlementSecurity=2 (DisputeWindow).');
595
+ }
538
596
  return {
539
597
  escrowNonce: optionalBn(input, 'nonce', new BN(0)),
540
598
  pricePerCall: requiredBn(input, 'pricePerCall'),
@@ -542,25 +600,14 @@ function parseEscrowV2Args(input) {
542
600
  initialDeposit: requiredBn(input, 'initialDeposit'),
543
601
  expiresAt: optionalBn(input, 'expiresAt', new BN(0)),
544
602
  volumeCurve: [],
545
- tokenMint: optionalPublicKey(input, 'tokenMint') ?? null,
546
- tokenDecimals: optionalNumber(input, 'tokenDecimals') ?? 9,
547
- settlementSecurity: optionalNumber(input, 'settlementSecurity') ?? 0,
548
- disputeWindowSlots: optionalBn(input, 'disputeWindowSlots', new BN(0)),
549
- coSigner: optionalPublicKey(input, 'coSigner') ?? null,
603
+ tokenMint,
604
+ tokenDecimals: optionalNumber(input, 'tokenDecimals') ?? (tokenMint ? 6 : 9),
605
+ settlementSecurity,
606
+ disputeWindowSlots,
607
+ coSigner,
550
608
  arbiter: optionalPublicKey(input, 'arbiter') ?? null,
551
609
  };
552
610
  }
553
- /**
554
- * @name parseSettlement
555
- * @description Builds typed V1 batch-settlement entries from MCP JSON input.
556
- */
557
- function parseSettlement(item) {
558
- const record = asRecord(item);
559
- return {
560
- callsToSettle: requiredBn(record, 'callsToSettle'),
561
- serviceHash: requiredBytes(record, 'serviceHash', 32),
562
- };
563
- }
564
611
  /**
565
612
  * @name parseFeedbackArgs
566
613
  * @description Builds typed feedback args from MCP JSON input.
@@ -817,7 +864,7 @@ const discoveryTools = [
817
864
  {
818
865
  name: 'sap_discover_agents',
819
866
  title: 'Discover SAP Agents',
820
- description: 'Discover agents by protocol, capability, or capability list. Unfiltered global listing is not exposed by SDK v0.20.',
867
+ description: 'Discover agents by protocol, capability, or capability list. For unfiltered global listing, use sap_list_all_agents.',
821
868
  inputSchema: {
822
869
  protocol: { type: 'string', description: 'Protocol identifier to filter agents by (e.g. "jupiter", "drift")' },
823
870
  capability: { type: 'string', description: 'Single capability ID to filter agents by (e.g. "jupiter:swap")' },
@@ -849,7 +896,7 @@ const discoveryTools = [
849
896
  count: 0,
850
897
  agents: [],
851
898
  overview: await client.discovery.getNetworkOverview(),
852
- note: 'SDK v0.20 exposes filtered discovery, not unfiltered global agent enumeration. Provide protocol or capability.',
899
+ note: 'SDK filtered discovery requires a protocol or capability. For global on-chain directory snapshots, call sap_list_all_agents.',
853
900
  };
854
901
  },
855
902
  },
@@ -1071,57 +1118,6 @@ const indexAndFetchTools = [
1071
1118
  },
1072
1119
  ];
1073
1120
  const paymentAndEscrowTools = [
1074
- {
1075
- name: 'sap_create_escrow',
1076
- title: 'Create SAP Escrow V1',
1077
- description: 'Create a V1 escrow using SDK EscrowModule.create.',
1078
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in lamports (as a decimal string)' }, maxCalls: { type: 'string', description: 'Maximum number of calls the escrow covers (as a decimal string)' }, initialDeposit: { type: 'string', description: 'Initial deposit amount in lamports (as a decimal string)' } },
1079
- handler: async (input, client) => ({ signature: await client.escrow.create(requiredPublicKey(input, 'agentWallet'), parseEscrowArgs(input)) }),
1080
- },
1081
- {
1082
- name: 'sap_deposit_escrow',
1083
- title: 'Deposit SAP Escrow V1',
1084
- description: 'Deposit funds into a V1 escrow.',
1085
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, amount: { type: 'string', description: 'Deposit amount in lamports (as a decimal string)' } },
1086
- handler: async (input, client) => ({ signature: await client.escrow.deposit(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'amount')) }),
1087
- },
1088
- {
1089
- name: 'sap_settle_escrow',
1090
- title: 'Settle SAP Escrow V1',
1091
- description: 'Settle calls against a V1 escrow.',
1092
- inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, callsToSettle: { type: 'string', description: 'Number of calls to settle (as a decimal string)' }, serviceHash: { type: 'array', description: '32-byte service hash as a byte array, hex string, or base64 string' } },
1093
- handler: async (input, client) => ({
1094
- signature: await client.escrow.settle(requiredPublicKey(input, 'depositorWallet'), requiredBn(input, 'callsToSettle'), requiredBytes(input, 'serviceHash', 32)),
1095
- }),
1096
- },
1097
- {
1098
- name: 'sap_settle_escrow_batch',
1099
- title: 'Batch Settle SAP Escrow V1',
1100
- description: 'Batch settle V1 escrow entries using SDK EscrowModule.settleBatch.',
1101
- inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, settlements: { type: 'array', description: 'Array of settlement objects, each containing callsToSettle (string) and serviceHash (32-byte array)' }, batchRoot: { type: 'array', description: 'Optional 32-byte Merkle root for batch verification' } },
1102
- handler: async (input, client) => {
1103
- if (!Array.isArray(input.settlements)) {
1104
- throw new Error('settlements must be an array');
1105
- }
1106
- return {
1107
- signature: await client.escrow.settleBatch(requiredPublicKey(input, 'depositorWallet'), input.settlements.map(parseSettlement), input.batchRoot === undefined ? null : requiredBytes(input, 'batchRoot', 32)),
1108
- };
1109
- },
1110
- },
1111
- {
1112
- name: 'sap_withdraw_escrow',
1113
- title: 'Withdraw SAP Escrow V1',
1114
- description: 'Withdraw funds from a V1 escrow.',
1115
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, amount: { type: 'string', description: 'Withdrawal amount in lamports (as a decimal string)' } },
1116
- handler: async (input, client) => ({ signature: await client.escrow.withdraw(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'amount')) }),
1117
- },
1118
- {
1119
- name: 'sap_close_escrow',
1120
- title: 'Close SAP Escrow V1',
1121
- description: 'Close an empty V1 escrow.',
1122
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' } },
1123
- handler: async (input, client) => ({ signature: await client.escrow.close(requiredPublicKey(input, 'agentWallet')) }),
1124
- },
1125
1121
  {
1126
1122
  name: 'sap_x402_estimate_cost',
1127
1123
  title: 'Estimate SAP x402 Cost',
@@ -1157,9 +1153,9 @@ const paymentAndEscrowTools = [
1157
1153
  },
1158
1154
  {
1159
1155
  name: 'sap_x402_prepare_payment',
1160
- title: 'Prepare SAP x402 Payment V1 Deprecated',
1161
- description: 'Prepare a V1 x402 payment context using SDK X402Registry.preparePayment. Deprecated by the SDK for production escrow creation; prefer Escrow V2 tools for new flows.',
1162
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call as a decimal string' }, deposit: { type: 'string', description: 'Initial deposit amount as a decimal string' }, maxCalls: { type: 'string', description: 'Optional maximum number of calls covered' }, expiresAt: { type: 'string', description: 'Optional expiry timestamp in unix seconds' }, volumeCurve: { type: 'array', description: 'Optional array of { afterCalls, pricePerCall } pricing breakpoints' }, tokenMint: { type: 'string', description: 'Optional SPL token mint; omit/null for SOL' }, tokenDecimals: { type: 'number', description: 'Optional token decimals' }, networkIdentifier: { type: 'string', description: 'Optional x402 network identifier written into headers' } },
1156
+ title: 'Prepare SAP x402 Payment',
1157
+ description: 'Prepare an x402 payment context using SDK X402Registry.preparePayment. New production escrow funding should use Escrow V2 fields and nonce-aware flows.',
1158
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: `Price per call as a decimal string. ${ESCROW_AMOUNT_DESCRIPTION}` }, deposit: { type: 'string', description: `Initial deposit as a decimal string. ${ESCROW_AMOUNT_DESCRIPTION}` }, maxCalls: { type: 'string', description: 'Optional maximum number of calls covered' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' }, expiresAt: { type: 'string', description: 'Optional expiry timestamp in unix seconds' }, volumeCurve: { type: 'array', description: 'Optional array of { afterCalls, pricePerCall } pricing breakpoints' }, tokenMint: { type: 'string', description: 'Optional SPL token mint; omit/null for SOL. Use EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v for mainnet USDC.' }, tokenDecimals: { type: 'number', description: 'Optional token decimals. Defaults to 6 for USDC/SPL flows when supplied by the SDK and 9 for native SOL.' }, networkIdentifier: { type: 'string', description: 'Optional x402 network identifier written into headers' } },
1163
1159
  handler: async (input, client) => ({
1164
1160
  payment: await client.x402.preparePayment(requiredPublicKey(input, 'agentWallet'), parseX402PreparePaymentOptions(input)),
1165
1161
  }),
@@ -1168,7 +1164,7 @@ const paymentAndEscrowTools = [
1168
1164
  name: 'sap_x402_build_payment_headers',
1169
1165
  title: 'Build SAP x402 Payment Headers',
1170
1166
  description: 'Build SAP x402 HTTP headers from a public PaymentContext returned by sap_x402_prepare_payment.',
1171
- inputSchema: { escrowPda: { type: 'string', description: 'Escrow PDA (base58)' }, agentPda: { type: 'string', description: 'Agent PDA (base58)' }, agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in token base units' }, maxCalls: { type: 'string', description: 'Max calls as a decimal string' }, txSignature: { type: 'string', description: 'Escrow creation transaction signature' }, networkIdentifier: { type: 'string', description: 'x402 network identifier stored in the payment context' }, network: { type: 'string', description: 'Optional override for X-Payment-Network' } },
1167
+ inputSchema: { escrowPda: { type: 'string', description: 'Escrow PDA (base58)' }, agentPda: { type: 'string', description: 'Agent PDA (base58)' }, agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in token base units' }, maxCalls: { type: 'string', description: 'Max calls as a decimal string' }, nonce: { type: 'string', description: 'Escrow nonce as a decimal string. Defaults to 0.' }, txSignature: { type: 'string', description: 'Escrow creation transaction signature' }, networkIdentifier: { type: 'string', description: 'x402 network identifier stored in the payment context' }, network: { type: 'string', description: 'Optional override for X-Payment-Network' } },
1172
1168
  handler: async (input, client) => ({
1173
1169
  headers: client.x402.buildPaymentHeaders(parsePaymentContext(input), { network: optionalString(input, 'network') }),
1174
1170
  }),
@@ -1177,9 +1173,10 @@ const paymentAndEscrowTools = [
1177
1173
  name: 'sap_x402_build_headers_from_escrow',
1178
1174
  title: 'Build SAP x402 Headers From Escrow',
1179
1175
  description: 'Build SAP x402 HTTP headers by fetching escrow data for an agent wallet with SDK X402Registry.buildPaymentHeadersFromEscrow.',
1180
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, network: { type: 'string', description: 'Optional network identifier for X-Payment-Network' } },
1176
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' }, network: { type: 'string', description: 'Optional network identifier for X-Payment-Network' } },
1181
1177
  handler: async (input, client) => ({
1182
1178
  headers: await client.x402.buildPaymentHeadersFromEscrow(requiredPublicKey(input, 'agentWallet'), {
1179
+ nonce: optionalString(input, 'nonce'),
1183
1180
  network: optionalString(input, 'network'),
1184
1181
  }),
1185
1182
  }),
@@ -1188,39 +1185,45 @@ const paymentAndEscrowTools = [
1188
1185
  name: 'sap_x402_has_escrow',
1189
1186
  title: 'Check SAP x402 Escrow',
1190
1187
  description: 'Check whether an x402 escrow exists for an agent/depositor pair.',
1191
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58); defaults to caller in SDK' } },
1192
- handler: async (input, client) => ({ exists: await client.x402.hasEscrow(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor')) }),
1188
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58); defaults to caller in SDK' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' } },
1189
+ handler: async (input, client) => ({ exists: await client.x402.hasEscrow(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor'), { nonce: optionalString(input, 'nonce') }) }),
1193
1190
  },
1194
1191
  {
1195
1192
  name: 'sap_x402_fetch_escrow',
1196
1193
  title: 'Fetch SAP x402 Escrow',
1197
1194
  description: 'Fetch raw x402 escrow account data using SDK X402Registry.fetchEscrow. Resolves V2 first, then V1 fallback.',
1198
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58); defaults to caller in SDK' } },
1199
- handler: async (input, client) => ({ escrow: await client.x402.fetchEscrow(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor')) }),
1195
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58); defaults to caller in SDK' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' } },
1196
+ handler: async (input, client) => ({ escrow: await client.x402.fetchEscrow(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor'), { nonce: optionalString(input, 'nonce') }) }),
1200
1197
  },
1201
1198
  {
1202
1199
  name: 'sap_x402_get_balance',
1203
1200
  title: 'Get SAP x402 Balance',
1204
1201
  description: 'Fetch x402 escrow balance using SDK X402Registry.getBalance.',
1205
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58) to filter balance by' } },
1206
- handler: async (input, client) => ({ balance: await client.x402.getBalance(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor')) }),
1202
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58) to filter balance by' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' } },
1203
+ handler: async (input, client) => ({ balance: await client.x402.getBalance(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor'), { nonce: optionalString(input, 'nonce') }) }),
1207
1204
  },
1208
1205
  {
1209
1206
  name: 'sap_x402_settle',
1210
1207
  title: 'Settle SAP x402 Calls',
1211
1208
  description: 'Settle served x402 calls through SDK X402Registry.settle. Must be called by the agent owner wallet.',
1212
- inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, callsToSettle: { type: 'number', description: 'Number of calls to settle' }, serviceData: { type: 'string', description: 'Service data to hash into the settlement proof' }, priorityFeeMicroLamports: { type: 'number', description: 'Optional priority fee in microlamports per compute unit' }, computeUnits: { type: 'number', description: 'Optional compute-unit limit' }, skipPreflight: { type: 'boolean', description: 'Optional skip preflight flag' }, commitment: { type: 'string', description: 'Optional processed|confirmed|finalized commitment' }, maxRetries: { type: 'number', description: 'Optional RPC retry limit' } },
1209
+ inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' }, callsToSettle: { type: 'number', description: 'Number of calls to settle' }, serviceData: { type: 'string', description: 'Service data to hash into the settlement proof' }, priorityFeeMicroLamports: { type: 'number', description: 'Optional priority fee in microlamports per compute unit' }, computeUnits: { type: 'number', description: 'Optional compute-unit limit' }, skipPreflight: { type: 'boolean', description: 'Optional skip preflight flag' }, commitment: { type: 'string', description: 'Optional processed|confirmed|finalized commitment' }, maxRetries: { type: 'number', description: 'Optional RPC retry limit' } },
1213
1210
  handler: async (input, client) => ({
1214
- settlement: await client.x402.settle(requiredPublicKey(input, 'depositorWallet'), requiredNumber(input, 'callsToSettle'), requiredString(input, 'serviceData'), parseSettleOptions(input)),
1211
+ settlement: await client.x402.settle(requiredPublicKey(input, 'depositorWallet'), requiredNumber(input, 'callsToSettle'), requiredString(input, 'serviceData'), {
1212
+ ...(parseSettleOptions(input) ?? {}),
1213
+ ...(optionalString(input, 'nonce') ? { nonce: optionalString(input, 'nonce') } : {}),
1214
+ }),
1215
1215
  }),
1216
1216
  },
1217
1217
  {
1218
1218
  name: 'sap_x402_settle_batch',
1219
1219
  title: 'Batch Settle SAP x402 Calls',
1220
1220
  description: 'Batch-settle served x402 calls through SDK X402Registry.settleBatch. Must be called by the agent owner wallet.',
1221
- inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, entries: { type: 'array', description: 'Array of { calls, serviceData } settlement entries' }, priorityFeeMicroLamports: { type: 'number', description: 'Optional priority fee in microlamports per compute unit' }, computeUnits: { type: 'number', description: 'Optional compute-unit limit' }, skipPreflight: { type: 'boolean', description: 'Optional skip preflight flag' }, commitment: { type: 'string', description: 'Optional processed|confirmed|finalized commitment' }, maxRetries: { type: 'number', description: 'Optional RPC retry limit' } },
1221
+ inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, nonce: { type: 'string', description: 'Optional escrow nonce as a decimal string. Defaults to 0.' }, entries: { type: 'array', description: 'Array of { calls, serviceData } settlement entries' }, priorityFeeMicroLamports: { type: 'number', description: 'Optional priority fee in microlamports per compute unit' }, computeUnits: { type: 'number', description: 'Optional compute-unit limit' }, skipPreflight: { type: 'boolean', description: 'Optional skip preflight flag' }, commitment: { type: 'string', description: 'Optional processed|confirmed|finalized commitment' }, maxRetries: { type: 'number', description: 'Optional RPC retry limit' } },
1222
1222
  handler: async (input, client) => ({
1223
- settlement: await client.x402.settleBatch(requiredPublicKey(input, 'depositorWallet'), parseX402BatchSettlementEntries(input.entries), parseSettleOptions(input)),
1223
+ settlement: await client.x402.settleBatch(requiredPublicKey(input, 'depositorWallet'), parseX402BatchSettlementEntries(input.entries), {
1224
+ ...(parseSettleOptions(input) ?? {}),
1225
+ ...(optionalString(input, 'nonce') ? { nonce: optionalString(input, 'nonce') } : {}),
1226
+ }),
1224
1227
  }),
1225
1228
  },
1226
1229
  ];
@@ -1228,15 +1231,15 @@ const escrowV2Tools = [
1228
1231
  {
1229
1232
  name: 'sap_create_escrow_v2',
1230
1233
  title: 'Create SAP Escrow V2',
1231
- description: 'Create a V2 escrow using SDK EscrowV2Module.create.',
1232
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in lamports (as a decimal string)' }, maxCalls: { type: 'string', description: 'Maximum number of calls the escrow covers (as a decimal string)' }, initialDeposit: { type: 'string', description: 'Initial deposit amount in lamports (as a decimal string)' } },
1234
+ description: 'Create a V2 escrow using SDK EscrowV2Module.create. Defaults to DisputeWindow settlementSecurity=2; SelfReport/0 is rejected.',
1235
+ inputSchema: escrowV2CreateInputSchema,
1233
1236
  handler: async (input, client) => ({ signature: await client.escrowV2.create(requiredPublicKey(input, 'agentWallet'), parseEscrowV2Args(input)) }),
1234
1237
  },
1235
1238
  {
1236
1239
  name: 'sap_deposit_escrow_v2',
1237
1240
  title: 'Deposit SAP Escrow V2',
1238
1241
  description: 'Deposit funds into a V2 escrow.',
1239
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, amount: { type: 'string', description: 'Deposit amount in lamports (as a decimal string)' } },
1242
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, amount: { type: 'string', description: `Deposit amount as a decimal string. ${ESCROW_AMOUNT_DESCRIPTION}` } },
1240
1243
  handler: async (input, client) => ({ signature: await client.escrowV2.deposit(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'amount')) }),
1241
1244
  },
1242
1245
  {
@@ -1270,16 +1273,16 @@ const escrowV2Tools = [
1270
1273
  name: 'sap_file_dispute_v2',
1271
1274
  title: 'File SAP Escrow V2 Dispute',
1272
1275
  description: 'File a dispute for a V2 pending settlement.',
1273
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, settlementIndex: { type: 'string', description: 'Settlement index to dispute (as a decimal string)' }, evidenceHash: { type: 'array', description: '32-byte evidence hash as a byte array, hex string, or base64 string' }, disputeType: { type: 'number', description: 'Optional dispute type identifier (numeric)' } },
1276
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, settlementIndex: { type: 'string', description: 'Settlement index to dispute (as a decimal string)' }, evidenceHash: { type: 'array', description: '32-byte evidence hash as a byte array, hex string, or base64 string' } },
1274
1277
  handler: async (input, client) => ({
1275
- signature: await client.escrowV2.fileDispute(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'settlementIndex'), requiredBytes(input, 'evidenceHash', 32), optionalNumber(input, 'disputeType')),
1278
+ signature: await client.escrowV2.fileDispute(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'settlementIndex'), requiredBytes(input, 'evidenceHash', 32)),
1276
1279
  }),
1277
1280
  },
1278
1281
  {
1279
1282
  name: 'sap_withdraw_escrow_v2',
1280
1283
  title: 'Withdraw SAP Escrow V2',
1281
1284
  description: 'Withdraw funds from a V2 escrow.',
1282
- inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, amount: { type: 'string', description: 'Withdrawal amount in lamports (as a decimal string)' } },
1285
+ inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, amount: { type: 'string', description: `Withdrawal amount as a decimal string. ${ESCROW_AMOUNT_DESCRIPTION}` } },
1283
1286
  handler: async (input, client) => ({ signature: await client.escrowV2.withdraw(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'amount')) }),
1284
1287
  },
1285
1288
  {
@@ -1527,7 +1530,7 @@ const sapToolGroups = [
1527
1530
  ];
1528
1531
  /**
1529
1532
  * @name registerSapSdkTools
1530
- * @description Registers production SAP SDK-backed tools using the public SDK v0.20 client surface.
1533
+ * @description Registers production SAP SDK-backed tools using the current public SDK v1.0.x client surface.
1531
1534
  */
1532
1535
  export function registerSapSdkTools(server, _context) {
1533
1536
  logger.debug('Registering SAP SDK tools');