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

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.
@@ -275,7 +295,7 @@ declare const TOOLS: readonly [{
275
295
  };
276
296
  }, {
277
297
  readonly name: "discover";
278
- readonly description: "Search SuiPay gateway resources.";
298
+ 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
299
  readonly inputSchema: {
280
300
  readonly type: "object";
281
301
  readonly properties: {
@@ -299,7 +319,7 @@ declare const TOOLS: readonly [{
299
319
  };
300
320
  }, {
301
321
  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.";
322
+ 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
323
  readonly inputSchema: {
304
324
  readonly type: "object";
305
325
  readonly properties: {
@@ -307,6 +327,11 @@ declare const TOOLS: readonly [{
307
327
  readonly type: "string";
308
328
  readonly description: "Label shown in SuiPay console.";
309
329
  };
330
+ readonly target: {
331
+ readonly type: "string";
332
+ readonly enum: readonly ["dev", "local"];
333
+ readonly description: "Where to bind the grant. Default is Railway suipay-dev. Pass \"local\" for localhost:3000 / 127.0.0.1:4340.";
334
+ };
310
335
  readonly gatewayResourceUrl: {
311
336
  readonly type: "string";
312
337
  readonly description: "Gateway resource URL whose 402 defines recipient, asset, and package.";
@@ -364,4 +389,4 @@ declare function createServer(cfg: McpConfig, auth?: McpAuthContext, trace?: Mcp
364
389
  */
365
390
  declare function handleSuipayMcpHttpRequest(req: Request, cfg: McpConfig, auth?: McpAuthContext, trace?: McpTraceRuntime | null, options?: McpServerOptions): Promise<Response>;
366
391
 
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 };
392
+ 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-B4YTVw0k.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-THLDEMGS.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-B4YTVw0k.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-B4YTVw0k.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,7 +315,33 @@ 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;
@@ -347,6 +369,9 @@ interface ToolDeps {
347
369
  * carries the delegate address only — never the seed.
348
370
  */
349
371
  onUrl?: (url: string) => void;
372
+ createPayer?: typeof createPayer;
373
+ createReader?: typeof createReader;
374
+ startStdioLogin?: typeof startStdioLogin;
350
375
  }
351
376
  declare function pay(args: {
352
377
  url: string;
@@ -357,7 +382,7 @@ declare function pay(args: {
357
382
  }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
358
383
  declare function receipts(args: {
359
384
  challengeId?: string;
360
- }, _cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
385
+ }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
361
386
 
362
387
  declare function loadBootProfile(load?: typeof loadPaymentProfile): {
363
388
  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-P54ZYBPN.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-THLDEMGS.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmdoss/suipay-mcp",
3
- "version": "0.2.2-dev.4",
3
+ "version": "0.2.2-dev.5",
4
4
  "type": "module",
5
5
  "description": "SuiPay MCP — pay MPP-gated APIs from a spend-account grant with an agent-held delegate key.",
6
6
  "main": "./dist/index.js",
@@ -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
- };