@aifinpay/mcp 0.1.0-alpha.6 → 1.0.1
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 +26 -7
- package/bin/aifinpay-mcp.js +1 -1
- package/dist/directory.d.ts +55 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +56 -0
- package/dist/directory.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/agent-address.d.ts +27 -0
- package/dist/tools/agent-address.d.ts.map +1 -1
- package/dist/tools/agent-address.js +12 -0
- package/dist/tools/agent-address.js.map +1 -1
- package/dist/tools/agent-call.d.ts +8 -0
- package/dist/tools/agent-call.d.ts.map +1 -1
- package/dist/tools/agent-call.js +32 -11
- package/dist/tools/agent-call.js.map +1 -1
- package/dist/tools/agent-claim-self.d.ts +10 -2
- package/dist/tools/agent-claim-self.d.ts.map +1 -1
- package/dist/tools/agent-claim-self.js +49 -12
- package/dist/tools/agent-claim-self.js.map +1 -1
- package/dist/tools/agent-quote.d.ts +8 -0
- package/dist/tools/agent-quote.d.ts.map +1 -1
- package/dist/tools/agent-quote.js +3 -0
- package/dist/tools/agent-quote.js.map +1 -1
- package/dist/tools/directory.d.ts +275 -0
- package/dist/tools/directory.d.ts.map +1 -0
- package/dist/tools/directory.js +254 -0
- package/dist/tools/directory.js.map +1 -0
- package/dist/tools/pay-with-split.d.ts +18 -0
- package/dist/tools/pay-with-split.d.ts.map +1 -1
- package/dist/tools/pay-with-split.js +7 -0
- package/dist/tools/pay-with-split.js.map +1 -1
- package/dist/tools/payable-fetch.d.ts +8 -0
- package/dist/tools/payable-fetch.d.ts.map +1 -1
- package/dist/tools/payable-fetch.js +16 -5
- package/dist/tools/payable-fetch.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -6,11 +6,29 @@ MCP-aware agent runtime — your agent can now buy services autonomously.
|
|
|
6
6
|
|
|
7
7
|
## Tools
|
|
8
8
|
|
|
9
|
+
### Payment / agent
|
|
9
10
|
| Tool | What it does |
|
|
10
11
|
|---|---|
|
|
11
|
-
| `payable_fetch(url, opts?)` | Fetch any URL. On 402, auto-detect facilitator, sign, retry. |
|
|
12
|
-
| `
|
|
13
|
-
| `agent_quote(url)` | Inspect a 402 challenge without paying
|
|
12
|
+
| `payable_fetch(url, opts?)` | Fetch any URL. On HTTP 402, auto-detect the facilitator, sign, pay, and retry. |
|
|
13
|
+
| `agent_call({provider, body})` | Pay a registered AiFinPay provider and return its response (unified call). |
|
|
14
|
+
| `agent_quote(url)` | Inspect a 402 challenge without paying — quoted amount + facilitator flavor. |
|
|
15
|
+
| `agent_address()` | Return the agent's address so you know where to fund it. |
|
|
16
|
+
| `agent_claim_self(...)` | Publish/claim this agent on the public AiFinPay network directory. |
|
|
17
|
+
| `pay_with_split(...)` | Execute a fee-on-top (B2B) split payment. |
|
|
18
|
+
| `quote_split(...)` | Preview the fee-on-top split breakdown without paying. |
|
|
19
|
+
|
|
20
|
+
### Marketplace directory (read-only)
|
|
21
|
+
| Tool | What it does |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `list_providers()` | List the AI services available through AiFinPay with per-call prices. |
|
|
24
|
+
| `provider_info(name)` | Details for one provider (price, networks, service type). |
|
|
25
|
+
| `provider_status()` | Which provider bridges are currently reachable. |
|
|
26
|
+
| `service_coverage()` | Which categories AiFinPay covers and the providers in each. |
|
|
27
|
+
| `network_stats()` | Public protocol statistics. |
|
|
28
|
+
| `leaderboard()` | Public on-chain leaderboard of AiFinPay agents. |
|
|
29
|
+
| `quote_cost(...)` | Preview the fee-on-top cost for a given price (no payment). |
|
|
30
|
+
| `verify_passport(pubkey)` | Whether a key holds an AiFinPay AgentPassport. |
|
|
31
|
+
| `agent_profile(address)` | Public profile + activity summary for an agent. |
|
|
14
32
|
|
|
15
33
|
## Install
|
|
16
34
|
|
|
@@ -38,8 +56,9 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
38
56
|
}
|
|
39
57
|
```
|
|
40
58
|
|
|
41
|
-
Restart Claude Desktop. Now Claude can call
|
|
42
|
-
|
|
59
|
+
Restart Claude Desktop. Now Claude can call any of the tools above —
|
|
60
|
+
`payable_fetch`, `agent_call`, `pay_with_split`, and the read-only
|
|
61
|
+
marketplace directory — like any other tool.
|
|
43
62
|
|
|
44
63
|
## First run — generating an agent
|
|
45
64
|
|
|
@@ -61,7 +80,7 @@ agent identity (and any funded Seat) persists across restarts.
|
|
|
61
80
|
| Var | Default | Purpose |
|
|
62
81
|
|---|---|---|
|
|
63
82
|
| `AIFINPAY_AGENT_SECRET` | — | Base58 secret. If absent → ephemeral agent printed to stderr. |
|
|
64
|
-
| `AIFINPAY_BASE_URL` | `https://aifinpay.
|
|
83
|
+
| `AIFINPAY_BASE_URL` | `https://aifinpay.io` | Backend URL for nonce + funding probes. |
|
|
65
84
|
| `AIFINPAY_TIMEOUT_MS` | `30000` | Request timeout. |
|
|
66
85
|
| `AIFINPAY_MAX_USD` | — | Hard cap per single payment. Strongly recommended. |
|
|
67
86
|
|
|
@@ -71,7 +90,7 @@ agent identity (and any funded Seat) persists across restarts.
|
|
|
71
90
|
import { createServer, loadConfigFromEnv } from "@aifinpay/mcp";
|
|
72
91
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
73
92
|
|
|
74
|
-
const { server } = createServer({
|
|
93
|
+
const { server } = await createServer({
|
|
75
94
|
...loadConfigFromEnv(),
|
|
76
95
|
agentSecretB58: "your-secret-here",
|
|
77
96
|
maxAmountUsd: 0.10,
|
package/bin/aifinpay-mcp.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Configure via env:
|
|
8
8
|
* AIFINPAY_AGENT_SECRET base58 secret (load existing identity)
|
|
9
|
-
* AIFINPAY_BASE_URL default https://aifinpay.
|
|
9
|
+
* AIFINPAY_BASE_URL default https://aifinpay.io
|
|
10
10
|
* AIFINPAY_TIMEOUT_MS default 30000
|
|
11
11
|
* AIFINPAY_MAX_USD hard cap per single payment (no default)
|
|
12
12
|
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createDirectoryServer — the READ-ONLY MCP server submitted to the OpenAI
|
|
3
|
+
* ChatGPT App Directory. Distinct from `createServer` (the full BYO-MCP
|
|
4
|
+
* connector with payment execution): this one exposes ONLY the read-only
|
|
5
|
+
* directory tools, requires NO agent identity and NO auth, and never moves
|
|
6
|
+
* money — so it is reviewable under OpenAI's directory policy (Obsidian/32 /34).
|
|
7
|
+
*
|
|
8
|
+
* One codebase, two profiles: the HTTP wrapper picks this when
|
|
9
|
+
* AIFINPAY_MCP_PROFILE=directory.
|
|
10
|
+
*/
|
|
11
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
12
|
+
export interface DirectoryServerConfig {
|
|
13
|
+
/** Public API base for the wrapped GET endpoints. Defaults to production. */
|
|
14
|
+
apiBase?: string;
|
|
15
|
+
/** Per-request timeout (ms). */
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
log?: (level: "info" | "warn" | "error", msg: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createDirectoryServer(config?: DirectoryServerConfig): Promise<{
|
|
20
|
+
server: Server<{
|
|
21
|
+
method: string;
|
|
22
|
+
params?: {
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
_meta?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
progressToken?: string | number | undefined;
|
|
27
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
28
|
+
taskId: string;
|
|
29
|
+
} | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
method: string;
|
|
34
|
+
params?: {
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
_meta?: {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
progressToken?: string | number | undefined;
|
|
39
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
40
|
+
taskId: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
_meta?: {
|
|
47
|
+
[x: string]: unknown;
|
|
48
|
+
progressToken?: string | number | undefined;
|
|
49
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
50
|
+
taskId: string;
|
|
51
|
+
} | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
}>;
|
|
55
|
+
//# sourceMappingURL=directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAwBD,wBAAsB,qBAAqB,CAAC,MAAM,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2B7E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createDirectoryServer — the READ-ONLY MCP server submitted to the OpenAI
|
|
3
|
+
* ChatGPT App Directory. Distinct from `createServer` (the full BYO-MCP
|
|
4
|
+
* connector with payment execution): this one exposes ONLY the read-only
|
|
5
|
+
* directory tools, requires NO agent identity and NO auth, and never moves
|
|
6
|
+
* money — so it is reviewable under OpenAI's directory policy (Obsidian/32 /34).
|
|
7
|
+
*
|
|
8
|
+
* One codebase, two profiles: the HTTP wrapper picks this when
|
|
9
|
+
* AIFINPAY_MCP_PROFILE=directory.
|
|
10
|
+
*/
|
|
11
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
12
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
13
|
+
import { directoryTools, runDirectoryTool, DIRECTORY_API_BASE, } from "./tools/directory.js";
|
|
14
|
+
// Server-wide instructions returned at initialize. ChatGPT/Codex use these as a
|
|
15
|
+
// cross-tool guide (OpenAI readiness checklist item; the audit found it ABSENT
|
|
16
|
+
// on the connector server). States the read-only contract, networks, and limits.
|
|
17
|
+
const DIRECTORY_INSTRUCTIONS = [
|
|
18
|
+
"AiFinPay is payment infrastructure for AI agents. THIS server is the",
|
|
19
|
+
"read-only directory surface: it answers questions about the AiFinPay agent",
|
|
20
|
+
"economy and prices AI services — it does NOT move money, hold funds, sign",
|
|
21
|
+
"transactions, or execute any payment. Every tool is read-only.",
|
|
22
|
+
"",
|
|
23
|
+
"Use it to: list available AI providers and their per-call prices",
|
|
24
|
+
"(list_providers / provider_info / provider_status / service_coverage),",
|
|
25
|
+
"preview a fee-on-top cost breakdown without paying (quote_cost), read public",
|
|
26
|
+
"protocol stats (network_stats) and the on-chain agent leaderboard",
|
|
27
|
+
"(leaderboard), verify an agent's AgentPassport (verify_passport), and look up",
|
|
28
|
+
"a public agent profile (agent_profile).",
|
|
29
|
+
"",
|
|
30
|
+
"Networks: Polygon and Solana mainnet. Data is public on-chain / registry",
|
|
31
|
+
"information. To actually execute a payment, an agent uses the separate",
|
|
32
|
+
"AiFinPay connector or SDK — not this directory app. Requests are rate limited;",
|
|
33
|
+
"on HTTP 429 (rate_limit_exceeded), back off and retry.",
|
|
34
|
+
].join("\n");
|
|
35
|
+
export async function createDirectoryServer(config = {}) {
|
|
36
|
+
const log = config.log ?? ((lvl, msg) => process.stderr.write(`[${lvl}] ${msg}\n`));
|
|
37
|
+
const ctx = {
|
|
38
|
+
apiBase: (config.apiBase || DIRECTORY_API_BASE).replace(/\/$/, ""),
|
|
39
|
+
timeoutMs: config.timeoutMs ?? 15000,
|
|
40
|
+
log,
|
|
41
|
+
};
|
|
42
|
+
const server = new Server({ name: "@aifinpay/mcp-directory", version: "1.0.0" }, {
|
|
43
|
+
capabilities: { tools: {} },
|
|
44
|
+
instructions: DIRECTORY_INSTRUCTIONS,
|
|
45
|
+
});
|
|
46
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
47
|
+
tools: directoryTools(),
|
|
48
|
+
}));
|
|
49
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
50
|
+
const { name, arguments: args } = request.params;
|
|
51
|
+
return runDirectoryTool(ctx, name, args ?? {});
|
|
52
|
+
});
|
|
53
|
+
log("info", `[aifinpay-mcp-directory] read-only profile · api=${ctx.apiBase}`);
|
|
54
|
+
return { server };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAU9B,gFAAgF;AAChF,+EAA+E;AAC/E,iFAAiF;AACjF,MAAM,sBAAsB,GAAG;IAC7B,sEAAsE;IACtE,4EAA4E;IAC5E,2EAA2E;IAC3E,gEAAgE;IAChE,EAAE;IACF,kEAAkE;IAClE,wEAAwE;IACxE,8EAA8E;IAC9E,mEAAmE;IACnE,+EAA+E;IA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CAAC;IAC/E,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
* import { createServer } from "@aifinpay/mcp";
|
|
19
19
|
* import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
20
20
|
*
|
|
21
|
-
* const { server } = createServer({ agentSecretB58: process.env.SECRET });
|
|
21
|
+
* const { server } = await createServer({ agentSecretB58: process.env.SECRET });
|
|
22
22
|
* await server.connect(new StdioServerTransport());
|
|
23
23
|
*/
|
|
24
24
|
export { createServer } from "./server.js";
|
|
25
25
|
export type { ToolContext } from "./server.js";
|
|
26
26
|
export type { McpConfig } from "./config.js";
|
|
27
27
|
export { loadConfigFromEnv } from "./config.js";
|
|
28
|
+
export { createDirectoryServer } from "./directory.js";
|
|
29
|
+
export type { DirectoryServerConfig } from "./directory.js";
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
* import { createServer } from "@aifinpay/mcp";
|
|
19
19
|
* import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
20
20
|
*
|
|
21
|
-
* const { server } = createServer({ agentSecretB58: process.env.SECRET });
|
|
21
|
+
* const { server } = await createServer({ agentSecretB58: process.env.SECRET });
|
|
22
22
|
* await server.connect(new StdioServerTransport());
|
|
23
23
|
*/
|
|
24
24
|
export { createServer } from "./server.js";
|
|
25
25
|
export { loadConfigFromEnv } from "./config.js";
|
|
26
|
+
// Read-only directory profile — the surface submitted to the OpenAI ChatGPT App
|
|
27
|
+
// Directory (no agent, no auth, no payment execution). See directory.ts.
|
|
28
|
+
export { createDirectoryServer } from "./directory.js";
|
|
26
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,gFAAgF;AAChF,yEAAyE;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
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,EAAS,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,MAAM,GAAE,SAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,MAAM,GAAE,SAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGxD;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
|
@@ -39,10 +39,21 @@ export async function createServer(config = {}) {
|
|
|
39
39
|
` >> Save the secret to AIFINPAY_AGENT_SECRET to keep the agent across restarts.`);
|
|
40
40
|
return a;
|
|
41
41
|
})();
|
|
42
|
+
// AIFINPAY_MAX_USD is the documented "hard cap on a single payment".
|
|
43
|
+
// payable_fetch enforces it via PayOptions, but agent_call settles through
|
|
44
|
+
// AiFinPayAgent.call() which only honours the agent's budget caps — wire
|
|
45
|
+
// the cap there too, otherwise the primary tool has NO runaway protection.
|
|
46
|
+
if (config.maxAmountUsd !== undefined && Number.isFinite(config.maxAmountUsd)) {
|
|
47
|
+
agent.setBudget({ per_call_usd: config.maxAmountUsd });
|
|
48
|
+
log("info", `[aifinpay-mcp] per-call cap: $${config.maxAmountUsd} (AIFINPAY_MAX_USD)`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
log("warn", "[aifinpay-mcp] AIFINPAY_MAX_USD not set — agent_call/payable_fetch have NO per-payment cap. Strongly recommended.");
|
|
52
|
+
}
|
|
42
53
|
log("info", `[aifinpay-mcp] solana: ${agent.solanaAddress} · evm: ${agent.evmAddress}`);
|
|
43
54
|
const server = new Server({
|
|
44
55
|
name: "@aifinpay/mcp",
|
|
45
|
-
version: "
|
|
56
|
+
version: "1.0.0",
|
|
46
57
|
}, {
|
|
47
58
|
capabilities: {
|
|
48
59
|
tools: {},
|
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,EAAS,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,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AK,eAAe;gBAClB,OAAO,eAAe,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAC1C,KAAK,YAAY;gBACf,OAAO,YAAY,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YACvC,KAAK,kBAAkB;gBACrB,OAAO,iBAAiB,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAC5C,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,gBAAgB;gBACnB,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;gBACE,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE;wBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE;qBAChD;iBACF,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,sEAAsE;IACtE,kBAAkB;IAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -6,11 +6,38 @@ export declare function agentAddressTool(): {
|
|
|
6
6
|
type: string;
|
|
7
7
|
properties: {};
|
|
8
8
|
};
|
|
9
|
+
annotations: {
|
|
10
|
+
readOnlyHint: boolean;
|
|
11
|
+
openWorldHint: boolean;
|
|
12
|
+
destructiveHint: boolean;
|
|
13
|
+
};
|
|
14
|
+
outputSchema: {
|
|
15
|
+
type: string;
|
|
16
|
+
properties: {
|
|
17
|
+
solana: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
evm: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
note: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
9
31
|
};
|
|
10
32
|
export declare function runAgentAddress(ctx: ToolContext, _args: Record<string, unknown>): Promise<{
|
|
11
33
|
content: {
|
|
12
34
|
type: string;
|
|
13
35
|
text: string;
|
|
14
36
|
}[];
|
|
37
|
+
structuredContent: {
|
|
38
|
+
solana: string;
|
|
39
|
+
evm: string;
|
|
40
|
+
note: string;
|
|
41
|
+
};
|
|
15
42
|
}>;
|
|
16
43
|
//# sourceMappingURL=agent-address.d.ts.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB/B;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;GAgB/B"}
|
|
@@ -10,6 +10,17 @@ export function agentAddressTool() {
|
|
|
10
10
|
type: "object",
|
|
11
11
|
properties: {},
|
|
12
12
|
},
|
|
13
|
+
// OpenAI Apps SDK requires impact hints on every tool (omitting = validation error).
|
|
14
|
+
annotations: { readOnlyHint: true, openWorldHint: false, destructiveHint: false },
|
|
15
|
+
outputSchema: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
solana: { type: "string", description: "Solana base58 address" },
|
|
19
|
+
evm: { type: "string", description: "Polygon/EVM address" },
|
|
20
|
+
note: { type: "string" },
|
|
21
|
+
},
|
|
22
|
+
required: ["solana", "evm"],
|
|
23
|
+
},
|
|
13
24
|
};
|
|
14
25
|
}
|
|
15
26
|
export async function runAgentAddress(ctx, _args) {
|
|
@@ -24,6 +35,7 @@ export async function runAgentAddress(ctx, _args) {
|
|
|
24
35
|
content: [
|
|
25
36
|
{ type: "text", text: JSON.stringify(payload, null, 2) },
|
|
26
37
|
],
|
|
38
|
+
structuredContent: payload,
|
|
27
39
|
};
|
|
28
40
|
}
|
|
29
41
|
//# sourceMappingURL=agent-address.js.map
|
|
@@ -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,mEAAmE;YACnE,yEAAyE;YACzE,oEAAoE;YACpE,oEAAoE;YACpE,0EAA0E;QAC5E,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAgB,EAChB,KAA8B;IAE9B,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,aAAa;QAC/B,GAAG,EAAK,GAAG,CAAC,KAAK,CAAC,UAAU;QAC5B,IAAI,EACF,iEAAiE;YACjE,oEAAoE;YACpE,0EAA0E;KAC7E,CAAC;IACF,OAAO;QACL,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAA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BAAiB,EAAE,OAAO;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -43,6 +43,14 @@ export declare function agentCallTool(): {
|
|
|
43
43
|
};
|
|
44
44
|
required: string[];
|
|
45
45
|
};
|
|
46
|
+
annotations: {
|
|
47
|
+
readOnlyHint: boolean;
|
|
48
|
+
openWorldHint: boolean;
|
|
49
|
+
destructiveHint: boolean;
|
|
50
|
+
};
|
|
51
|
+
outputSchema: {
|
|
52
|
+
type: string;
|
|
53
|
+
};
|
|
46
54
|
};
|
|
47
55
|
export declare function runAgentCall(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
48
56
|
isError: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-call.d.ts","sourceRoot":"","sources":["../../src/tools/agent-call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa
|
|
1
|
+
{"version":3,"file":"agent-call.d.ts","sourceRoot":"","sources":["../../src/tools/agent-call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgD5B;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAkE9B"}
|
package/dist/tools/agent-call.js
CHANGED
|
@@ -17,13 +17,21 @@
|
|
|
17
17
|
export function agentCallTool() {
|
|
18
18
|
return {
|
|
19
19
|
name: "agent_call",
|
|
20
|
-
description: "
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
20
|
+
description: "USE THIS TOOL whenever the user asks to call, pay, query, search via, " +
|
|
21
|
+
"or use any of these AiFinPay-registered paid providers: 'exa' (neural " +
|
|
22
|
+
"web search), 'io-net' (LLM inference, Llama-3.3-70B), 'venice' (image " +
|
|
23
|
+
"generation), or any other provider listed at " +
|
|
24
|
+
"https://aifinpay.io/api/providers. " +
|
|
25
|
+
"DO NOT use WebSearch or WebFetch for these providers — they are paid " +
|
|
26
|
+
"APIs accessible only through this MCP, and a plain web search will " +
|
|
27
|
+
"return public marketing pages instead of the actual API. " +
|
|
28
|
+
"Natural-language triggers that should invoke this tool: 'call exa for X', " +
|
|
29
|
+
"'search exa', 'pay venice to generate Y', 'use io-net to run inference', " +
|
|
30
|
+
"'query exa', 'ask io-net'. Provider name maps to the `provider` argument. " +
|
|
31
|
+
"Body is the provider-specific request shape (e.g. {messages:[...]} for " +
|
|
32
|
+
"io-net inference, {query:'...'} for exa search). Returns the upstream " +
|
|
33
|
+
"response with the Polygon tx hash + Polygonscan link prepended. " +
|
|
34
|
+
"Settlement is automatic — Polygon mainnet, atomic 99/1 split via B2BSplitter.",
|
|
27
35
|
inputSchema: {
|
|
28
36
|
type: "object",
|
|
29
37
|
properties: {
|
|
@@ -49,6 +57,9 @@ export function agentCallTool() {
|
|
|
49
57
|
},
|
|
50
58
|
required: ["provider"],
|
|
51
59
|
},
|
|
60
|
+
// Settles a real on-chain payment to an arbitrary registered provider.
|
|
61
|
+
annotations: { readOnlyHint: false, openWorldHint: true, destructiveHint: true },
|
|
62
|
+
outputSchema: { type: "object" },
|
|
52
63
|
};
|
|
53
64
|
}
|
|
54
65
|
export async function runAgentCall(ctx, args) {
|
|
@@ -81,13 +92,23 @@ export async function runAgentCall(ctx, args) {
|
|
|
81
92
|
parsed = JSON.parse(text);
|
|
82
93
|
}
|
|
83
94
|
catch { /* keep as text */ }
|
|
95
|
+
// Pull the @internal settlement metadata attached by AiFinPayAgent.call
|
|
96
|
+
// (see unifiedAgent.ts). Surfacing the tx hash here lets the agent show
|
|
97
|
+
// a clickable explorer link in chat without re-querying the chain.
|
|
98
|
+
const meta = resp;
|
|
99
|
+
const txHash = meta.aifinpayTx;
|
|
100
|
+
const txChain = meta.aifinpayChain;
|
|
101
|
+
const txLine = txHash
|
|
102
|
+
? `Paid on ${txChain ?? "polygon"}. Tx: ${txHash} → https://${txChain === "solana" ? "solscan.io/tx" : "polygonscan.com/tx"}/${txHash}\n\n`
|
|
103
|
+
: "";
|
|
104
|
+
const bodyText = typeof parsed === "string"
|
|
105
|
+
? parsed
|
|
106
|
+
: JSON.stringify({ status: resp.status, body: parsed }, null, 2);
|
|
84
107
|
return {
|
|
85
108
|
content: [
|
|
86
109
|
{
|
|
87
110
|
type: "text",
|
|
88
|
-
text:
|
|
89
|
-
? parsed
|
|
90
|
-
: JSON.stringify({ status: resp.status, body: parsed }, null, 2),
|
|
111
|
+
text: txLine + bodyText,
|
|
91
112
|
},
|
|
92
113
|
],
|
|
93
114
|
};
|
|
@@ -98,7 +119,7 @@ export async function runAgentCall(ctx, args) {
|
|
|
98
119
|
? "Tip: increase the per-call cost cap or use `agent_quote` to preview before paying."
|
|
99
120
|
: message.toLowerCase().includes("revert") || message.toLowerCase().includes("insufficient")
|
|
100
121
|
? `Tip: ensure the EVM address ${ctx.agent.evmAddress} holds enough POL on Polygon for gas + payment.`
|
|
101
|
-
: `Provider may be misconfigured. Check https://aifinpay.
|
|
122
|
+
: `Provider may be misconfigured. Check https://aifinpay.io/api/providers.`;
|
|
102
123
|
return {
|
|
103
124
|
isError: true,
|
|
104
125
|
content: [{ type: "text", text: `agent_call failed: ${message}\n\n${hint}` }],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-call.js","sourceRoot":"","sources":["../../src/tools/agent-call.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"agent-call.js","sourceRoot":"","sources":["../../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;QAEP,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,QAAQ;YACzC,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEnE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,GAAG,QAAQ;iBACxB;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,IAAI,GACR,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACtC,CAAC,CAAC,oFAAoF;YACtF,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;gBAC1F,CAAC,CAAC,+BAA+B,GAAG,CAAC,KAAK,CAAC,UAAU,iDAAiD;gBACtG,CAAC,CAAC,yEAAyE,CAAC;QAClF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,OAAO,OAAO,IAAI,EAAE,EAAE,CAAC;SAC9E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -4,8 +4,8 @@ import type { ToolContext } from "../server.js";
|
|
|
4
4
|
* autonomously by signing a claim challenge with its own key.
|
|
5
5
|
*
|
|
6
6
|
* Flow (executed inside the tool, no copy-paste between UIs):
|
|
7
|
-
* 1. User signs in to /login on aifinpay.
|
|
8
|
-
* email with URL like `https://aifinpay.
|
|
7
|
+
* 1. User signs in to /login on aifinpay.io → gets a magic-link
|
|
8
|
+
* email with URL like `https://aifinpay.io/api/auth/verify?token=…`
|
|
9
9
|
* 2. User pastes that URL to the agent: "claim yourself on my account
|
|
10
10
|
* using this magic link"
|
|
11
11
|
* 3. Agent calls this tool with the magic_link_url
|
|
@@ -41,6 +41,14 @@ export declare function agentClaimSelfTool(): {
|
|
|
41
41
|
};
|
|
42
42
|
required: string[];
|
|
43
43
|
};
|
|
44
|
+
annotations: {
|
|
45
|
+
readOnlyHint: boolean;
|
|
46
|
+
openWorldHint: boolean;
|
|
47
|
+
destructiveHint: boolean;
|
|
48
|
+
};
|
|
49
|
+
outputSchema: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
44
52
|
};
|
|
45
53
|
export declare function runAgentClaimSelf(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
46
54
|
isError: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-claim-self.d.ts","sourceRoot":"","sources":["../../src/tools/agent-claim-self.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB
|
|
1
|
+
{"version":3,"file":"agent-claim-self.d.ts","sourceRoot":"","sources":["../../src/tools/agent-claim-self.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;EAgCjC;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAgL9B"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* autonomously by signing a claim challenge with its own key.
|
|
4
4
|
*
|
|
5
5
|
* Flow (executed inside the tool, no copy-paste between UIs):
|
|
6
|
-
* 1. User signs in to /login on aifinpay.
|
|
7
|
-
* email with URL like `https://aifinpay.
|
|
6
|
+
* 1. User signs in to /login on aifinpay.io → gets a magic-link
|
|
7
|
+
* email with URL like `https://aifinpay.io/api/auth/verify?token=…`
|
|
8
8
|
* 2. User pastes that URL to the agent: "claim yourself on my account
|
|
9
9
|
* using this magic link"
|
|
10
10
|
* 3. Agent calls this tool with the magic_link_url
|
|
@@ -28,7 +28,7 @@ export function agentClaimSelfTool() {
|
|
|
28
28
|
name: "agent_claim_self",
|
|
29
29
|
description: "Attach this agent to a user's AiFinPay account autonomously. " +
|
|
30
30
|
"Requires a magic-link URL the user got after signing in at " +
|
|
31
|
-
"https://aifinpay.
|
|
31
|
+
"https://aifinpay.io/login. The tool will use the link to " +
|
|
32
32
|
"establish a session, request a claim challenge for this agent's " +
|
|
33
33
|
"EVM address, sign it with the agent's key, and submit the proof. " +
|
|
34
34
|
"After this completes, the user's /me page lists this agent and " +
|
|
@@ -39,7 +39,7 @@ export function agentClaimSelfTool() {
|
|
|
39
39
|
magic_link_url: {
|
|
40
40
|
type: "string",
|
|
41
41
|
description: "The URL the user received in the sign-in email. Looks like " +
|
|
42
|
-
"https://aifinpay.
|
|
42
|
+
"https://aifinpay.io/api/auth/verify?token=… — one-shot, " +
|
|
43
43
|
"expires 15 minutes after the user requested it.",
|
|
44
44
|
},
|
|
45
45
|
label: {
|
|
@@ -49,6 +49,9 @@ export function agentClaimSelfTool() {
|
|
|
49
49
|
},
|
|
50
50
|
required: ["magic_link_url"],
|
|
51
51
|
},
|
|
52
|
+
// Binds the agent to a user account (bounded to AiFinPay; not fund-moving).
|
|
53
|
+
annotations: { readOnlyHint: false, openWorldHint: false, destructiveHint: false },
|
|
54
|
+
outputSchema: { type: "object" },
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
export async function runAgentClaimSelf(ctx, args) {
|
|
@@ -57,7 +60,7 @@ export async function runAgentClaimSelf(ctx, args) {
|
|
|
57
60
|
if (!magicLinkUrl || !magicLinkUrl.includes("/api/auth/verify?token=")) {
|
|
58
61
|
return {
|
|
59
62
|
isError: true,
|
|
60
|
-
content: [{ type: "text", text: "magic_link_url required — should look like https://aifinpay.
|
|
63
|
+
content: [{ type: "text", text: "magic_link_url required — should look like https://aifinpay.io/api/auth/verify?token=…" }],
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
66
|
// Derive API base from the magic link itself so demo can run against
|
|
@@ -155,8 +158,46 @@ export async function runAgentClaimSelf(ctx, args) {
|
|
|
155
158
|
catch (e) {
|
|
156
159
|
solRes = { ok: false, reason: `solana_signer_unavailable: ${e.message}` };
|
|
157
160
|
}
|
|
158
|
-
// ── 4.
|
|
161
|
+
// ── 4. Balance check (best-effort) — drives funded-vs-unfunded copy ─
|
|
162
|
+
// Never block the claim flow on a balance check; if the RPC is down or
|
|
163
|
+
// balance() throws, fall back to the standard funding recommendation.
|
|
164
|
+
let polygonUsdc = 0;
|
|
165
|
+
let solanaUsdc = 0;
|
|
159
166
|
try {
|
|
167
|
+
const bal = await ctx.agent.balance();
|
|
168
|
+
polygonUsdc = bal.chains.polygon.usdc ?? 0;
|
|
169
|
+
solanaUsdc = bal.chains.solana.usdc ?? 0;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
/* swallow — keep funding_recommendation as-is */
|
|
173
|
+
}
|
|
174
|
+
// ── 5. Report ──────────────────────────────────────────────────────
|
|
175
|
+
try {
|
|
176
|
+
// Dashboard URLs live at dashboard.aifinpay.io regardless of
|
|
177
|
+
// which host the user used for magic-link sign-in. apiBase is correct
|
|
178
|
+
// only for /me (which lives at whichever host the user signed in via).
|
|
179
|
+
const DASHBOARD_BASE = "https://dashboard.aifinpay.io";
|
|
180
|
+
// Funded threshold: 0.10 USDC (~4 io-net calls). Below this we still
|
|
181
|
+
// show the funding tip; at-or-above we show a "Funded" status so the
|
|
182
|
+
// agent doesn't tell the user to send money they already sent.
|
|
183
|
+
const FUNDED_USDC_THRESHOLD = 0.10;
|
|
184
|
+
const polygonFunded = polygonUsdc >= FUNDED_USDC_THRESHOLD;
|
|
185
|
+
const fundingFields = polygonFunded
|
|
186
|
+
? {
|
|
187
|
+
funding_status: `Funded — $${polygonUsdc.toFixed(2)} USDC available on Polygon`,
|
|
188
|
+
}
|
|
189
|
+
: {
|
|
190
|
+
// Live bridges (io.net, Exa, Venice) settle on Polygon — fund
|
|
191
|
+
// the Polygon address with USDC for autonomous calls today.
|
|
192
|
+
// Solana is claimed for visibility; SOL-native settlement is
|
|
193
|
+
// available on bridges that advertise pay_solana in their 402.
|
|
194
|
+
funding_recommendation: `Send USDC on Polygon to ${evmAddr} (~0.5 USDC ≈ 20 calls). Optionally fund the Solana address with SOL to use Solana-native bridges.`,
|
|
195
|
+
};
|
|
196
|
+
// Surface Solana USDC status when balance() exposes a non-zero value;
|
|
197
|
+
// schema doesn't currently include solana.usdc but future-proof here.
|
|
198
|
+
if (solanaUsdc >= FUNDED_USDC_THRESHOLD) {
|
|
199
|
+
fundingFields.funding_status_solana = `Funded — $${solanaUsdc.toFixed(2)} USDC available on Solana`;
|
|
200
|
+
}
|
|
160
201
|
return {
|
|
161
202
|
content: [
|
|
162
203
|
{
|
|
@@ -168,12 +209,8 @@ export async function runAgentClaimSelf(ctx, args) {
|
|
|
168
209
|
solana_address: solAddr,
|
|
169
210
|
solana_claim: solRes.ok ? "ok" : `skipped (${solRes.reason})`,
|
|
170
211
|
label: label || null,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// Solana is claimed for visibility; SOL-native settlement is
|
|
174
|
-
// available on bridges that advertise pay_solana in their 402.
|
|
175
|
-
funding_recommendation: `Send USDC on Polygon to ${evmAddr} (~0.5 USDC ≈ 20 calls). Optionally fund the Solana address with SOL to use Solana-native bridges.`,
|
|
176
|
-
next: `Visit ${apiBase}/agents/${evmAddr} (Polygon view) or ${apiBase}/agents/${solAddr} (Solana view). Watchlist: ${apiBase}/me.`,
|
|
212
|
+
...fundingFields,
|
|
213
|
+
next: `Visit ${DASHBOARD_BASE}/agents/${evmAddr} (Polygon view) or ${DASHBOARD_BASE}/agents/${solAddr} (Solana view). Watchlist: ${apiBase}/me.`,
|
|
177
214
|
}, null, 2),
|
|
178
215
|
},
|
|
179
216
|
],
|