@aifinpay/mcp 2.0.0-rc.5 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -69
  3. package/bin/aifinpay-mcp.js +115 -67
  4. package/dist/api.d.ts +2 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +6 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/config.d.ts +17 -2
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +66 -11
  11. package/dist/config.js.map +1 -1
  12. package/dist/identity.d.ts +9 -0
  13. package/dist/identity.d.ts.map +1 -0
  14. package/dist/identity.js +81 -0
  15. package/dist/identity.js.map +1 -0
  16. package/dist/index.d.ts +3 -6
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +3 -6
  19. package/dist/index.js.map +1 -1
  20. package/dist/payment-state.d.ts +35 -0
  21. package/dist/payment-state.d.ts.map +1 -0
  22. package/dist/payment-state.js +127 -0
  23. package/dist/payment-state.js.map +1 -0
  24. package/dist/safe-fetch.d.ts.map +1 -1
  25. package/dist/safe-fetch.js +73 -19
  26. package/dist/safe-fetch.js.map +1 -1
  27. package/dist/server.d.ts +5 -15
  28. package/dist/server.d.ts.map +1 -1
  29. package/dist/server.js +127 -38
  30. package/dist/server.js.map +1 -1
  31. package/dist/tools/agent-address.d.ts.map +1 -1
  32. package/dist/tools/agent-address.js +5 -4
  33. package/dist/tools/agent-address.js.map +1 -1
  34. package/dist/tools/agent-history.d.ts +58 -0
  35. package/dist/tools/agent-history.d.ts.map +1 -0
  36. package/dist/tools/agent-history.js +141 -0
  37. package/dist/tools/agent-history.js.map +1 -0
  38. package/dist/tools/agent-quota.d.ts.map +1 -1
  39. package/dist/tools/agent-quota.js +3 -1
  40. package/dist/tools/agent-quota.js.map +1 -1
  41. package/dist/tools/{agent-quote.d.ts → dev-payment-quote.d.ts} +10 -12
  42. package/dist/tools/dev-payment-quote.d.ts.map +1 -0
  43. package/dist/tools/dev-payment-quote.js +80 -0
  44. package/dist/tools/dev-payment-quote.js.map +1 -0
  45. package/dist/tools/payable-fetch.d.ts +3 -29
  46. package/dist/tools/payable-fetch.d.ts.map +1 -1
  47. package/dist/tools/payable-fetch.js +231 -109
  48. package/dist/tools/payable-fetch.js.map +1 -1
  49. package/dist/tools/production-control.d.ts +104 -0
  50. package/dist/tools/production-control.d.ts.map +1 -1
  51. package/dist/tools/production-control.js +177 -14
  52. package/dist/tools/production-control.js.map +1 -1
  53. package/dist/tools/supported-chains.d.ts +38 -0
  54. package/dist/tools/supported-chains.d.ts.map +1 -0
  55. package/dist/tools/supported-chains.js +132 -0
  56. package/dist/tools/supported-chains.js.map +1 -0
  57. package/package.json +30 -7
  58. package/skills/SKILL.md +332 -0
  59. package/smithery.yaml +137 -0
  60. package/dist/directory.d.ts +0 -55
  61. package/dist/directory.d.ts.map +0 -1
  62. package/dist/directory.js +0 -56
  63. package/dist/directory.js.map +0 -1
  64. package/dist/tools/agent-call.d.ts +0 -68
  65. package/dist/tools/agent-call.d.ts.map +0 -1
  66. package/dist/tools/agent-call.js +0 -129
  67. package/dist/tools/agent-call.js.map +0 -1
  68. package/dist/tools/agent-claim-self.d.ts +0 -66
  69. package/dist/tools/agent-claim-self.d.ts.map +0 -1
  70. package/dist/tools/agent-claim-self.js +0 -299
  71. package/dist/tools/agent-claim-self.js.map +0 -1
  72. package/dist/tools/agent-quote.d.ts.map +0 -1
  73. package/dist/tools/agent-quote.js +0 -81
  74. package/dist/tools/agent-quote.js.map +0 -1
  75. package/dist/tools/pay-with-split.d.ts +0 -93
  76. package/dist/tools/pay-with-split.d.ts.map +0 -1
  77. package/dist/tools/pay-with-split.js +0 -138
  78. package/dist/tools/pay-with-split.js.map +0 -1
@@ -1,93 +0,0 @@
1
- import type { ToolContext } from "../server.js";
2
- export declare function payWithSplitTool(): {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- chain: {
9
- type: string;
10
- enum: string[];
11
- description: string;
12
- };
13
- merchant_wallet: {
14
- type: string;
15
- description: string;
16
- };
17
- merchant_amount: {
18
- type: string;
19
- description: string;
20
- };
21
- order_id: {
22
- type: string;
23
- description: string;
24
- };
25
- fee_recipient: {
26
- type: string;
27
- description: string;
28
- };
29
- };
30
- required: string[];
31
- };
32
- annotations: {
33
- readOnlyHint: boolean;
34
- openWorldHint: boolean;
35
- destructiveHint: boolean;
36
- };
37
- outputSchema: {
38
- type: string;
39
- };
40
- };
41
- export declare function runPayWithSplit(ctx: ToolContext, args: Record<string, unknown>): Promise<{
42
- isError: boolean;
43
- content: {
44
- type: string;
45
- text: string;
46
- }[];
47
- } | {
48
- content: {
49
- type: string;
50
- text: string;
51
- }[];
52
- structuredContent: Record<string, unknown>;
53
- }>;
54
- export declare function quoteSplitTool(): {
55
- name: string;
56
- description: string;
57
- inputSchema: {
58
- type: string;
59
- properties: {
60
- chain: {
61
- type: string;
62
- enum: string[];
63
- };
64
- merchant_amount: {
65
- type: string;
66
- description: string;
67
- };
68
- };
69
- required: string[];
70
- };
71
- annotations: {
72
- readOnlyHint: boolean;
73
- openWorldHint: boolean;
74
- destructiveHint: boolean;
75
- };
76
- outputSchema: {
77
- type: string;
78
- };
79
- };
80
- export declare function runQuoteSplit(ctx: ToolContext, args: Record<string, unknown>): Promise<{
81
- isError: boolean;
82
- content: {
83
- type: string;
84
- text: string;
85
- }[];
86
- } | {
87
- content: {
88
- type: string;
89
- text: string;
90
- }[];
91
- structuredContent: Record<string, unknown>;
92
- }>;
93
- //# sourceMappingURL=pay-with-split.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pay-with-split.d.ts","sourceRoot":"","sources":["../../src/tools/pay-with-split.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAahD,wBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8C/B;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAsC9B;AAED,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;EAuB7B;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAoB9B"}
@@ -1,138 +0,0 @@
1
- // NOTE on the chain enum below: pay_with_split and quote_split are
2
- // BACKEND-INVOICE-DRIVEN — they call the operator API
3
- // (POST /api/b2b/pay-with-split, GET /api/b2b/quote-split), which supports
4
- // solana + 6 on-chain-verified EVM chains (polygon, base, optimism,
5
- // unichain, botchain, xrplevm). Keep this enum in lockstep with the
6
- // backend's ../evm-chains.js registry — a chain listed here without
7
- // backend support would just be rejected server-side. Stables: USDC on
8
- // base/optimism/unichain, USDC+USDT on polygon; botchain/xrplevm are
9
- // native-token only. Direct (non-invoice) splitter settlement lives in
10
- // the SDK's AiFinPayAgent.call() (@aifinpay/agent >= 1.3.0).
11
- export function payWithSplitTool() {
12
- return {
13
- name: "pay_with_split",
14
- description: "Get on-chain instructions for a fee-on-top atomic 3-way payment. " +
15
- "The merchant receives the FULL quoted price; AiFinPay protocol fee " +
16
- "(1%) and creator/referral fee (0.01%) are added ON TOP. The agent " +
17
- "executes the returned instructions with their chain SDK of choice. " +
18
- "Returns 503 with onboarding message if the splitter is not yet " +
19
- "deployed on the requested chain.",
20
- inputSchema: {
21
- type: "object",
22
- properties: {
23
- chain: {
24
- type: "string",
25
- enum: ["solana", "polygon", "base", "optimism", "unichain", "botchain", "xrplevm"],
26
- description: "Chain to settle on.",
27
- },
28
- merchant_wallet: {
29
- type: "string",
30
- description: "Recipient — Solana base58 pubkey or Polygon 0x address.",
31
- },
32
- merchant_amount: {
33
- type: "string",
34
- description: "Merchant's quoted price in chain units (lamports for Solana, " +
35
- "wei for Polygon). Use a string to preserve precision.",
36
- },
37
- order_id: {
38
- type: "string",
39
- description: "Off-chain reference (max 64 chars).",
40
- },
41
- fee_recipient: {
42
- type: "string",
43
- description: "Optional — receives the IP-creator fee. Omit to route the " +
44
- "creator slot to AiFinPay treasury.",
45
- },
46
- },
47
- required: ["chain", "merchant_wallet", "merchant_amount", "order_id"],
48
- },
49
- // Returns on-chain instructions/invoice; does not itself broadcast funds.
50
- annotations: { readOnlyHint: false, openWorldHint: false, destructiveHint: false },
51
- outputSchema: { type: "object" },
52
- };
53
- }
54
- export async function runPayWithSplit(ctx, args) {
55
- const chain = args.chain;
56
- if (!chain || !["solana", "polygon", "base", "optimism", "unichain", "botchain", "xrplevm"].includes(chain)) {
57
- return errorResult("chain must be 'solana', 'polygon', 'base', 'optimism', 'unichain', 'botchain' or 'xrplevm'");
58
- }
59
- const merchantWallet = String(args.merchant_wallet ?? "");
60
- const merchantAmount = String(args.merchant_amount ?? "");
61
- const orderId = String(args.order_id ?? "");
62
- if (!merchantWallet || !merchantAmount || !orderId) {
63
- return errorResult("merchant_wallet, merchant_amount, and order_id are all required");
64
- }
65
- const feeRecipient = typeof args.fee_recipient === "string" && args.fee_recipient
66
- ? args.fee_recipient
67
- : undefined;
68
- try {
69
- const invoice = await ctx.agent.inner.payWithSplitInvoice({
70
- // published @aifinpay/agent (<=1.3.0) still types this "solana"|"polygon";
71
- // the value is forwarded verbatim to the backend, which accepts all 7.
72
- // Drop the cast once agent >=1.3.1 (widened types) is published.
73
- chain: chain,
74
- merchantWallet,
75
- merchantAmount,
76
- orderId,
77
- feeRecipient,
78
- });
79
- return {
80
- content: [{ type: "text", text: JSON.stringify(invoice, null, 2) }],
81
- structuredContent: invoice,
82
- };
83
- }
84
- catch (e) {
85
- const err = e;
86
- return errorResult(`${err.constructor.name}: ${err.message}`);
87
- }
88
- }
89
- export function quoteSplitTool() {
90
- return {
91
- name: "quote_split",
92
- description: "Pure-view: compute the fee-on-top breakdown (merchant + treasury + " +
93
- "creator + total) for a given merchant amount. No payment, no auth. " +
94
- "Use this BEFORE pay_with_split to decide whether the cost is " +
95
- "acceptable.",
96
- inputSchema: {
97
- type: "object",
98
- properties: {
99
- chain: { type: "string", enum: ["solana", "polygon", "base", "optimism", "unichain", "botchain", "xrplevm"] },
100
- merchant_amount: {
101
- type: "string",
102
- description: "Merchant's quoted price (lamports for Solana, wei for Polygon).",
103
- },
104
- },
105
- required: ["chain", "merchant_amount"],
106
- },
107
- annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
108
- outputSchema: { type: "object" },
109
- };
110
- }
111
- export async function runQuoteSplit(ctx, args) {
112
- const chain = args.chain;
113
- if (!chain || !["solana", "polygon", "base", "optimism", "unichain", "botchain", "xrplevm"].includes(chain)) {
114
- return errorResult("chain must be 'solana', 'polygon', 'base', 'optimism', 'unichain', 'botchain' or 'xrplevm'");
115
- }
116
- const merchantAmount = String(args.merchant_amount ?? "");
117
- if (!merchantAmount)
118
- return errorResult("merchant_amount required");
119
- try {
120
- // Same published-type lag as above — cast until agent >=1.3.1 ships.
121
- const quote = await ctx.agent.inner.quoteSplit({ chain: chain, merchantAmount });
122
- return {
123
- content: [{ type: "text", text: JSON.stringify(quote, null, 2) }],
124
- structuredContent: quote,
125
- };
126
- }
127
- catch (e) {
128
- const err = e;
129
- return errorResult(`${err.constructor.name}: ${err.message}`);
130
- }
131
- }
132
- function errorResult(...lines) {
133
- return {
134
- isError: true,
135
- content: lines.map((line) => ({ type: "text", text: line })),
136
- };
137
- }
138
- //# sourceMappingURL=pay-with-split.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pay-with-split.js","sourceRoot":"","sources":["../../src/tools/pay-with-split.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,sDAAsD;AACtD,2EAA2E;AAC3E,oEAAoE;AACpE,oEAAoE;AACpE,oEAAoE;AACpE,uEAAuE;AACvE,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAE7D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