@aifinpay/mcp 2.0.0-rc.12 → 2.0.0-rc.13

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.
@@ -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,sBA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,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QACjD,OAAO,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,EAAE,oDAAoD,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/E,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { ToolContext } from "../server.js";
2
+ /**
3
+ * `agent_call` — unified registry-resolved paid HTTP call.
4
+ *
5
+ * The agent picks a provider by name ("exa", "io-net", "venice", …),
6
+ * the SDK looks up the bridge URL + price from the public AiFinPay
7
+ * registry, negotiates the 402 challenge, settles on Polygon via
8
+ * B2BSplitter.payMatic, retries with proof, and returns the upstream
9
+ * response body.
10
+ *
11
+ * Use this in preference to `payable_fetch` when you have a registered
12
+ * provider name — it auto-routes price, chain, and bridge URL.
13
+ *
14
+ * Requires the EVM address (from `agent_address`) to be funded with POL
15
+ * on Polygon mainnet (gas + payment), or USDC if the provider quotes in
16
+ * stablecoin.
17
+ */
18
+ export declare function agentCallTool(): {
19
+ name: string;
20
+ description: string;
21
+ inputSchema: {
22
+ type: string;
23
+ properties: {
24
+ provider: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ body: {
29
+ type: string;
30
+ description: string;
31
+ additionalProperties: boolean;
32
+ };
33
+ method: {
34
+ type: string;
35
+ enum: string[];
36
+ default: string;
37
+ description: string;
38
+ };
39
+ cost: {
40
+ type: string;
41
+ description: string;
42
+ };
43
+ };
44
+ required: string[];
45
+ };
46
+ annotations: {
47
+ readOnlyHint: boolean;
48
+ openWorldHint: boolean;
49
+ destructiveHint: boolean;
50
+ };
51
+ outputSchema: {
52
+ type: string;
53
+ };
54
+ };
55
+ export declare function runAgentCall(ctx: ToolContext, args: Record<string, unknown>): Promise<{
56
+ isError: boolean;
57
+ content: {
58
+ type: string;
59
+ text: string;
60
+ }[];
61
+ } | {
62
+ content: {
63
+ type: string;
64
+ text: string;
65
+ }[];
66
+ isError?: undefined;
67
+ }>;
68
+ //# sourceMappingURL=agent-call.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgD5B;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAkE9B"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * `agent_call` — unified registry-resolved paid HTTP call.
3
+ *
4
+ * The agent picks a provider by name ("exa", "io-net", "venice", …),
5
+ * the SDK looks up the bridge URL + price from the public AiFinPay
6
+ * registry, negotiates the 402 challenge, settles on Polygon via
7
+ * B2BSplitter.payMatic, retries with proof, and returns the upstream
8
+ * response body.
9
+ *
10
+ * Use this in preference to `payable_fetch` when you have a registered
11
+ * provider name — it auto-routes price, chain, and bridge URL.
12
+ *
13
+ * Requires the EVM address (from `agent_address`) to be funded with POL
14
+ * on Polygon mainnet (gas + payment), or USDC if the provider quotes in
15
+ * stablecoin.
16
+ */
17
+ export function agentCallTool() {
18
+ return {
19
+ name: "agent_call",
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.",
35
+ inputSchema: {
36
+ type: "object",
37
+ properties: {
38
+ provider: {
39
+ type: "string",
40
+ description: "Registered provider name. Example: 'io-net', 'exa', 'venice'.",
41
+ },
42
+ body: {
43
+ type: "object",
44
+ description: "Provider-specific request body. Forwarded to the bridge after payment.",
45
+ additionalProperties: true,
46
+ },
47
+ method: {
48
+ type: "string",
49
+ enum: ["GET", "POST"],
50
+ default: "POST",
51
+ description: "HTTP method. Defaults to POST (matches all current providers).",
52
+ },
53
+ cost: {
54
+ type: "number",
55
+ description: "Optional override of the registry-quoted price (USD). Use to enforce a stricter budget cap.",
56
+ },
57
+ },
58
+ required: ["provider"],
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" },
63
+ };
64
+ }
65
+ export async function runAgentCall(ctx, args) {
66
+ const provider = args.provider;
67
+ const body = args.body;
68
+ const method = args.method ?? "POST";
69
+ const cost = args.cost;
70
+ if (!provider) {
71
+ return {
72
+ isError: true,
73
+ content: [{ type: "text", text: "`provider` is required (e.g. 'exa', 'io-net')" }],
74
+ };
75
+ }
76
+ try {
77
+ const resp = await ctx.agent.call({
78
+ provider,
79
+ body,
80
+ method,
81
+ cost,
82
+ });
83
+ if (resp === null) {
84
+ return {
85
+ isError: true,
86
+ content: [{ type: "text", text: "Call skipped — budget cap exceeded (on_limit_exceeded='skip')." }],
87
+ };
88
+ }
89
+ const text = await resp.text();
90
+ let parsed = text;
91
+ try {
92
+ parsed = JSON.parse(text);
93
+ }
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);
107
+ return {
108
+ content: [
109
+ {
110
+ type: "text",
111
+ text: txLine + bodyText,
112
+ },
113
+ ],
114
+ };
115
+ }
116
+ catch (err) {
117
+ const message = err instanceof Error ? err.message : String(err);
118
+ const hint = message.toLowerCase().includes("budget")
119
+ ? "Tip: increase the per-call cost cap or use `agent_quote` to preview before paying."
120
+ : message.toLowerCase().includes("revert") || message.toLowerCase().includes("insufficient")
121
+ ? `Tip: ensure the EVM address ${ctx.agent.evmAddress} holds enough POL on Polygon for gas + payment.`
122
+ : `Provider may be misconfigured. Check https://aifinpay.io/api/providers.`;
123
+ return {
124
+ isError: true,
125
+ content: [{ type: "text", text: `agent_call failed: ${message}\n\n${hint}` }],
126
+ };
127
+ }
128
+ }
129
+ //# sourceMappingURL=agent-call.js.map
@@ -0,0 +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,wEAAwE;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AC,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"}
@@ -0,0 +1,66 @@
1
+ import type { ToolContext } from "../server.js";
2
+ /**
3
+ * `agent_claim_self` — agent attaches itself to a user's AiFinPay account
4
+ * autonomously by signing a claim challenge with its own key.
5
+ *
6
+ * Flow (executed inside the tool, no copy-paste between UIs):
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
+ * 2. User pastes that URL to the agent: "claim yourself on my account
10
+ * using this magic link"
11
+ * 3. Agent calls this tool with the magic_link_url
12
+ * 4. Tool hits the magic link → server issues session cookie
13
+ * 5. Tool POSTs to /api/me/agents/challenge with the agent's EVM address
14
+ * 6. Tool signs the returned message with the agent's EVM key (EIP-191)
15
+ * 7. Tool POSTs to /api/me/agents/claim → server verifies signature →
16
+ * agent attached to user's watchlist
17
+ *
18
+ * Optional `label` field gives the agent a friendly name in the user's UI.
19
+ *
20
+ * Security model:
21
+ * - Magic-link URL is one-shot, 15-min TTL, identifies the user
22
+ * - Signature proves the agent holds the EVM private key
23
+ * - Combination: "this user OWNS this agent". Either alone is
24
+ * insufficient (signature alone can't pick an account; magic link
25
+ * alone can't prove key control).
26
+ */
27
+ export declare function agentClaimSelfTool(): {
28
+ name: string;
29
+ description: string;
30
+ inputSchema: {
31
+ type: string;
32
+ properties: {
33
+ magic_link_url: {
34
+ type: string;
35
+ description: string;
36
+ };
37
+ label: {
38
+ type: string;
39
+ description: string;
40
+ };
41
+ };
42
+ required: string[];
43
+ };
44
+ annotations: {
45
+ readOnlyHint: boolean;
46
+ openWorldHint: boolean;
47
+ destructiveHint: boolean;
48
+ };
49
+ outputSchema: {
50
+ type: string;
51
+ };
52
+ };
53
+ export declare function runAgentClaimSelf(ctx: ToolContext, args: Record<string, unknown>): Promise<{
54
+ isError: boolean;
55
+ content: {
56
+ type: string;
57
+ text: string;
58
+ }[];
59
+ } | {
60
+ content: {
61
+ type: string;
62
+ text: string;
63
+ }[];
64
+ isError?: undefined;
65
+ }>;
66
+ //# sourceMappingURL=agent-claim-self.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;EAgCjC;AAiED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GA4L9B"}