@aifinpay/mcp 1.5.3 → 2.0.0-rc.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/README.md +11 -15
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +46 -0
- package/dist/config.js.map +1 -1
- package/dist/safe-fetch.d.ts +2 -0
- package/dist/safe-fetch.d.ts.map +1 -1
- package/dist/safe-fetch.js +21 -1
- package/dist/safe-fetch.js.map +1 -1
- package/dist/server.d.ts +10 -7
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +43 -81
- package/dist/server.js.map +1 -1
- package/dist/tools/agent-address.d.ts.map +1 -1
- package/dist/tools/agent-address.js +6 -27
- package/dist/tools/agent-address.js.map +1 -1
- package/dist/tools/agent-quota.d.ts +40 -0
- package/dist/tools/agent-quota.d.ts.map +1 -0
- package/dist/tools/agent-quota.js +95 -0
- package/dist/tools/agent-quota.js.map +1 -0
- package/dist/tools/production-control.d.ts +108 -0
- package/dist/tools/production-control.d.ts.map +1 -0
- package/dist/tools/production-control.js +131 -0
- package/dist/tools/production-control.js.map +1 -0
- package/package.json +5 -20
package/README.md
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
# @aifinpay/mcp
|
|
2
2
|
|
|
3
|
-
MCP server exposing AiFinPay
|
|
4
|
-
agent
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
and XRPL EVM (native-token path), while the MCP `pay_with_split` /
|
|
12
|
-
`quote_split` tools stay Polygon + Solana (backend invoice flow). The
|
|
13
|
-
protocol itself is live across 13 networks — see
|
|
14
|
-
[aifinpay.io/llms.txt](https://aifinpay.io/llms.txt).
|
|
3
|
+
MCP server exposing AiFinPay payment and quote primitives to MCP-aware
|
|
4
|
+
agent runtimes. Canonical domain: **aifinpay.io**.
|
|
5
|
+
|
|
6
|
+
AIFP-1 is gross-inclusive: payer total equals the quote, merchant receives 99%,
|
|
7
|
+
AiFinPay receives 1%, creator/referral receives 0%. AIFP-2/x402 currently
|
|
8
|
+
charges 0% at the protocol layer. Fund-moving paths fail closed until the exact
|
|
9
|
+
deployment, runtime hash, governance profile, merchant target, asset and paid
|
|
10
|
+
E2E evidence are verified.
|
|
15
11
|
|
|
16
12
|
## Tools
|
|
17
13
|
|
|
@@ -21,8 +17,8 @@ protocol itself is live across 13 networks — see
|
|
|
21
17
|
| `agent_address()` | Return the agent's funding addresses on **both** chains — Polygon `0x…` (default settlement: io.net, Exa, Venice bridges) and Solana base58 (Seat PDA / leaderboard). One seed, two chains — fund either. |
|
|
22
18
|
| `agent_quote(url)` | Inspect a 402 challenge without paying. Shows the merchant's quoted amount + facilitator flavor. |
|
|
23
19
|
| `agent_call(provider, …)` | Call a live provider from the AiFinPay directory (io.net, Exa, Venice, …) with automatic payment. |
|
|
24
|
-
| `pay_with_split(
|
|
25
|
-
| `quote_split(
|
|
20
|
+
| `pay_with_split(…)` | Retired compatibility tool. Returns `legacy_split_route_retired`; never creates an invoice or moves funds. |
|
|
21
|
+
| `quote_split(…)` | Retired compatibility tool. Use a canonical AIFP-1 quote. |
|
|
26
22
|
| `agent_claim_self(magic_link_url)` | Link this agent to your dashboard account via a one-shot magic link from `aifinpay.io/login` — spend history shows up in the dashboard. |
|
|
27
23
|
|
|
28
24
|
## Install
|
|
@@ -77,7 +73,7 @@ agent identity (and any funded Seat) persists across restarts.
|
|
|
77
73
|
| `AIFINPAY_AGENT_SECRET` | — | Base58 secret. If absent → ephemeral agent printed to stderr. |
|
|
78
74
|
| `AIFINPAY_BASE_URL` | `https://aifinpay.io` | Backend URL for nonce + funding probes. |
|
|
79
75
|
| `AIFINPAY_TIMEOUT_MS` | `30000` | Request timeout. |
|
|
80
|
-
| `AIFINPAY_MAX_USD` | — |
|
|
76
|
+
| `AIFINPAY_MAX_USD` | — | Mandatory positive finite operator ceiling for any fund-moving tool. |
|
|
81
77
|
|
|
82
78
|
## Programmatic use
|
|
83
79
|
|
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,30 @@ export interface McpConfig {
|
|
|
9
9
|
timeoutMs?: number;
|
|
10
10
|
/** Hard cap on a single payment to prevent runaway agents. */
|
|
11
11
|
maxAmountUsd?: number;
|
|
12
|
+
/** Gateway origins this agent may settle against.
|
|
13
|
+
*
|
|
14
|
+
* The SDK has always supported this (parseGatewayUrl in @aifinpay/agent) and
|
|
15
|
+
* this wrapper never exposed it, so a self-hosted merchant was unreachable:
|
|
16
|
+
* payable_fetch reached the 402 and then refused with "dev.ratersapp.com is
|
|
17
|
+
* not a known AiFinPay gateway; allowed: https://gateway.aifinpay.io".
|
|
18
|
+
* Observed in an external E2E run on 2026-08-27.
|
|
19
|
+
*
|
|
20
|
+
* Set by the OPERATOR, exact origins only, never a wildcard. The refusal it
|
|
21
|
+
* relaxes is not paranoia: a 402 is unauthenticated, so paying an
|
|
22
|
+
* unrecognised host means paying whoever answered. Naming a host here is a
|
|
23
|
+
* statement that you know who that is. */
|
|
24
|
+
gatewayOrigins?: string[];
|
|
25
|
+
/** Hosts whose DNS pre-check is skipped, exact names only.
|
|
26
|
+
*
|
|
27
|
+
* safe-fetch resolves a hostname and refuses if any answer is a private
|
|
28
|
+
* address — an SSRF guard. Behind an HTTP proxy the client cannot resolve at
|
|
29
|
+
* all (getaddrinfo EAI_AGAIN), so every host is refused for the wrong reason.
|
|
30
|
+
*
|
|
31
|
+
* This is deliberately NOT a proxy-detection switch that disables the check
|
|
32
|
+
* globally: that would turn one environment quirk into a blanket SSRF
|
|
33
|
+
* bypass. An operator names the hosts they vouch for, one at a time, and the
|
|
34
|
+
* guard stays on for everything else. */
|
|
35
|
+
trustedHosts?: string[];
|
|
12
36
|
/** Optional log destination (defaults to stderr). */
|
|
13
37
|
logFn?: (level: "info" | "warn" | "error", msg: string) => void;
|
|
14
38
|
}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB;kFAC8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qDAAqD;IACrD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,iBAAiB,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB;kFAC8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;+CAW2C;IAC3C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;;;;;;;;8CAS0C;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,qDAAqD;IACrD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,iBAAiB,IAAI,SAAS,CAa7C"}
|
package/dist/config.js
CHANGED
|
@@ -8,6 +8,52 @@ export function loadConfigFromEnv() {
|
|
|
8
8
|
maxAmountUsd: process.env.AIFINPAY_MAX_USD
|
|
9
9
|
? Number(process.env.AIFINPAY_MAX_USD)
|
|
10
10
|
: undefined,
|
|
11
|
+
gatewayOrigins: splitOrigins(process.env.AIFINPAY_GATEWAY_ORIGINS),
|
|
12
|
+
trustedHosts: splitList(process.env.AIFINPAY_TRUSTED_HOSTS),
|
|
11
13
|
};
|
|
12
14
|
}
|
|
15
|
+
/** Comma-separated list → trimmed entries, or undefined when unset/empty.
|
|
16
|
+
* Undefined and [] mean different things downstream: undefined keeps the SDK
|
|
17
|
+
* default, [] would mean "no origin is payable". An operator who sets the
|
|
18
|
+
* variable to an empty string means the former. */
|
|
19
|
+
function splitList(raw) {
|
|
20
|
+
if (!raw)
|
|
21
|
+
return undefined;
|
|
22
|
+
const out = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
23
|
+
return out.length ? out : undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Same, but each entry must be a bare https origin.
|
|
26
|
+
* A path or a wildcard here would read as allowed and match nothing, which is
|
|
27
|
+
* the failure that looks like the feature is broken rather than misconfigured. */
|
|
28
|
+
function splitOrigins(raw) {
|
|
29
|
+
const list = splitList(raw);
|
|
30
|
+
if (!list)
|
|
31
|
+
return undefined;
|
|
32
|
+
for (const entry of list) {
|
|
33
|
+
let u;
|
|
34
|
+
try {
|
|
35
|
+
u = new URL(entry);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new Error(`AIFINPAY_GATEWAY_ORIGINS: "${entry}" is not a URL`);
|
|
39
|
+
}
|
|
40
|
+
if (u.origin !== entry.replace(/\/+$/, "")) {
|
|
41
|
+
throw new Error(`AIFINPAY_GATEWAY_ORIGINS: "${entry}" must be a bare origin like https://dev.example.com `
|
|
42
|
+
+ `(got path/query "${u.pathname}${u.search}")`);
|
|
43
|
+
}
|
|
44
|
+
// WHATWG URL accepts "*" in a hostname, so new URL("https://*.example.com")
|
|
45
|
+
// parses and its origin round-trips — the entry would be stored, matched
|
|
46
|
+
// against nothing, and read as "I allowed this host". Rejecting it here is
|
|
47
|
+
// the difference between a misconfiguration that says so and one that looks
|
|
48
|
+
// like the feature is broken.
|
|
49
|
+
if (!/^[a-z0-9.-]+$/i.test(u.hostname) || u.hostname.startsWith("-") || u.hostname.includes("..")) {
|
|
50
|
+
throw new Error(`AIFINPAY_GATEWAY_ORIGINS: "${entry}" is not a plain hostname. `
|
|
51
|
+
+ `Wildcards are not supported — name each origin you settle against.`);
|
|
52
|
+
}
|
|
53
|
+
if (u.protocol !== "https:" && u.hostname !== "localhost" && u.hostname !== "127.0.0.1") {
|
|
54
|
+
throw new Error(`AIFINPAY_GATEWAY_ORIGINS: "${entry}" is not https — refusing to settle over plaintext`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return list;
|
|
58
|
+
}
|
|
13
59
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA6CA,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,SAAS;QAC9D,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS;QACnD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;YACxC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;YACzC,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;YACxC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;YACtC,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;QAClE,YAAY,EAAE,SAAS,CAAC,O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AC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClG,MAAM,IAAI,KAAK,CACb,8BAA8B,KAAK,6BAA6B;kBAC9D,oEAAoE,CACvE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,WAAW,IAAI,CAAC,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YACxF,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,oDAAoD,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/safe-fetch.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class BlockedRequestError extends Error {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function assertRequestAllowed(rawUrl: string, opts?: {
|
|
14
14
|
allowPrivate?: boolean;
|
|
15
|
+
trustedHosts?: string[];
|
|
15
16
|
}): Promise<URL>;
|
|
16
17
|
/**
|
|
17
18
|
* A `fetch` that validates the target, and every redirect target, before going.
|
|
@@ -21,5 +22,6 @@ export declare function assertRequestAllowed(rawUrl: string, opts?: {
|
|
|
21
22
|
*/
|
|
22
23
|
export declare function makeSafeFetch(opts?: {
|
|
23
24
|
allowPrivate?: boolean;
|
|
25
|
+
trustedHosts?: string[];
|
|
24
26
|
}): typeof fetch;
|
|
25
27
|
//# sourceMappingURL=safe-fetch.d.ts.map
|
package/dist/safe-fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-fetch.d.ts","sourceRoot":"","sources":["../src/safe-fetch.ts"],"names":[],"mappings":"AA4DA,oDAAoD;AACpD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAmBtD;AAED,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AAEjD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"safe-fetch.d.ts","sourceRoot":"","sources":["../src/safe-fetch.ts"],"names":[],"mappings":"AA4DA,oDAAoD;AACpD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAmBtD;AAED,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AAEjD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAC7D,OAAO,CAAC,GAAG,CAAC,CAyEd;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG,OAAO,KAAK,CA4B1G"}
|
package/dist/safe-fetch.js
CHANGED
|
@@ -116,12 +116,32 @@ export async function assertRequestAllowed(rawUrl, opts = {}) {
|
|
|
116
116
|
}
|
|
117
117
|
return url;
|
|
118
118
|
}
|
|
119
|
+
// An operator naming this exact host has vouched for it, so the resolution
|
|
120
|
+
// step is skipped for it and only for it.
|
|
121
|
+
//
|
|
122
|
+
// Why this exists: behind an HTTP proxy the client does not resolve at all —
|
|
123
|
+
// the proxy does — so lookup() fails with getaddrinfo EAI_AGAIN and every
|
|
124
|
+
// host is refused as "cannot resolve". That is the guard misfiring on the
|
|
125
|
+
// environment rather than on a threat, and it made the MCP server unusable in
|
|
126
|
+
// proxied setups (external E2E, 2026-08-27).
|
|
127
|
+
//
|
|
128
|
+
// Deliberately per-host and not a proxy-detection switch. "We seem to be
|
|
129
|
+
// behind a proxy, disable the SSRF check" turns one environment quirk into a
|
|
130
|
+
// blanket bypass, which is the shape of the vulnerability this file exists to
|
|
131
|
+
// prevent. Exact hostnames only — no suffix matching, because "example.com"
|
|
132
|
+
// trusting "evil-example.com" is the classic way an allowlist stops meaning
|
|
133
|
+
// anything.
|
|
134
|
+
if (opts.trustedHosts?.some((h) => h.toLowerCase() === host.toLowerCase())) {
|
|
135
|
+
return url;
|
|
136
|
+
}
|
|
119
137
|
let addresses;
|
|
120
138
|
try {
|
|
121
139
|
addresses = await lookup(host, { all: true });
|
|
122
140
|
}
|
|
123
141
|
catch (e) {
|
|
124
|
-
throw new BlockedRequestError(`cannot resolve ${host}: ${e.message}`
|
|
142
|
+
throw new BlockedRequestError(`cannot resolve ${host}: ${e.message}. `
|
|
143
|
+
+ `If this host is reachable only through a proxy, name it in `
|
|
144
|
+
+ `AIFINPAY_TRUSTED_HOSTS to skip the DNS pre-check for it alone.`);
|
|
125
145
|
}
|
|
126
146
|
if (!addresses.length) {
|
|
127
147
|
throw new BlockedRequestError(`${host} resolved to nothing`);
|
package/dist/safe-fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-fetch.js","sourceRoot":"","sources":["../src/safe-fetch.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AACxE,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,gFAAgF;AAChF,mEAAmE;AACnE,sEAAsE;AACtE,6EAA6E;AAC7E,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,uDAAuD;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,qDAAqD;AACrD,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAuB;IACrC,CAAC,UAAU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ts
CHANGED
|
@@ -2,15 +2,18 @@ import { AiFinPayAgent } from "@aifinpay/agent";
|
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import type { McpConfig } from "./config.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Production-RC MCP surface.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* IMPORTANT: the old agent_call, payable_fetch, pay_with_split, quote_split,
|
|
8
|
+
* agent_claim_self and agent_quote tools are deliberately NOT registered.
|
|
9
|
+
* They depend on @aifinpay/agent 1.x legacy splitter/x402 semantics and must not
|
|
10
|
+
* be available to a model after the 0% AIFP-2 / gross-inclusive AIFP-1 change.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* This server remains useful before the SDK 2.0 package is published: it can
|
|
13
|
+
* expose the wallet address, resolve Agent Passport identity, read verified
|
|
14
|
+
* v1.3 routes, and construct a non-signing settlement invoice. Signing/moving
|
|
15
|
+
* value returns only after MCP depends on the published v2 executor and its E2E
|
|
16
|
+
* release gate has passed.
|
|
14
17
|
*/
|
|
15
18
|
export declare function createServer(config?: McpConfig): Promise<{
|
|
16
19
|
server: Server<{
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAwB7C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAAC,MAAM,GAAE,SAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFxD;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D"}
|
package/dist/server.js
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
1
|
import { AiFinPayAgent } from "@aifinpay/agent";
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { payableFetchTool, runPayableFetch } from "./tools/payable-fetch.js";
|
|
5
4
|
import { agentAddressTool, runAgentAddress } from "./tools/agent-address.js";
|
|
6
|
-
import {
|
|
7
|
-
import { agentCallTool, runAgentCall } from "./tools/agent-call.js";
|
|
8
|
-
import { agentClaimSelfTool, runAgentClaimSelf } from "./tools/agent-claim-self.js";
|
|
5
|
+
import { agentQuotaTool, runAgentQuota } from "./tools/agent-quota.js";
|
|
9
6
|
import { makeSafeFetch } from "./safe-fetch.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// caller — or a prompt injection reaching the tool — could name
|
|
16
|
-
// http://127.0.0.1:4001 or http://169.254.169.254/latest/meta-data/ and read
|
|
17
|
-
// the answer. It is the tool exposed over HTTP today.
|
|
18
|
-
//
|
|
19
|
-
// Set AIFINPAY_ALLOW_PRIVATE_FETCH=1 to lift it, which is what a local bridge
|
|
20
|
-
// on localhost needs and what a public deployment must never have.
|
|
7
|
+
import { loadConfigFromEnv } from "./config.js";
|
|
8
|
+
import { agentPassportResolveTool, runAgentPassportResolve, settlementRoutesTool, runSettlementRoutes, settlementInvoiceTool, runSettlementInvoice, } from "./tools/production-control.js";
|
|
9
|
+
// Every backend/public request made by this server goes through safeFetch.
|
|
10
|
+
// Public deployments never lift private-network protection; local development
|
|
11
|
+
// may explicitly use AIFINPAY_ALLOW_PRIVATE_FETCH=1.
|
|
21
12
|
const safeFetch = makeSafeFetch({
|
|
22
13
|
allowPrivate: process.env.AIFINPAY_ALLOW_PRIVATE_FETCH === "1",
|
|
14
|
+
// Exact hosts an operator vouches for. Skips only the DNS pre-check, and only
|
|
15
|
+
// for those names — see safe-fetch.ts for why this is not a proxy switch.
|
|
16
|
+
trustedHosts: loadConfigFromEnv().trustedHosts,
|
|
23
17
|
});
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
19
|
+
* Production-RC MCP surface.
|
|
26
20
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
21
|
+
* IMPORTANT: the old agent_call, payable_fetch, pay_with_split, quote_split,
|
|
22
|
+
* agent_claim_self and agent_quote tools are deliberately NOT registered.
|
|
23
|
+
* They depend on @aifinpay/agent 1.x legacy splitter/x402 semantics and must not
|
|
24
|
+
* be available to a model after the 0% AIFP-2 / gross-inclusive AIFP-1 change.
|
|
29
25
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
26
|
+
* This server remains useful before the SDK 2.0 package is published: it can
|
|
27
|
+
* expose the wallet address, resolve Agent Passport identity, read verified
|
|
28
|
+
* v1.3 routes, and construct a non-signing settlement invoice. Signing/moving
|
|
29
|
+
* value returns only after MCP depends on the published v2 executor and its E2E
|
|
30
|
+
* release gate has passed.
|
|
34
31
|
*/
|
|
35
32
|
export async function createServer(config = {}) {
|
|
36
33
|
const log = config.logFn ?? defaultLog;
|
|
37
|
-
// Agent identity: load from env secret if provided, else generate one
|
|
38
|
-
// and print to stderr so the human knows what to fund.
|
|
39
34
|
const agent = config.agentSecretB58
|
|
40
35
|
? await AiFinPayAgent.fromSolanaSecret(config.agentSecretB58, {
|
|
41
36
|
fetchImpl: safeFetch,
|
|
@@ -48,19 +43,6 @@ export async function createServer(config = {}) {
|
|
|
48
43
|
baseUrl: config.baseUrl,
|
|
49
44
|
timeoutMs: config.timeoutMs,
|
|
50
45
|
});
|
|
51
|
-
// NEVER log private key material. stderr is captured by Docker,
|
|
52
|
-
// journald, CI logs, support bundles and monitoring, so printing the
|
|
53
|
-
// secret here leaked it into all of them.
|
|
54
|
-
//
|
|
55
|
-
// The warning below stays, but not for the reason it once gave. That
|
|
56
|
-
// reason — that new() produced an EVM key independent of the Solana
|
|
57
|
-
// one, so no backup could restore both — was fixed: everything now
|
|
58
|
-
// derives from a single random seed. What makes this identity
|
|
59
|
-
// ephemeral is narrower and still true: the seed is never printed and
|
|
60
|
-
// never written anywhere, deliberately, because stderr ends up in
|
|
61
|
-
// Docker, journald, CI logs and support bundles. Recoverable in
|
|
62
|
-
// principle, unrecoverable in practice, so still not an address to
|
|
63
|
-
// fund.
|
|
64
46
|
log("warn", `[aifinpay-mcp] no AIFINPAY_AGENT_SECRET set — generated an EPHEMERAL, NON-RECOVERABLE agent.\n` +
|
|
65
47
|
` solana_address: ${a.solanaAddress}\n` +
|
|
66
48
|
` evm_address: ${a.evmAddress}\n` +
|
|
@@ -69,71 +51,51 @@ export async function createServer(config = {}) {
|
|
|
69
51
|
` (AiFinPayAgent.fromSeed / \`aifinpay init\`) and set AIFINPAY_AGENT_SECRET.`);
|
|
70
52
|
return a;
|
|
71
53
|
})();
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
// the cap there too, otherwise the primary tool has NO runaway protection.
|
|
54
|
+
// Keep the legacy agent budget configured even though this RC exposes no
|
|
55
|
+
// signing tool. It remains an additional defence for downstream/private code
|
|
56
|
+
// and for the subsequent v2 MCP executor integration.
|
|
76
57
|
if (config.maxAmountUsd !== undefined && Number.isFinite(config.maxAmountUsd)) {
|
|
77
58
|
agent.setBudget({ per_call_usd: config.maxAmountUsd });
|
|
78
59
|
log("info", `[aifinpay-mcp] per-call cap: $${config.maxAmountUsd} (AIFINPAY_MAX_USD)`);
|
|
79
60
|
}
|
|
80
|
-
|
|
81
|
-
log("warn", "[aifinpay-mcp] AIFINPAY_MAX_USD not set — agent_call/payable_fetch have NO per-payment cap. Strongly recommended.");
|
|
82
|
-
}
|
|
83
|
-
log("info", `[aifinpay-mcp] solana: ${agent.solanaAddress} · evm: ${agent.evmAddress}`);
|
|
61
|
+
log("info", `[aifinpay-mcp] production RC safe surface · solana: ${agent.solanaAddress} · evm: ${agent.evmAddress}`);
|
|
84
62
|
const server = new Server({
|
|
85
63
|
name: "@aifinpay/mcp",
|
|
86
|
-
version: "
|
|
87
|
-
}, {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
agentClaimSelfTool(),
|
|
98
|
-
payableFetchTool(),
|
|
99
|
-
agentQuoteTool(),
|
|
100
|
-
payWithSplitTool(),
|
|
101
|
-
quoteSplitTool(),
|
|
102
|
-
],
|
|
103
|
-
};
|
|
104
|
-
});
|
|
64
|
+
version: "2.0.0-rc.1",
|
|
65
|
+
}, { capabilities: { tools: {} } });
|
|
66
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
67
|
+
tools: [
|
|
68
|
+
agentAddressTool(),
|
|
69
|
+
agentQuotaTool(),
|
|
70
|
+
agentPassportResolveTool(),
|
|
71
|
+
settlementRoutesTool(),
|
|
72
|
+
settlementInvoiceTool(),
|
|
73
|
+
],
|
|
74
|
+
}));
|
|
105
75
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
106
76
|
const { name, arguments: args } = request.params;
|
|
107
77
|
const ctx = { agent, config, log };
|
|
108
78
|
switch (name) {
|
|
109
79
|
case "agent_address":
|
|
110
80
|
return runAgentAddress(ctx, args ?? {});
|
|
111
|
-
case "
|
|
112
|
-
return
|
|
113
|
-
case "
|
|
114
|
-
return
|
|
115
|
-
case "
|
|
116
|
-
return
|
|
117
|
-
case "
|
|
118
|
-
return
|
|
119
|
-
case "pay_with_split":
|
|
120
|
-
return runPayWithSplit(ctx, args ?? {});
|
|
121
|
-
case "quote_split":
|
|
122
|
-
return runQuoteSplit(ctx, args ?? {});
|
|
81
|
+
case "agent_quota":
|
|
82
|
+
return runAgentQuota(ctx, args ?? {});
|
|
83
|
+
case "agent_passport_resolve":
|
|
84
|
+
return runAgentPassportResolve(ctx, args ?? {});
|
|
85
|
+
case "settlement_routes":
|
|
86
|
+
return runSettlementRoutes(ctx, args ?? {});
|
|
87
|
+
case "settlement_invoice":
|
|
88
|
+
return runSettlementInvoice(ctx, args ?? {});
|
|
123
89
|
default:
|
|
124
90
|
return {
|
|
125
91
|
isError: true,
|
|
126
|
-
content: [
|
|
127
|
-
{ type: "text", text: `unknown tool: ${name}` },
|
|
128
|
-
],
|
|
92
|
+
content: [{ type: "text", text: `unknown or retired tool: ${name}` }],
|
|
129
93
|
};
|
|
130
94
|
}
|
|
131
95
|
});
|
|
132
96
|
return { server, agent };
|
|
133
97
|
}
|
|
134
98
|
function defaultLog(level, msg) {
|
|
135
|
-
// MCP stdio servers MUST NOT write to stdout — the transport owns it.
|
|
136
|
-
// stderr is safe.
|
|
137
99
|
process.stderr.write(`[${level}] ${msg}\n`);
|
|
138
100
|
}
|
|
139
101
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AA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C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,eAAe;gBAClB,OAAO,eAAe,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAC1C,KAAK,aAAa;gBAChB,OAAO,aAAa,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YACxC,KAAK,wBAAwB;gBAC3B,OAAO,uBAAuB,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAClD,KAAK,mBAAmB;gBACtB,OAAO,mBAAmB,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAC9C,KAAK,oBAAoB;gBACvB,OAAO,oBAAoB,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAC/C;gBACE,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAA4B,IAAI,EAAE,EAAE,CAAC;iBACtE,CAAC;QACN,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAC;AAQD,SAAS,UAAU,CAAC,KAAgC,EAAE,GAAW;IAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-address.d.ts","sourceRoot":"","sources":["../../src/tools/agent-address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"agent-address.d.ts","sourceRoot":"","sources":["../../src/tools/agent-address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2B/B;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;GAe/B"}
|
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
export function agentAddressTool() {
|
|
2
2
|
return {
|
|
3
3
|
name: "agent_address",
|
|
4
|
-
description: "Return the agent's on-chain
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"and other bridges advertising Polygon settlement. Solana (base58) — " +
|
|
8
|
-
"for the leaderboard / Seat PDA and Solana-native bridges. Casper — " +
|
|
9
|
-
"identity only for now: the address is derived from the same seed and " +
|
|
10
|
-
"can be funded, but this SDK cannot yet sign Casper deploys, so it is " +
|
|
11
|
-
"not a settlement rail here. One seed, three addresses.",
|
|
4
|
+
description: "Return the agent's currently derived on-chain addresses. " +
|
|
5
|
+
"This tool is read-only and never authorizes or signs a payment. " +
|
|
6
|
+
"Production value movement is available only through the verified SDK v2 settlement executor after trusted deployment pins are released.",
|
|
12
7
|
inputSchema: {
|
|
13
8
|
type: "object",
|
|
14
9
|
properties: {},
|
|
15
10
|
},
|
|
16
|
-
// OpenAI Apps SDK requires impact hints on every tool (omitting = validation error).
|
|
17
11
|
annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
|
|
18
12
|
outputSchema: {
|
|
19
13
|
type: "object",
|
|
20
14
|
properties: {
|
|
21
15
|
solana: { type: "string", description: "Solana base58 address" },
|
|
22
|
-
evm: { type: "string", description: "
|
|
23
|
-
// Declared because the handler returns it. A field present in the
|
|
24
|
-
// payload but absent from the schema is how a client silently drops
|
|
25
|
-
// it — the address would be derived, returned, and never shown.
|
|
16
|
+
evm: { type: "string", description: "EVM address used across EVM networks" },
|
|
26
17
|
casper: {
|
|
27
18
|
type: "string",
|
|
28
|
-
description: "Casper
|
|
29
|
-
"and fundable, but this SDK cannot sign Casper deploys yet.",
|
|
19
|
+
description: "Casper identity derived from the same seed. Read-only in this MCP RC; no payment signing tool is exposed.",
|
|
30
20
|
},
|
|
31
21
|
note: { type: "string" },
|
|
32
22
|
},
|
|
33
|
-
// `casper` is deliberately not required: an agent built from a raw EVM
|
|
34
|
-
// key has no seed to derive it from, and claiming it always exists
|
|
35
|
-
// would make that case look like a bug rather than a limitation.
|
|
36
23
|
required: ["solana", "evm"],
|
|
37
24
|
},
|
|
38
25
|
};
|
|
@@ -41,16 +28,8 @@ export async function runAgentAddress(ctx, _args) {
|
|
|
41
28
|
const payload = {
|
|
42
29
|
solana: ctx.agent.solanaAddress,
|
|
43
30
|
evm: ctx.agent.evmAddress,
|
|
44
|
-
// Casper was absent here while the project counted it among its live
|
|
45
|
-
// networks, so an agent could not be told its own address on a chain we
|
|
46
|
-
// advertise. Same seed as the other two; the account hash is what a Casper
|
|
47
|
-
// explorer expects.
|
|
48
31
|
casper: ctx.agent.casperAddress,
|
|
49
|
-
note: "
|
|
50
|
-
"(io.net, Exa, Venice). Solana is supported via Seat PDA payments. " +
|
|
51
|
-
"Casper has a deployed settlement contract and the SDK derives the " +
|
|
52
|
-
"address, but does not yet sign Casper deploys. " +
|
|
53
|
-
"One seed derives all three — funding any enables that chain.",
|
|
32
|
+
note: "Read-only address discovery. Payment signing is intentionally absent from this MCP production RC until the final SDK v2 release contains independently trusted deployment pins and paid E2E evidence.",
|
|
54
33
|
};
|
|
55
34
|
return {
|
|
56
35
|
content: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-address.js","sourceRoot":"","sources":["../../src/tools/agent-address.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"agent-address.js","sourceRoot":"","sources":["../../src/tools/agent-address.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QAC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|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
merchant_id: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
include_exhausted: {
|
|
13
|
+
type: string;
|
|
14
|
+
default: boolean;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
annotations: {
|
|
20
|
+
readOnlyHint: boolean;
|
|
21
|
+
openWorldHint: boolean;
|
|
22
|
+
destructiveHint: boolean;
|
|
23
|
+
};
|
|
24
|
+
outputSchema: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function runAgentQuota(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
29
|
+
isError: boolean;
|
|
30
|
+
content: {
|
|
31
|
+
type: string;
|
|
32
|
+
text: string;
|
|
33
|
+
}[];
|
|
34
|
+
} | {
|
|
35
|
+
content: {
|
|
36
|
+
type: string;
|
|
37
|
+
text: string;
|
|
38
|
+
}[];
|
|
39
|
+
}>;
|
|
40
|
+
//# sourceMappingURL=agent-quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-quota.d.ts","sourceRoot":"","sources":["../../src/tools/agent-quota.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;EA4B7B;AAiBD,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;GAwE9B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const DEFAULT_BASE = "https://api.aifinpay.io";
|
|
2
|
+
export function agentQuotaTool() {
|
|
3
|
+
return {
|
|
4
|
+
name: "agent_quota",
|
|
5
|
+
description: "How many prepaid requests this agent has left, per service. Lists the " +
|
|
6
|
+
"agent's active quota batches (merchant, resource, used, remaining, " +
|
|
7
|
+
"expiry). Read-only; never spends, pays, or signs anything. Ask it " +
|
|
8
|
+
"things like: how many calls do I have left at mrch_x?",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
merchant_id: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "Optional mrch_… filter — only batches bought from this service.",
|
|
15
|
+
},
|
|
16
|
+
include_exhausted: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
default: false,
|
|
19
|
+
description: "Also list batches with 0 remaining (still retained, not yet expired).",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
// Talks only to the configured AiFinPay backend, never to arbitrary URLs.
|
|
24
|
+
annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
|
|
25
|
+
outputSchema: { type: "object" },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export async function runAgentQuota(ctx, args) {
|
|
29
|
+
const base = (ctx.config.baseUrl ?? DEFAULT_BASE).replace(/\/+$/, "");
|
|
30
|
+
const address = ctx.agent.evmAddress;
|
|
31
|
+
const merchantFilter = typeof args.merchant_id === "string" && args.merchant_id ? args.merchant_id : null;
|
|
32
|
+
const includeExhausted = args.include_exhausted === true;
|
|
33
|
+
let resp;
|
|
34
|
+
try {
|
|
35
|
+
resp = await ctx.agent.inner.fetchImpl(`${base}/v1/agents/${address}/receipts`, { method: "GET" });
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
const err = e;
|
|
39
|
+
return errorResult(`could not reach ${base}: ${err.message}`);
|
|
40
|
+
}
|
|
41
|
+
if (!resp.ok) {
|
|
42
|
+
return errorResult(`quota lookup failed: HTTP ${resp.status}`);
|
|
43
|
+
}
|
|
44
|
+
const body = (await resp.json());
|
|
45
|
+
const now = Math.floor(Date.now() / 1000);
|
|
46
|
+
let batches = (body.receipts ?? [])
|
|
47
|
+
.filter((r) => r.exp == null || r.exp > now)
|
|
48
|
+
.filter((r) => (merchantFilter ? r.merchant_id === merchantFilter : true))
|
|
49
|
+
.filter((r) => includeExhausted || (r.remaining ?? 0) > 0)
|
|
50
|
+
.map((r) => ({
|
|
51
|
+
merchant_id: r.merchant_id,
|
|
52
|
+
resource: r.resource,
|
|
53
|
+
scope: r.scope ?? "exact",
|
|
54
|
+
tier: r.tier,
|
|
55
|
+
used: r.used ?? 0,
|
|
56
|
+
remaining: r.remaining ?? 0,
|
|
57
|
+
quota: r.quota ?? 1,
|
|
58
|
+
paid: r.amount != null ? `${r.amount} ${r.currency ?? "USD"}` : undefined,
|
|
59
|
+
expires: r.exp != null ? new Date(r.exp * 1000).toISOString() : undefined,
|
|
60
|
+
receipt_id: r.receipt_id,
|
|
61
|
+
}));
|
|
62
|
+
// Most useful first: the batches with the most room to spend.
|
|
63
|
+
batches = batches.sort((a, b) => b.remaining - a.remaining);
|
|
64
|
+
// Roll up per merchant so "how much do I have left at X" is one line even
|
|
65
|
+
// when the agent bought several batches there.
|
|
66
|
+
const perMerchant = new Map();
|
|
67
|
+
for (const b of batches) {
|
|
68
|
+
const key = b.merchant_id ?? "unknown";
|
|
69
|
+
const cur = perMerchant.get(key) ?? { remaining: 0, batches: 0 };
|
|
70
|
+
cur.remaining += b.remaining;
|
|
71
|
+
cur.batches += 1;
|
|
72
|
+
perMerchant.set(key, cur);
|
|
73
|
+
}
|
|
74
|
+
const payload = {
|
|
75
|
+
agent: address,
|
|
76
|
+
...(merchantFilter ? { merchant_filter: merchantFilter } : {}),
|
|
77
|
+
totals: Object.fromEntries(perMerchant),
|
|
78
|
+
batches,
|
|
79
|
+
note: batches.length === 0
|
|
80
|
+
? merchantFilter
|
|
81
|
+
? `no active quota at ${merchantFilter} — a new batch starts with that service's 402 (or agent_quote its URL first)`
|
|
82
|
+
: "no active quota anywhere — pay a service's 402 to start a batch"
|
|
83
|
+
: "`remaining` is authoritative where AiFinPay meters (hosted gateway); a merchant running its own @aifinpay/gate meters locally and our copy can lag behind by their traffic.",
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function errorResult(...lines) {
|
|
90
|
+
return {
|
|
91
|
+
isError: true,
|
|
92
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=agent-quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-quota.js","sourceRoot":"","sources":["../../src/tools/agent-quota.ts"],"names":[],"mappings":"AAuBA,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAE/C,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,wEAAwE;YACxE,qEAAqE;YACrE,oEAAoE;YACpE,uDAAuD;QACzD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,iEAAiE;iBACpE;gBACD,iBAAiB,EAAE;oBACjB,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK;oBACd,WAAW,EACT,uEAAuE;iBAC1E;aACF;SACF;QACD,0EAA0E;QAC1E,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;QACjF,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACjC,CAAC;AACJ,CAAC;AAiBD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAgB,EAChB,IAA6B;IAE7B,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,YAAY,CAAC,C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
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
identifier: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
required: string[];
|
|
14
|
+
};
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: boolean;
|
|
17
|
+
openWorldHint: boolean;
|
|
18
|
+
destructiveHint: boolean;
|
|
19
|
+
};
|
|
20
|
+
outputSchema: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function runAgentPassportResolve(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
export declare function settlementRoutesTool(): {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: string;
|
|
35
|
+
properties: {
|
|
36
|
+
route_class: {
|
|
37
|
+
type: string;
|
|
38
|
+
enum: string[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
annotations: {
|
|
43
|
+
readOnlyHint: boolean;
|
|
44
|
+
openWorldHint: boolean;
|
|
45
|
+
destructiveHint: boolean;
|
|
46
|
+
};
|
|
47
|
+
outputSchema: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare function runSettlementRoutes(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
52
|
+
content: {
|
|
53
|
+
type: string;
|
|
54
|
+
text: string;
|
|
55
|
+
}[];
|
|
56
|
+
}>;
|
|
57
|
+
export declare function settlementInvoiceTool(): {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: string;
|
|
62
|
+
properties: {
|
|
63
|
+
route_class: {
|
|
64
|
+
type: string;
|
|
65
|
+
enum: string[];
|
|
66
|
+
};
|
|
67
|
+
chain: {
|
|
68
|
+
type: string;
|
|
69
|
+
enum: string[];
|
|
70
|
+
};
|
|
71
|
+
asset: {
|
|
72
|
+
type: string;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
gross_amount: {
|
|
76
|
+
type: string;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
merchant_wallet: {
|
|
80
|
+
type: string;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
order_id: {
|
|
84
|
+
type: string;
|
|
85
|
+
};
|
|
86
|
+
valid_until: {
|
|
87
|
+
type: string;
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
required: string[];
|
|
92
|
+
};
|
|
93
|
+
annotations: {
|
|
94
|
+
readOnlyHint: boolean;
|
|
95
|
+
openWorldHint: boolean;
|
|
96
|
+
destructiveHint: boolean;
|
|
97
|
+
};
|
|
98
|
+
outputSchema: {
|
|
99
|
+
type: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export declare function runSettlementInvoice(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
103
|
+
content: {
|
|
104
|
+
type: string;
|
|
105
|
+
text: string;
|
|
106
|
+
}[];
|
|
107
|
+
}>;
|
|
108
|
+
//# sourceMappingURL=production-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-control.d.ts","sourceRoot":"","sources":["../../src/tools/production-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA8BhD,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;EAgBvC;AAED,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;GAS5F;AAED,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;;;;EAgBnC;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;GAQxF;AAED,wBAAgB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBpC;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;GAuBzF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const DEFAULT_BASE = "https://aifinpay.io";
|
|
2
|
+
const ROUTES = new Set(["AIFP-1", "AIFP-2"]);
|
|
3
|
+
const CHAINS = new Set([
|
|
4
|
+
"polygon", "avalanche", "arbitrum", "bnb", "base",
|
|
5
|
+
"unichain", "optimism", "botchain", "xrplevm",
|
|
6
|
+
]);
|
|
7
|
+
function result(value) {
|
|
8
|
+
return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
|
|
9
|
+
}
|
|
10
|
+
function errorResult(message) {
|
|
11
|
+
return { isError: true, content: [{ type: "text", text: message }] };
|
|
12
|
+
}
|
|
13
|
+
function base(ctx) {
|
|
14
|
+
return String(ctx.config.baseUrl || DEFAULT_BASE).replace(/\/$/, "");
|
|
15
|
+
}
|
|
16
|
+
async function api(ctx, path, init) {
|
|
17
|
+
const response = await ctx.agent.inner.fetchImpl(`${base(ctx)}${path}`, init);
|
|
18
|
+
const body = await response.json().catch(() => null);
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
const detail = body && typeof body === "object"
|
|
21
|
+
? JSON.stringify(body)
|
|
22
|
+
: `HTTP ${response.status}`;
|
|
23
|
+
throw new Error(detail);
|
|
24
|
+
}
|
|
25
|
+
return body;
|
|
26
|
+
}
|
|
27
|
+
export function agentPassportResolveTool() {
|
|
28
|
+
return {
|
|
29
|
+
name: "agent_passport_resolve",
|
|
30
|
+
description: "Resolve an AiFinPay Agent Passport by @username, permanent AIFP number, or immutable agent id. " +
|
|
31
|
+
"Returns verified public wallet bindings only. Resolution never authorizes a payment.",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
identifier: { type: "string", description: "@username, AIFP-#########, or aifp_agent_* id" },
|
|
36
|
+
},
|
|
37
|
+
required: ["identifier"],
|
|
38
|
+
},
|
|
39
|
+
annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
|
|
40
|
+
outputSchema: { type: "object" },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export async function runAgentPassportResolve(ctx, args) {
|
|
44
|
+
const identifier = String(args.identifier || "").trim();
|
|
45
|
+
if (!identifier)
|
|
46
|
+
return errorResult("missing required arg: identifier");
|
|
47
|
+
try {
|
|
48
|
+
const body = await api(ctx, `/api/agent/resolve/${encodeURIComponent(identifier)}`);
|
|
49
|
+
return result(body);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
return errorResult(`Agent Passport resolve failed: ${e.message}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function settlementRoutesTool() {
|
|
56
|
+
return {
|
|
57
|
+
name: "settlement_routes",
|
|
58
|
+
description: "Read AiFinPay's currently runtime-verified v1.3 settlement routes. " +
|
|
59
|
+
"AIFP-1 is merchant monetisation (99% merchant / 1% AiFinPay / 0% creator). " +
|
|
60
|
+
"AIFP-2/x402 is 100% provider / 0% AiFinPay / 0% creator.",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
route_class: { type: "string", enum: ["AIFP-1", "AIFP-2"] },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
|
|
68
|
+
outputSchema: { type: "object" },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export async function runSettlementRoutes(ctx, args) {
|
|
72
|
+
const route = args.route_class == null ? "" : String(args.route_class).toUpperCase();
|
|
73
|
+
if (route && !ROUTES.has(route))
|
|
74
|
+
return errorResult("route_class must be AIFP-1 or AIFP-2");
|
|
75
|
+
try {
|
|
76
|
+
return result(await api(ctx, `/v1/settlement/routes${route ? `?route_class=${encodeURIComponent(route)}` : ""}`));
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
return errorResult(`Settlement route lookup failed: ${e.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function settlementInvoiceTool() {
|
|
83
|
+
return {
|
|
84
|
+
name: "settlement_invoice",
|
|
85
|
+
description: "Build and validate a NON-SIGNING v1.3 settlement invoice. This tool never moves funds. " +
|
|
86
|
+
"Use the published @aifinpay/agent v2 settlement executor to verify bytecode/profile and sign it.",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
route_class: { type: "string", enum: ["AIFP-1", "AIFP-2"] },
|
|
91
|
+
chain: { type: "string", enum: [...CHAINS] },
|
|
92
|
+
asset: { type: "string", description: "Native symbol, USDC, or USDT if the route advertises it." },
|
|
93
|
+
gross_amount: { type: "string", description: "Gross payer amount in base units." },
|
|
94
|
+
merchant_wallet: { type: "string", description: "Merchant/provider EVM wallet." },
|
|
95
|
+
order_id: { type: "string" },
|
|
96
|
+
valid_until: { type: "integer", description: "Optional Unix seconds, max 20 minutes ahead." },
|
|
97
|
+
},
|
|
98
|
+
required: ["route_class", "chain", "asset", "gross_amount", "merchant_wallet", "order_id"],
|
|
99
|
+
},
|
|
100
|
+
annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
|
|
101
|
+
outputSchema: { type: "object" },
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export async function runSettlementInvoice(ctx, args) {
|
|
105
|
+
const route = String(args.route_class || "").toUpperCase();
|
|
106
|
+
const chain = String(args.chain || "").toLowerCase();
|
|
107
|
+
if (!ROUTES.has(route))
|
|
108
|
+
return errorResult("route_class must be AIFP-1 or AIFP-2");
|
|
109
|
+
if (!CHAINS.has(chain))
|
|
110
|
+
return errorResult("unsupported EVM settlement chain");
|
|
111
|
+
try {
|
|
112
|
+
const payload = {
|
|
113
|
+
route_class: route,
|
|
114
|
+
chain,
|
|
115
|
+
asset: String(args.asset || "").toUpperCase(),
|
|
116
|
+
gross_amount: String(args.gross_amount || ""),
|
|
117
|
+
merchant_wallet: String(args.merchant_wallet || ""),
|
|
118
|
+
order_id: String(args.order_id || ""),
|
|
119
|
+
...(args.valid_until != null ? { valid_until: Number(args.valid_until) } : {}),
|
|
120
|
+
};
|
|
121
|
+
return result(await api(ctx, "/v1/settlement/invoice", {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: { "content-type": "application/json" },
|
|
124
|
+
body: JSON.stringify(payload),
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
return errorResult(`Settlement invoice failed: ${e.message}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=production-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-control.js","sourceRoot":"","sources":["../../src/tools/production-control.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAC3C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACrB,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM;IACjD,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS;CAC9C,CAAC,CAAC;AAEH,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,K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AC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/E,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,wBAAwB,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CAAC,CAAC,CAAC;IACN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,WAAW,CAAC,8BAA+B,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aifinpay/mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0-rc.3",
|
|
4
|
+
"description": "AiFinPay MCP production-RC control surface for Agent Passport resolution and runtime-verified AIFP-1/AIFP-2 settlement invoices. Signing tools remain gated until @aifinpay/agent v2 release.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
"mcp-server",
|
|
33
33
|
"mcp-payments",
|
|
34
34
|
"mcp-monetization",
|
|
35
|
-
"
|
|
35
|
+
"agent-passport",
|
|
36
|
+
"settlement",
|
|
36
37
|
"x402-mcp",
|
|
37
|
-
"pay-per-call",
|
|
38
|
-
"paid-ai-tools",
|
|
39
38
|
"claude-desktop",
|
|
40
39
|
"claude-mcp",
|
|
41
40
|
"cursor",
|
|
@@ -46,29 +45,15 @@
|
|
|
46
45
|
"ai-agent-payments",
|
|
47
46
|
"agentic-ai",
|
|
48
47
|
"autonomous-agents",
|
|
49
|
-
"autonomous-payments",
|
|
50
48
|
"agent-payments",
|
|
51
49
|
"agent-commerce",
|
|
52
50
|
"agentic-commerce",
|
|
53
51
|
"agent-economy",
|
|
54
52
|
"ai-commerce",
|
|
55
|
-
"ai-payment-infrastructure",
|
|
56
|
-
"ai-financial-infrastructure",
|
|
57
53
|
"x402",
|
|
58
54
|
"x402-payments",
|
|
59
55
|
"http-402",
|
|
60
|
-
"
|
|
61
|
-
"api-payments",
|
|
62
|
-
"api-monetization",
|
|
63
|
-
"machine-payments",
|
|
64
|
-
"m2m-payments",
|
|
65
|
-
"programmable-payments",
|
|
66
|
-
"crypto-payments",
|
|
67
|
-
"stablecoin-payments",
|
|
68
|
-
"polygon",
|
|
69
|
-
"solana",
|
|
70
|
-
"non-custodial",
|
|
71
|
-
"stripe-for-ai-agents"
|
|
56
|
+
"non-custodial"
|
|
72
57
|
],
|
|
73
58
|
"author": "CoinSecurities (SECCO) <contact@aifinpay.io>",
|
|
74
59
|
"license": "MIT",
|