@cmdoss/suipay-mcp 0.2.2-dev.4 → 0.2.2-dev.6

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.
@@ -55,7 +55,19 @@ interface McpAuthContext {
55
55
  listReceipts?: (challengeId?: string) => Promise<SettlementDTO[]>;
56
56
  }
57
57
 
58
+ type McpTarget = 'dev' | 'local';
59
+ /**
60
+ * Public suipay-dev origins (Railway). `local` is the laptop stack from
61
+ * `pnpm demo:testnet`. Explicit `SUIPAY_GATEWAY_URL` / `SUIPAY_CONSOLE_URL`
62
+ * still win over the preset.
63
+ */
64
+ declare const MCP_TARGET_PRESETS: Record<McpTarget, {
65
+ consoleUrl: string;
66
+ gatewayUrl: string;
67
+ }>;
58
68
  interface McpConfig {
69
+ /** Preset used when console/gateway env is unset. Set by `loadMcpConfig`. */
70
+ target?: McpTarget;
59
71
  consoleUrl: string;
60
72
  gatewayUrl: string;
61
73
  rpcUrl: string;
@@ -68,7 +80,15 @@ interface McpConfig {
68
80
  minMaxPerPayment: bigint;
69
81
  label: string;
70
82
  }
71
- declare function loadMcpConfig(env?: NodeJS.ProcessEnv): McpConfig;
83
+ /**
84
+ * CLI flags: `--local` / `-local`, `--dev` / `-dev`. Unknown args are ignored
85
+ * so an MCP host can pass extra argv without breaking stdio.
86
+ */
87
+ declare function parseMcpTargetFlag(argv: readonly string[]): McpTarget | undefined;
88
+ declare function resolveMcpTarget(env?: NodeJS.ProcessEnv, argv?: readonly string[]): McpTarget;
89
+ /** Same public origin, or the same laptop loopback port (`localhost` ≡ `127.0.0.1`). */
90
+ declare function sameMcpGateway(a: string, b: string): boolean;
91
+ declare function loadMcpConfig(env?: NodeJS.ProcessEnv, argv?: readonly string[]): McpConfig;
72
92
 
73
93
  /**
74
94
  * Agent-held settlement wiring for the `pay` tool.
@@ -262,6 +282,14 @@ declare const TOOLS: readonly [{
262
282
  readonly type: "object";
263
283
  readonly description: "JSON request body for a POST. Sent as application/json and bound to the payment.";
264
284
  };
285
+ readonly file: {
286
+ readonly type: "string";
287
+ readonly description: "Absolute path under SUIPAY_MCP_FILE_ROOT (unset disables attach). Stdio POST only; requires fileField. Regular non-empty file whose decoded size fits the paid-body ceiling. Not a URL, FIFO, device, or path under ~/.suipay. Bytes fill json[fileField] as canonical base64.";
288
+ };
289
+ readonly fileField: {
290
+ readonly type: "string";
291
+ readonly description: "JSON key to set from file (e.g. contentBase64). Required with file. Pattern [A-Za-z][A-Za-z0-9_]{0,63}. Must not already be present on json.";
292
+ };
265
293
  readonly recipient: {
266
294
  readonly type: "string";
267
295
  readonly description: "Sui address you expect to be paid. The payment is refused, unsigned, if the prepared transaction pays anyone else.";
@@ -275,7 +303,7 @@ declare const TOOLS: readonly [{
275
303
  };
276
304
  }, {
277
305
  readonly name: "discover";
278
- readonly description: "Search SuiPay gateway resources.";
306
+ readonly description: "Search SuiPay gateway resources. After login, each row includes name, path, url, catalog price, and whether the current session can cover one call at that price (descriptive only — pay still enforces the grant).";
279
307
  readonly inputSchema: {
280
308
  readonly type: "object";
281
309
  readonly properties: {
@@ -299,7 +327,7 @@ declare const TOOLS: readonly [{
299
327
  };
300
328
  }, {
301
329
  readonly name: "suipay_login";
302
- readonly description: "Mint or reuse the local delegate key (version-2, mode 0600) and open the console with the public address only so the owner can bind a spend-account grant. Stdio only; hosted /mcp never holds a spendable key.";
330
+ readonly description: "Mint or reuse the local delegate key (version-2, mode 0600) and return a clickable console URL immediately so the owner can bind a spend-account grant. Does not wait for the wallet. Default target is Railway suipay-dev; pass target=\"local\" (or start the binary with --local) for the laptop stack. Stdio only; hosted /mcp never holds a spendable key.";
303
331
  readonly inputSchema: {
304
332
  readonly type: "object";
305
333
  readonly properties: {
@@ -307,6 +335,11 @@ declare const TOOLS: readonly [{
307
335
  readonly type: "string";
308
336
  readonly description: "Label shown in SuiPay console.";
309
337
  };
338
+ readonly target: {
339
+ readonly type: "string";
340
+ readonly enum: readonly ["dev", "local"];
341
+ readonly description: "Where to bind the grant. Default is Railway suipay-dev. Pass \"local\" for localhost:3000 / 127.0.0.1:4340.";
342
+ };
310
343
  readonly gatewayResourceUrl: {
311
344
  readonly type: "string";
312
345
  readonly description: "Gateway resource URL whose 402 defines recipient, asset, and package.";
@@ -345,6 +378,11 @@ interface McpServerOptions {
345
378
  * does not already authorize.
346
379
  */
347
380
  resolveAgentHeld?: AgentHeldResolver;
381
+ /**
382
+ * Wire that created this server. Hosted HTTP never forwards `file` into `pay`.
383
+ * Stdio is the default so existing tests stay local.
384
+ */
385
+ transport?: 'stdio' | 'http';
348
386
  }
349
387
  declare function createServer(cfg: McpConfig, auth?: McpAuthContext, trace?: McpTraceHooks, options?: McpServerOptions): Server;
350
388
 
@@ -364,4 +402,4 @@ declare function createServer(cfg: McpConfig, auth?: McpAuthContext, trace?: Mcp
364
402
  */
365
403
  declare function handleSuipayMcpHttpRequest(req: Request, cfg: McpConfig, auth?: McpAuthContext, trace?: McpTraceRuntime | null, options?: McpServerOptions): Promise<Response>;
366
404
 
367
- export { type AgentHeldResolver as A, type McpConfig as M, PACKAGE_NAME as P, TOOLS as T, type McpAuthContext as a, type McpTraceHooks as b, type AgentHeldSettlement as c, type McpEnvelope as d, type McpEnvelopeEntry as e, type McpServerOptions as f, type McpTraceContext as g, type McpTraceRuntime as h, canonicalMcpRequestId as i, createServer as j, handleSuipayMcpHttpRequest as k, inspectMcpEnvelope as l, loadMcpConfig as m, resolveAgentHeldSettlement as n, resetAgentHeldProcessLedger as r, traceMcpHttpRequest as t };
405
+ export { type AgentHeldResolver as A, type McpConfig as M, PACKAGE_NAME as P, TOOLS as T, type McpAuthContext as a, type McpTraceHooks as b, type AgentHeldSettlement as c, MCP_TARGET_PRESETS as d, type McpEnvelope as e, type McpEnvelopeEntry as f, type McpServerOptions as g, type McpTarget as h, type McpTraceContext as i, type McpTraceRuntime as j, canonicalMcpRequestId as k, createServer as l, handleSuipayMcpHttpRequest as m, inspectMcpEnvelope as n, loadMcpConfig as o, parseMcpTargetFlag as p, resolveAgentHeldSettlement as q, resetAgentHeldProcessLedger as r, resolveMcpTarget as s, sameMcpGateway as t, traceMcpHttpRequest as u };
package/dist/http.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { k as handleSuipayMcpHttpRequest } from './http-C8xW9F1c.js';
1
+ export { m as handleSuipayMcpHttpRequest } from './http-DBP9qgVw.js';
2
2
  import '@cmdoss/suipay-core/policy/grant-target';
3
3
  import '@cmdoss/suipay-sdk/mcp/access-context';
4
4
  import '@cmdoss/suipay-sdk/buyer/settlement-dto';
package/dist/http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleSuipayMcpHttpRequest
3
- } from "./chunk-KDOGSB5I.js";
3
+ } from "./chunk-UTKVBAEZ.js";
4
4
  export {
5
5
  handleSuipayMcpHttpRequest
6
6
  };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { Wallet } from '@cmdoss/suipay-core/chain/types';
2
- import { M as McpConfig, a as McpAuthContext, b as McpTraceHooks } from './http-C8xW9F1c.js';
3
- export { A as AgentHeldResolver, c as AgentHeldSettlement, d as McpEnvelope, e as McpEnvelopeEntry, f as McpServerOptions, g as McpTraceContext, h as McpTraceRuntime, P as PACKAGE_NAME, T as TOOLS, i as canonicalMcpRequestId, j as createServer, k as handleSuipayMcpHttpRequest, l as inspectMcpEnvelope, m as loadMcpConfig, r as resetAgentHeldProcessLedger, n as resolveAgentHeldSettlement, t as traceMcpHttpRequest } from './http-C8xW9F1c.js';
2
+ import { M as McpConfig, a as McpAuthContext, b as McpTraceHooks } from './http-DBP9qgVw.js';
3
+ export { A as AgentHeldResolver, c as AgentHeldSettlement, d as MCP_TARGET_PRESETS, e as McpEnvelope, f as McpEnvelopeEntry, g as McpServerOptions, h as McpTarget, i as McpTraceContext, j as McpTraceRuntime, P as PACKAGE_NAME, T as TOOLS, k as canonicalMcpRequestId, l as createServer, m as handleSuipayMcpHttpRequest, n as inspectMcpEnvelope, o as loadMcpConfig, p as parseMcpTargetFlag, r as resetAgentHeldProcessLedger, q as resolveAgentHeldSettlement, s as resolveMcpTarget, t as sameMcpGateway, u as traceMcpHttpRequest } from './http-DBP9qgVw.js';
4
4
  import { GrantSnapshot } from '@cmdoss/suipay-core/policy/grant-target';
5
5
  export { resolveGrantTarget } from '@cmdoss/suipay-core/policy/grant-target';
6
6
  import { PaidHttpRequest } from '@cmdoss/suipay-sdk/protocol/paid-http-request';
7
7
  import { TraceSink } from '@cmdoss/suipay-core/trace/types';
8
8
  import { Dialect } from '@cmdoss/suipay-sdk/protocol/types';
9
- import { GetObjectJson } from '@cmdoss/suipay-sdk/agent-sdk/reads';
9
+ import { GetObjectJson, createReader } from '@cmdoss/suipay-sdk/agent-sdk/reads';
10
10
  import { DelegatedKeySigner, DelegatedPayerSession, DelegatedPayerConfig, DelegatedPayerDeps, SpendIntent, DelegatedPayResult } from '@cmdoss/suipay-sdk/delegated-signer/payer';
11
+ import { createPayer } from '@cmdoss/suipay-sdk/agent-sdk/delegate-agent';
11
12
  import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
12
13
  import '@cmdoss/suipay-sdk/mcp/access-context';
13
14
  import '@cmdoss/suipay-sdk/buyer/settlement-dto';
@@ -48,11 +49,6 @@ interface PaymentProfile {
48
49
  * and point operators at delegate OAuth / delegated-signer flows.
49
50
  */
50
51
  declare function loadPaymentProfile(): PaymentProfile | null;
51
- /**
52
- * First authorization generates a local keypair and persists it at 0600.
53
- * Re-authorization reuses the stored key so a second key cannot orphan the grant.
54
- * Returns only the public identity.
55
- */
56
52
  declare function ensureLocalSigningKey(opts?: {
57
53
  label?: string;
58
54
  }): Promise<LocalSigningKeyIdentity>;
@@ -319,12 +315,40 @@ declare function settlePreparedMcpPayment(args: {
319
315
  intent?: SpendIntent;
320
316
  }): Promise<DelegatedPayResult>;
321
317
 
318
+ interface StdioLoginOptions {
319
+ consoleUrl: string;
320
+ gatewayUrl: string;
321
+ identity: {
322
+ delegateAddress: string;
323
+ publicKeyHex: string;
324
+ };
325
+ label?: string;
326
+ timeoutMs?: number;
327
+ openBrowser?: boolean;
328
+ onUrl?: (connectUrl: string) => void;
329
+ }
330
+ interface StartedStdioLogin {
331
+ connectUrl: string;
332
+ port: number;
333
+ connectState: string;
334
+ done: Promise<void>;
335
+ close: () => void;
336
+ }
337
+ /**
338
+ * Bind the loopback listener and return the console URL immediately.
339
+ * The wallet callback is awaited on `done`, not on the MCP tool call.
340
+ */
341
+ declare function startStdioLogin(opts: StdioLoginOptions): Promise<StartedStdioLogin>;
342
+
322
343
  type ToolResult = CallToolResult;
344
+
323
345
  interface ToolDeps {
324
346
  fetchImpl?: typeof fetch;
325
347
  profileLoader?: () => PaymentProfile | null;
326
348
  /** Remote HTTP auth (grant + scope + optional shared-pool pay session). */
327
349
  auth?: McpAuthContext;
350
+ /** Wire transport. Hosted HTTP never reads a buyer path. */
351
+ transport?: 'stdio' | 'http';
328
352
  /**
329
353
  * Proxy-resolved live trace for this MCP request. Observation only: it never
330
354
  * changes which rail runs, what is paid, or whether a payment is allowed.
@@ -347,17 +371,22 @@ interface ToolDeps {
347
371
  * carries the delegate address only — never the seed.
348
372
  */
349
373
  onUrl?: (url: string) => void;
374
+ createPayer?: typeof createPayer;
375
+ createReader?: typeof createReader;
376
+ startStdioLogin?: typeof startStdioLogin;
350
377
  }
351
378
  declare function pay(args: {
352
379
  url: string;
353
380
  method?: unknown;
354
381
  json?: unknown;
382
+ file?: unknown;
383
+ fileField?: unknown;
355
384
  recipient?: unknown;
356
385
  maxAmount?: unknown;
357
386
  }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
358
387
  declare function receipts(args: {
359
388
  challengeId?: string;
360
- }, _cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
389
+ }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
361
390
 
362
391
  declare function loadBootProfile(load?: typeof loadPaymentProfile): {
363
392
  profile: ReturnType<typeof loadPaymentProfile>;
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  loadBootProfile,
3
3
  main
4
- } from "./chunk-XAM2YQC6.js";
4
+ } from "./chunk-AEV6Q6JC.js";
5
5
  import {
6
+ MCP_TARGET_PRESETS,
6
7
  PACKAGE_NAME,
7
8
  TOOLS,
8
9
  buildSpendAccountPayKind,
@@ -13,17 +14,21 @@ import {
13
14
  inspectMcpEnvelope,
14
15
  loadLocalSigner,
15
16
  loadMcpConfig,
17
+ parseMcpTargetFlag,
16
18
  pay,
17
19
  prepareSpendAccountPayment,
18
20
  receipts,
19
21
  resetAgentHeldProcessLedger,
20
22
  resolveAgentHeldSettlement,
21
23
  resolveGrantTarget,
24
+ resolveMcpTarget,
25
+ sameMcpGateway,
22
26
  settlePreparedMcpPayment,
23
27
  traceMcpHttpRequest,
24
28
  verifySpendAccountPayReconstructs
25
- } from "./chunk-KDOGSB5I.js";
29
+ } from "./chunk-UTKVBAEZ.js";
26
30
  export {
31
+ MCP_TARGET_PRESETS,
27
32
  PACKAGE_NAME,
28
33
  TOOLS,
29
34
  buildSpendAccountPayKind,
@@ -36,12 +41,15 @@ export {
36
41
  loadLocalSigner,
37
42
  loadMcpConfig,
38
43
  main,
44
+ parseMcpTargetFlag,
39
45
  pay,
40
46
  prepareSpendAccountPayment,
41
47
  receipts,
42
48
  resetAgentHeldProcessLedger,
43
49
  resolveAgentHeldSettlement,
44
50
  resolveGrantTarget,
51
+ resolveMcpTarget,
52
+ sameMcpGateway,
45
53
  settlePreparedMcpPayment,
46
54
  traceMcpHttpRequest,
47
55
  verifySpendAccountPayReconstructs
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@cmdoss/suipay-mcp",
3
- "version": "0.2.2-dev.4",
3
+ "version": "0.2.2-dev.6",
4
4
  "type": "module",
5
- "description": "SuiPay MCP — pay MPP-gated APIs from a spend-account grant with an agent-held delegate key.",
5
+ "description": "SuiPay MCP \u2014 pay MPP-gated APIs from a spend-account grant with an agent-held delegate key.",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
@@ -1,39 +0,0 @@
1
- import {
2
- createServer,
3
- loadMcpConfig,
4
- loadPaymentProfile
5
- } from "./chunk-KDOGSB5I.js";
6
-
7
- // src/index.ts
8
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
- function loadBootProfile(load = loadPaymentProfile) {
10
- try {
11
- return { profile: load(), unreadable: false };
12
- } catch {
13
- return { profile: null, unreadable: true };
14
- }
15
- }
16
- async function main() {
17
- const cfg = loadMcpConfig();
18
- const { profile: bootProfile, unreadable: bootProfileUnreadable } = loadBootProfile();
19
- const server = createServer(cfg);
20
- await server.connect(new StdioServerTransport());
21
- if (bootProfileUnreadable) {
22
- console.error(
23
- "[suipay-mcp] credentials unreadable: run suipay_login or suipay_logout force=true \xB7 stdio ready"
24
- );
25
- } else if (bootProfile) {
26
- console.error(
27
- `[suipay-mcp] delegate ${bootProfile.creds.delegateAddress} (${bootProfile.source}) \xB7 stdio ready`
28
- );
29
- } else {
30
- console.error(
31
- "[suipay-mcp] not connected \xB7 run suipay_login \xB7 stdio ready"
32
- );
33
- }
34
- }
35
-
36
- export {
37
- loadBootProfile,
38
- main
39
- };