@aifinpay/mcp 2.12.2 → 2.14.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 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -2
- package/dist/config.js.map +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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/merchant-site.d.ts +9 -1
- package/dist/merchant-site.d.ts.map +1 -1
- package/dist/merchant-site.js +11 -4
- package/dist/merchant-site.js.map +1 -1
- package/dist/native-price.d.ts +1 -1
- package/dist/native-price.d.ts.map +1 -1
- package/dist/native-price.js +4 -0
- package/dist/native-price.js.map +1 -1
- package/dist/pay-chains.d.ts +4 -0
- package/dist/pay-chains.d.ts.map +1 -1
- package/dist/pay-chains.js.map +1 -1
- package/dist/tools/agent-claim-self.d.ts.map +1 -1
- package/dist/tools/agent-claim-self.js +6 -18
- package/dist/tools/agent-claim-self.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 +253 -0
- package/dist/tools/directory.js.map +1 -0
- package/dist/tools/payable-fetch.d.ts.map +1 -1
- package/dist/tools/payable-fetch.js +14 -4
- package/dist/tools/payable-fetch.js.map +1 -1
- package/dist/tools/production-control.d.ts.map +1 -1
- package/dist/tools/production-control.js +4 -1
- package/dist/tools/production-control.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory tools — the READ-ONLY surface submitted to the OpenAI ChatGPT App
|
|
3
|
+
* Directory. Every tool here is a thin wrapper over a public `api.aifinpay.io`
|
|
4
|
+
* GET endpoint: no agent identity, no keys, no money movement, no auth. This is
|
|
5
|
+
* what makes the directory app reviewable (OpenAI prohibits payment/crypto
|
|
6
|
+
* EXECUTION in directory apps — see Obsidian/32). Execution tools live only on
|
|
7
|
+
* the full BYO-MCP connector (`server.ts`), never here.
|
|
8
|
+
*
|
|
9
|
+
* Each tool declares `readOnlyHint: true`, an `outputSchema`, and ALWAYS returns
|
|
10
|
+
* `structuredContent` matching it (the audit found 4 connector tools that declare
|
|
11
|
+
* outputSchema but return only text — Apps SDK validation may reject that; we
|
|
12
|
+
* don't repeat it).
|
|
13
|
+
*/
|
|
14
|
+
/** Public API base. Defaults to production; override with AIFINPAY_API_BASE. */
|
|
15
|
+
export declare const DIRECTORY_API_BASE: string;
|
|
16
|
+
export interface DirectoryContext {
|
|
17
|
+
apiBase: string;
|
|
18
|
+
timeoutMs: number;
|
|
19
|
+
log: (level: "info" | "warn" | "error", msg: string) => void;
|
|
20
|
+
}
|
|
21
|
+
type ToolResult = {
|
|
22
|
+
content: {
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}[];
|
|
26
|
+
structuredContent?: Record<string, unknown>;
|
|
27
|
+
isError?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare function directoryTools(): ({
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: string;
|
|
34
|
+
properties: {
|
|
35
|
+
name?: undefined;
|
|
36
|
+
chain?: undefined;
|
|
37
|
+
amount?: undefined;
|
|
38
|
+
asset?: undefined;
|
|
39
|
+
pubkey?: undefined;
|
|
40
|
+
address?: undefined;
|
|
41
|
+
};
|
|
42
|
+
required?: undefined;
|
|
43
|
+
};
|
|
44
|
+
annotations: {
|
|
45
|
+
readOnlyHint: boolean;
|
|
46
|
+
openWorldHint: boolean;
|
|
47
|
+
destructiveHint: boolean;
|
|
48
|
+
};
|
|
49
|
+
outputSchema: {
|
|
50
|
+
type: string;
|
|
51
|
+
properties: {
|
|
52
|
+
providers: {
|
|
53
|
+
type: string;
|
|
54
|
+
items: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
covered?: undefined;
|
|
59
|
+
total_seats?: undefined;
|
|
60
|
+
leaderboard?: undefined;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
name: string;
|
|
65
|
+
description: string;
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: string;
|
|
68
|
+
properties: {
|
|
69
|
+
name: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
chain?: undefined;
|
|
74
|
+
amount?: undefined;
|
|
75
|
+
asset?: undefined;
|
|
76
|
+
pubkey?: undefined;
|
|
77
|
+
address?: undefined;
|
|
78
|
+
};
|
|
79
|
+
required: string[];
|
|
80
|
+
};
|
|
81
|
+
annotations: {
|
|
82
|
+
readOnlyHint: boolean;
|
|
83
|
+
openWorldHint: boolean;
|
|
84
|
+
destructiveHint: boolean;
|
|
85
|
+
};
|
|
86
|
+
outputSchema: {
|
|
87
|
+
type: string;
|
|
88
|
+
properties?: undefined;
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: string;
|
|
95
|
+
properties: {
|
|
96
|
+
name?: undefined;
|
|
97
|
+
chain?: undefined;
|
|
98
|
+
amount?: undefined;
|
|
99
|
+
asset?: undefined;
|
|
100
|
+
pubkey?: undefined;
|
|
101
|
+
address?: undefined;
|
|
102
|
+
};
|
|
103
|
+
required?: undefined;
|
|
104
|
+
};
|
|
105
|
+
annotations: {
|
|
106
|
+
readOnlyHint: boolean;
|
|
107
|
+
openWorldHint: boolean;
|
|
108
|
+
destructiveHint: boolean;
|
|
109
|
+
};
|
|
110
|
+
outputSchema: {
|
|
111
|
+
type: string;
|
|
112
|
+
properties?: undefined;
|
|
113
|
+
};
|
|
114
|
+
} | {
|
|
115
|
+
name: string;
|
|
116
|
+
description: string;
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: string;
|
|
119
|
+
properties: {
|
|
120
|
+
name?: undefined;
|
|
121
|
+
chain?: undefined;
|
|
122
|
+
amount?: undefined;
|
|
123
|
+
asset?: undefined;
|
|
124
|
+
pubkey?: undefined;
|
|
125
|
+
address?: undefined;
|
|
126
|
+
};
|
|
127
|
+
required?: undefined;
|
|
128
|
+
};
|
|
129
|
+
annotations: {
|
|
130
|
+
readOnlyHint: boolean;
|
|
131
|
+
openWorldHint: boolean;
|
|
132
|
+
destructiveHint: boolean;
|
|
133
|
+
};
|
|
134
|
+
outputSchema: {
|
|
135
|
+
type: string;
|
|
136
|
+
properties: {
|
|
137
|
+
providers?: undefined;
|
|
138
|
+
covered: {
|
|
139
|
+
type: string;
|
|
140
|
+
items: {
|
|
141
|
+
type: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
total_seats?: undefined;
|
|
145
|
+
leaderboard?: undefined;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
} | {
|
|
149
|
+
name: string;
|
|
150
|
+
description: string;
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: string;
|
|
153
|
+
properties: {
|
|
154
|
+
name?: undefined;
|
|
155
|
+
chain?: undefined;
|
|
156
|
+
amount?: undefined;
|
|
157
|
+
asset?: undefined;
|
|
158
|
+
pubkey?: undefined;
|
|
159
|
+
address?: undefined;
|
|
160
|
+
};
|
|
161
|
+
required?: undefined;
|
|
162
|
+
};
|
|
163
|
+
annotations: {
|
|
164
|
+
readOnlyHint: boolean;
|
|
165
|
+
openWorldHint: boolean;
|
|
166
|
+
destructiveHint: boolean;
|
|
167
|
+
};
|
|
168
|
+
outputSchema: {
|
|
169
|
+
type: string;
|
|
170
|
+
properties: {
|
|
171
|
+
providers?: undefined;
|
|
172
|
+
covered?: undefined;
|
|
173
|
+
total_seats: {
|
|
174
|
+
type: string;
|
|
175
|
+
};
|
|
176
|
+
leaderboard: {
|
|
177
|
+
type: string;
|
|
178
|
+
items: {
|
|
179
|
+
type: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
} | {
|
|
185
|
+
name: string;
|
|
186
|
+
description: string;
|
|
187
|
+
inputSchema: {
|
|
188
|
+
type: string;
|
|
189
|
+
properties: {
|
|
190
|
+
name?: undefined;
|
|
191
|
+
chain: {
|
|
192
|
+
type: string;
|
|
193
|
+
enum: string[];
|
|
194
|
+
};
|
|
195
|
+
amount: {
|
|
196
|
+
type: string;
|
|
197
|
+
description: string;
|
|
198
|
+
};
|
|
199
|
+
asset: {
|
|
200
|
+
type: string;
|
|
201
|
+
enum: string[];
|
|
202
|
+
description: string;
|
|
203
|
+
};
|
|
204
|
+
pubkey?: undefined;
|
|
205
|
+
address?: undefined;
|
|
206
|
+
};
|
|
207
|
+
required: string[];
|
|
208
|
+
};
|
|
209
|
+
annotations: {
|
|
210
|
+
readOnlyHint: boolean;
|
|
211
|
+
openWorldHint: boolean;
|
|
212
|
+
destructiveHint: boolean;
|
|
213
|
+
};
|
|
214
|
+
outputSchema: {
|
|
215
|
+
properties?: undefined;
|
|
216
|
+
type: string;
|
|
217
|
+
};
|
|
218
|
+
} | {
|
|
219
|
+
name: string;
|
|
220
|
+
description: string;
|
|
221
|
+
inputSchema: {
|
|
222
|
+
type: string;
|
|
223
|
+
properties: {
|
|
224
|
+
name?: undefined;
|
|
225
|
+
chain?: undefined;
|
|
226
|
+
amount?: undefined;
|
|
227
|
+
asset?: undefined;
|
|
228
|
+
pubkey: {
|
|
229
|
+
type: string;
|
|
230
|
+
description: string;
|
|
231
|
+
};
|
|
232
|
+
address?: undefined;
|
|
233
|
+
};
|
|
234
|
+
required: string[];
|
|
235
|
+
};
|
|
236
|
+
annotations: {
|
|
237
|
+
readOnlyHint: boolean;
|
|
238
|
+
openWorldHint: boolean;
|
|
239
|
+
destructiveHint: boolean;
|
|
240
|
+
};
|
|
241
|
+
outputSchema: {
|
|
242
|
+
properties?: undefined;
|
|
243
|
+
type: string;
|
|
244
|
+
};
|
|
245
|
+
} | {
|
|
246
|
+
name: string;
|
|
247
|
+
description: string;
|
|
248
|
+
inputSchema: {
|
|
249
|
+
type: string;
|
|
250
|
+
properties: {
|
|
251
|
+
name?: undefined;
|
|
252
|
+
chain?: undefined;
|
|
253
|
+
amount?: undefined;
|
|
254
|
+
asset?: undefined;
|
|
255
|
+
pubkey?: undefined;
|
|
256
|
+
address: {
|
|
257
|
+
type: string;
|
|
258
|
+
description: string;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
required: string[];
|
|
262
|
+
};
|
|
263
|
+
annotations: {
|
|
264
|
+
readOnlyHint: boolean;
|
|
265
|
+
openWorldHint: boolean;
|
|
266
|
+
destructiveHint: boolean;
|
|
267
|
+
};
|
|
268
|
+
outputSchema: {
|
|
269
|
+
properties?: undefined;
|
|
270
|
+
type: string;
|
|
271
|
+
};
|
|
272
|
+
})[];
|
|
273
|
+
export declare function runDirectoryTool(ctx: DirectoryContext, name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
274
|
+
export {};
|
|
275
|
+
//# sourceMappingURL=directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/tools/directory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,QAAkF,CAAC;AAElH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D;AAED,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAyCF,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;gBAiBP,IAAI;gBAAW,KAAK;oBAAI,IAAI;;;;;;;;;;;;;;;gBAavC,IAAI;gBACJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA0BF,IAAI;gBAAW,KAAK;oBAAI,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAsBxB,IAAI;;;gBACJ,IAAI;gBAAW,KAAK;oBAAI,IAAI;;;;;;;;;;;;;gBAalC,IAAI;gBAAY,IAAI;;;gBAE3B,IAAI;gBACJ,WAAW;;;gBAKX,IAAI;gBACJ,IAAI;gBACJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAmBX,IAAI;gBACJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAgBX,IAAI;gBACJ,WAAW;;;;;;;;;;;;;;KAStB;AAID,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,UAAU,CAAC,CAsDrB"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory tools — the READ-ONLY surface submitted to the OpenAI ChatGPT App
|
|
3
|
+
* Directory. Every tool here is a thin wrapper over a public `api.aifinpay.io`
|
|
4
|
+
* GET endpoint: no agent identity, no keys, no money movement, no auth. This is
|
|
5
|
+
* what makes the directory app reviewable (OpenAI prohibits payment/crypto
|
|
6
|
+
* EXECUTION in directory apps — see Obsidian/32). Execution tools live only on
|
|
7
|
+
* the full BYO-MCP connector (`server.ts`), never here.
|
|
8
|
+
*
|
|
9
|
+
* Each tool declares `readOnlyHint: true`, an `outputSchema`, and ALWAYS returns
|
|
10
|
+
* `structuredContent` matching it (the audit found 4 connector tools that declare
|
|
11
|
+
* outputSchema but return only text — Apps SDK validation may reject that; we
|
|
12
|
+
* don't repeat it).
|
|
13
|
+
*/
|
|
14
|
+
/** Public API base. Defaults to production; override with AIFINPAY_API_BASE. */
|
|
15
|
+
export const DIRECTORY_API_BASE = (process.env.AIFINPAY_API_BASE || "https://api.aifinpay.io").replace(/\/$/, "");
|
|
16
|
+
function ok(data) {
|
|
17
|
+
// structuredContent must be an object; wrap bare arrays/primitives.
|
|
18
|
+
const structured = data && typeof data === "object" && !Array.isArray(data) ? data : { result: data };
|
|
19
|
+
return {
|
|
20
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
21
|
+
structuredContent: structured,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function fail(msg) {
|
|
25
|
+
return { isError: true, content: [{ type: "text", text: msg }] };
|
|
26
|
+
}
|
|
27
|
+
async function apiGet(ctx, path) {
|
|
28
|
+
const url = `${ctx.apiBase}${path}`;
|
|
29
|
+
const ctrl = new AbortController();
|
|
30
|
+
const t = setTimeout(() => ctrl.abort(), ctx.timeoutMs);
|
|
31
|
+
try {
|
|
32
|
+
const resp = await fetch(url, {
|
|
33
|
+
headers: { accept: "application/json" },
|
|
34
|
+
signal: ctrl.signal,
|
|
35
|
+
});
|
|
36
|
+
if (!resp.ok) {
|
|
37
|
+
return fail(`upstream ${resp.status} for ${path}`);
|
|
38
|
+
}
|
|
39
|
+
const data = await resp.json();
|
|
40
|
+
return ok(data);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return fail(`request failed for ${path}: ${e.message}`);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
clearTimeout(t);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const RO = { readOnlyHint: true, openWorldHint: false, destructiveHint: false };
|
|
50
|
+
// ── Tool definitions ───────────────────────────────────────────────────────
|
|
51
|
+
export function directoryTools() {
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
name: "list_providers",
|
|
55
|
+
description: "List the AI services available through AiFinPay (e.g. web search, " +
|
|
56
|
+
"image generation, LLM inference) with their per-call price and " +
|
|
57
|
+
"supported networks. Read-only; returns the public provider catalog.",
|
|
58
|
+
inputSchema: { type: "object", properties: {} },
|
|
59
|
+
annotations: RO,
|
|
60
|
+
// Permissive: the upstream provider catalog is the source of truth and its
|
|
61
|
+
// leaf field types vary (e.g. price_usd may be a number or a string for
|
|
62
|
+
// range/tier pricing). The MCP client validates structuredContent against
|
|
63
|
+
// this schema strictly, so we only assert the top-level shape.
|
|
64
|
+
outputSchema: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
providers: { type: "array", items: { type: "object" } },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "provider_info",
|
|
73
|
+
description: "Get the details of one AiFinPay provider by name (price, supported " +
|
|
74
|
+
"networks, service type, homepage). Read-only.",
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties: {
|
|
78
|
+
name: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "Provider name, e.g. 'exa', 'venice', 'io-net'.",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ["name"],
|
|
84
|
+
},
|
|
85
|
+
annotations: RO,
|
|
86
|
+
outputSchema: { type: "object" },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "provider_status",
|
|
90
|
+
description: "Report which AiFinPay provider bridges are currently reachable " + "(up/down). Read-only health view.",
|
|
91
|
+
inputSchema: { type: "object", properties: {} },
|
|
92
|
+
annotations: RO,
|
|
93
|
+
outputSchema: { type: "object" },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "service_coverage",
|
|
97
|
+
description: "Show which categories of AI service (search, compute, …) AiFinPay " +
|
|
98
|
+
"currently covers and the providers in each. Read-only.",
|
|
99
|
+
inputSchema: { type: "object", properties: {} },
|
|
100
|
+
annotations: RO,
|
|
101
|
+
outputSchema: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {
|
|
104
|
+
covered: { type: "array", items: { type: "object" } },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "network_stats",
|
|
110
|
+
description: "Return public protocol statistics: supported networks, number of " +
|
|
111
|
+
"active agents, total settled volume, and active providers. Read-only.",
|
|
112
|
+
inputSchema: { type: "object", properties: {} },
|
|
113
|
+
annotations: RO,
|
|
114
|
+
outputSchema: { type: "object" },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "leaderboard",
|
|
118
|
+
description: "Return the public on-chain leaderboard of AiFinPay agents ranked by " + "settled volume. Read-only.",
|
|
119
|
+
inputSchema: { type: "object", properties: {} },
|
|
120
|
+
annotations: RO,
|
|
121
|
+
outputSchema: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
total_seats: { type: "number" },
|
|
125
|
+
leaderboard: { type: "array", items: { type: "object" } },
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "quote_cost",
|
|
131
|
+
description: "Preview the fee-on-top breakdown (merchant amount + protocol fee + " +
|
|
132
|
+
"creator fee + total) for a given price, WITHOUT making any payment. " +
|
|
133
|
+
"Read-only price calculator.",
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
chain: { type: "string", enum: ["solana", "polygon"] },
|
|
138
|
+
amount: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "Merchant's quoted price in base units: lamports (Solana SOL), " +
|
|
141
|
+
"wei (Polygon POL), or 6-decimal units (Polygon USDC/USDT).",
|
|
142
|
+
},
|
|
143
|
+
asset: {
|
|
144
|
+
type: "string",
|
|
145
|
+
enum: ["SOL", "POL", "USDC", "USDT"],
|
|
146
|
+
description: "Settlement asset. Defaults to SOL on Solana, POL on Polygon. " +
|
|
147
|
+
"Use USDC/USDT for Polygon stablecoin quotes.",
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
required: ["chain", "amount"],
|
|
151
|
+
},
|
|
152
|
+
annotations: RO,
|
|
153
|
+
outputSchema: { type: "object" },
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "verify_passport",
|
|
157
|
+
description: "Check whether an agent public key holds an AiFinPay AgentPassport and " +
|
|
158
|
+
"return its on-chain status. Read-only.",
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
pubkey: {
|
|
163
|
+
type: "string",
|
|
164
|
+
description: "Agent public key (Solana base58 or EVM address).",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
required: ["pubkey"],
|
|
168
|
+
},
|
|
169
|
+
annotations: RO,
|
|
170
|
+
outputSchema: { type: "object" },
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: "agent_profile",
|
|
174
|
+
description: "Return the public profile and activity summary for an AiFinPay agent " + "by its address. Read-only.",
|
|
175
|
+
inputSchema: {
|
|
176
|
+
type: "object",
|
|
177
|
+
properties: {
|
|
178
|
+
address: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Agent address (EVM 0x… or Solana base58).",
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
required: ["address"],
|
|
184
|
+
},
|
|
185
|
+
annotations: RO,
|
|
186
|
+
outputSchema: { type: "object" },
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
// ── Dispatch ────────────────────────────────────────────────────────────────
|
|
191
|
+
export async function runDirectoryTool(ctx, name, args) {
|
|
192
|
+
switch (name) {
|
|
193
|
+
case "list_providers":
|
|
194
|
+
return apiGet(ctx, "/providers");
|
|
195
|
+
case "provider_info": {
|
|
196
|
+
const n = String(args.name ?? "").trim();
|
|
197
|
+
if (!n)
|
|
198
|
+
return fail("missing required arg: name");
|
|
199
|
+
return apiGet(ctx, `/providers/${encodeURIComponent(n)}`);
|
|
200
|
+
}
|
|
201
|
+
case "provider_status":
|
|
202
|
+
return apiGet(ctx, "/providers/status");
|
|
203
|
+
case "service_coverage":
|
|
204
|
+
return apiGet(ctx, "/registry/coverage");
|
|
205
|
+
case "network_stats":
|
|
206
|
+
return apiGet(ctx, "/network-stats");
|
|
207
|
+
case "leaderboard":
|
|
208
|
+
return apiGet(ctx, "/leaderboard");
|
|
209
|
+
case "quote_cost": {
|
|
210
|
+
const chain = String(args.chain ?? "")
|
|
211
|
+
.trim()
|
|
212
|
+
.toLowerCase();
|
|
213
|
+
const amount = String(args.amount ?? "").trim();
|
|
214
|
+
const asset = String(args.asset ?? "")
|
|
215
|
+
.trim()
|
|
216
|
+
.toUpperCase();
|
|
217
|
+
if (!chain || !amount)
|
|
218
|
+
return fail("missing required args: chain, amount");
|
|
219
|
+
const qs = new URLSearchParams();
|
|
220
|
+
if (chain === "solana") {
|
|
221
|
+
qs.set("merchant_amount_lamports", amount);
|
|
222
|
+
}
|
|
223
|
+
else if (chain === "polygon") {
|
|
224
|
+
if (asset === "USDC" || asset === "USDT") {
|
|
225
|
+
qs.set("merchant_amount_units", amount);
|
|
226
|
+
qs.set("asset", asset);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
qs.set("merchant_amount_wei", amount);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
return fail("chain must be 'solana' or 'polygon'");
|
|
234
|
+
}
|
|
235
|
+
return apiGet(ctx, `/b2b/quote-split?${qs.toString()}`);
|
|
236
|
+
}
|
|
237
|
+
case "verify_passport": {
|
|
238
|
+
const pk = String(args.pubkey ?? "").trim();
|
|
239
|
+
if (!pk)
|
|
240
|
+
return fail("missing required arg: pubkey");
|
|
241
|
+
return apiGet(ctx, `/passport/${encodeURIComponent(pk)}`);
|
|
242
|
+
}
|
|
243
|
+
case "agent_profile": {
|
|
244
|
+
const addr = String(args.address ?? "").trim();
|
|
245
|
+
if (!addr)
|
|
246
|
+
return fail("missing required arg: address");
|
|
247
|
+
return apiGet(ctx, `/network/agents/${encodeURIComponent(addr)}`);
|
|
248
|
+
}
|
|
249
|
+
default:
|
|
250
|
+
return fail(`unknown directory tool: ${name}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/tools/directory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,yBAAyB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAclH,SAAS,EAAE,CAAC,IAAa;IACvB,oEAAoE;IACpE,MAAM,UAAU,GACd,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAAgC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClH,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAChE,iBAAiB,EAAE,UAAU;KAC9B,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC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gBACJ,OAAO;gBACP,WAAW;;;QAIf,QAAQ;QACR,oBAAoB;;IAEtB,WAAW;QAAI,YAAY;QAAS,aAAa;QAAQ,eAAe;;EAE3E;AAED,2FAA2F;AAC3F,wBAAsB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"payable-fetch.d.ts","sourceRoot":"","sources":["../../src/tools/payable-fetch.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAmBhD,wBAAgB,gBAAgB;IAE5B,IAAI;IACJ,WAAW;IAEX,WAAW;QACT,IAAI;QACJ,UAAU;YACR,GAAG;gBACD,IAAI;gBACJ,WAAW;;YAGb,cAAc;gBACZ,IAAI;gBACJ,gBAAgB;gBAChB,WAAW;;YAEb,KAAK;gBACH,IAAI;gBACJ,IAAI;gBACJ,WAAW;;YAGb,oBAAoB;gBAClB,IAAI;gBACJ,OAAO;gBACP,WAAW;;;QAIf,QAAQ;QACR,oBAAoB;;IAEtB,WAAW;QAAI,YAAY;QAAS,aAAa;QAAQ,eAAe;;EAE3E;AAED,2FAA2F;AAC3F,wBAAsB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;GAyapF"}
|
|
@@ -17,7 +17,7 @@ const HOSTED_GATEWAY_ORIGIN = "https://gateway.aifinpay.io";
|
|
|
17
17
|
export function payableFetchTool() {
|
|
18
18
|
return {
|
|
19
19
|
name: "payable_fetch",
|
|
20
|
-
description: 'Fetch a GET resource from an AiFinPay merchant, paying its AIFP-1 402 when needed. Always listed: until a persistent wallet exists (npx @aifinpay/mcp init, then agent_reload) it signs nothing and returns the payment_setup_status checklist with the one next step. Payments are on by default within a built-in ceiling of $5 per payment and $20 per 24 hours (the owner can only lower it in env; the working limits are the dashboard Controls after agent_claim_self) and only ever reach a merchant registered with AiFinPay, through a quote signed by the AiFinPay backend; a 402 never chooses who is paid. Without AIFINPAY_GATEWAY_ORIGINS it pays only a merchant whose site AiFinPay reports as DNS-verified, on that very site (or through the AiFinPay hosted gateway); with it, only the origins the owner listed; AIFINPAY_PAYMENTS_ENABLED=0 turns payments off. Buys a prepaid batch through verified v1.4 on the chain the owner set in AIFINPAY_PAY_CHAIN (Polygon by default; other supported networks require explicit owner selection) — in its native currency (POL, SOL, ETH, AVAX, BNB or XRP), or in the stablecoin the owner set in AIFINPAY_PAY_ASSET (e.g. USDC; gas is still native) — within owner limits, then reuses its receipt. With scope "merchant" one batch covers every path on the site. Pending payments are recovered without sending another transaction. Other payment protocols are unsupported.',
|
|
20
|
+
description: 'Fetch a GET resource from an AiFinPay merchant, paying its AIFP-1 402 when needed. Always listed: until a persistent wallet exists (npx @aifinpay/mcp init, then agent_reload) it signs nothing and returns the payment_setup_status checklist with the one next step. Payments are on by default within a built-in ceiling of $5 per payment and $20 per 24 hours (the owner can only lower it in env; the working limits are the dashboard Controls after agent_claim_self) and only ever reach a merchant registered with AiFinPay, through a quote signed by the AiFinPay backend; a 402 never chooses who is paid. Without AIFINPAY_GATEWAY_ORIGINS it pays only a merchant whose site AiFinPay reports as DNS-verified, on that very site (or through the AiFinPay hosted gateway); with it, only the origins the owner listed; AIFINPAY_PAYMENTS_ENABLED=0 turns payments off. Buys a prepaid batch through verified v1.4 on the chain the owner set in AIFINPAY_PAY_CHAIN (Polygon by default; other supported networks require explicit owner selection) — in its native currency (POL, SOL, ETH, AVAX, BNB or XRP), or in the stablecoin the owner set in AIFINPAY_PAY_ASSET (e.g. USDC; gas is still native; on Arc only USDC, which is also its gas) — within owner limits, then reuses its receipt. With scope "merchant" one batch covers every path on the site. Pending payments are recovered without sending another transaction. Other payment protocols are unsupported.',
|
|
21
21
|
inputSchema: {
|
|
22
22
|
type: "object",
|
|
23
23
|
properties: {
|
|
@@ -98,6 +98,8 @@ export async function runPayableFetch(ctx, args) {
|
|
|
98
98
|
const parsed = parseGatewayUrl(url.href, origins, pathMode);
|
|
99
99
|
const pay = chain;
|
|
100
100
|
const payAsset = ctx.config.payAsset ?? pay.native;
|
|
101
|
+
// On Arc the native symbol names the USDC token: always the token path.
|
|
102
|
+
const stablePay = payAsset !== pay.native || pay.stablecoinOnly === true;
|
|
101
103
|
const rpc = ctx.config.rpcUrl ?? pay.defaultRpc;
|
|
102
104
|
return await store.exclusive(async () => {
|
|
103
105
|
state = store.read();
|
|
@@ -301,12 +303,12 @@ export async function runPayableFetch(ctx, args) {
|
|
|
301
303
|
: {
|
|
302
304
|
v14: {
|
|
303
305
|
chain: pay.name,
|
|
304
|
-
...(
|
|
306
|
+
...(stablePay ? { asset: payAsset } : {}),
|
|
305
307
|
maxGasWei: feeCap,
|
|
306
308
|
onPrepared: async (prepared) => {
|
|
307
309
|
await confirmPayee(prepared.quote.merchant_id);
|
|
308
310
|
let usd;
|
|
309
|
-
if (
|
|
311
|
+
if (stablePay) {
|
|
310
312
|
if (prepared.asset !== payAsset)
|
|
311
313
|
throw new Error("Prepared payment is not in the configured asset");
|
|
312
314
|
usd = Number(prepared.quote.amount);
|
|
@@ -395,7 +397,15 @@ export async function runPayableFetch(ctx, args) {
|
|
|
395
397
|
: ". This merchant id cannot be confirmed through this tool."));
|
|
396
398
|
}
|
|
397
399
|
if (!state?.pending && error instanceof UnverifiedMerchantSiteError) {
|
|
398
|
-
|
|
400
|
+
// Name the ways forward, so neither the agent nor the owner improvises a
|
|
401
|
+
// third one: another tool, a direct transfer or a retry loop.
|
|
402
|
+
const noOtherWay = "Do not try another way to pay this site: no other tool, SDK call or direct transfer.";
|
|
403
|
+
const allowlist = `add ${error.origin} to AIFINPAY_GATEWAY_ORIGINS in this MCP server's env (comma-separated https origins; once it is set, only the listed sites are paid) and restart the MCP client`;
|
|
404
|
+
return errorResult(error.kind === "unconfirmed"
|
|
405
|
+
? `${error.message} The AiFinPay lookup of this merchant failed. Try once more in a minute; if it fails again, stop and tell the owner. ${noOtherWay}`
|
|
406
|
+
: error.kind === "other_site"
|
|
407
|
+
? `${error.message} The site being paid for is not the one this merchant verified, so this 402 may be steering the payment to someone else. Do not retry. ${noOtherWay} Tell the owner; only if they know ${error.origin} belongs to this merchant should they ${allowlist}.`
|
|
408
|
+
: `${error.message} Do not retry. ${noOtherWay} Tell the owner there are two fixes: the merchant verifies this site's domain with AiFinPay (dash.aifinpay.io → Sites → DNS TXT record), or, if the owner knows and trusts ${error.origin}, they ${allowlist}. Then retry once.`);
|
|
399
409
|
}
|
|
400
410
|
if (!state?.pending && error instanceof Aifp1GatewayRetiredError) {
|
|
401
411
|
return errorResult(`${error.site} is retired: the gateway no longer serves this site (410 gateway_retired). Nothing was quoted or paid. Do not retry this request or pay for it again; tell the owner.`);
|