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

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,39 @@
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
+ };
@@ -55,19 +55,7 @@ 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
- }>;
68
58
  interface McpConfig {
69
- /** Preset used when console/gateway env is unset. Set by `loadMcpConfig`. */
70
- target?: McpTarget;
71
59
  consoleUrl: string;
72
60
  gatewayUrl: string;
73
61
  rpcUrl: string;
@@ -80,15 +68,7 @@ interface McpConfig {
80
68
  minMaxPerPayment: bigint;
81
69
  label: string;
82
70
  }
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;
71
+ declare function loadMcpConfig(env?: NodeJS.ProcessEnv): McpConfig;
92
72
 
93
73
  /**
94
74
  * Agent-held settlement wiring for the `pay` tool.
@@ -282,14 +262,6 @@ declare const TOOLS: readonly [{
282
262
  readonly type: "object";
283
263
  readonly description: "JSON request body for a POST. Sent as application/json and bound to the payment.";
284
264
  };
285
- readonly file: {
286
- readonly type: "string";
287
- readonly description: "Absolute local path whose bytes fill json[fileField] as canonical base64. Stdio only; requires fileField. GET must omit this.";
288
- };
289
- readonly fileField: {
290
- readonly type: "string";
291
- readonly description: "JSON key to set from file (e.g. contentBase64). Required with file. Must not already be present on json.";
292
- };
293
265
  readonly recipient: {
294
266
  readonly type: "string";
295
267
  readonly description: "Sui address you expect to be paid. The payment is refused, unsigned, if the prepared transaction pays anyone else.";
@@ -303,7 +275,7 @@ declare const TOOLS: readonly [{
303
275
  };
304
276
  }, {
305
277
  readonly name: "discover";
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).";
278
+ readonly description: "Search SuiPay gateway resources.";
307
279
  readonly inputSchema: {
308
280
  readonly type: "object";
309
281
  readonly properties: {
@@ -327,7 +299,7 @@ declare const TOOLS: readonly [{
327
299
  };
328
300
  }, {
329
301
  readonly name: "suipay_login";
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.";
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.";
331
303
  readonly inputSchema: {
332
304
  readonly type: "object";
333
305
  readonly properties: {
@@ -335,11 +307,6 @@ declare const TOOLS: readonly [{
335
307
  readonly type: "string";
336
308
  readonly description: "Label shown in SuiPay console.";
337
309
  };
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
- };
343
310
  readonly gatewayResourceUrl: {
344
311
  readonly type: "string";
345
312
  readonly description: "Gateway resource URL whose 402 defines recipient, asset, and package.";
@@ -397,4 +364,4 @@ declare function createServer(cfg: McpConfig, auth?: McpAuthContext, trace?: Mcp
397
364
  */
398
365
  declare function handleSuipayMcpHttpRequest(req: Request, cfg: McpConfig, auth?: McpAuthContext, trace?: McpTraceRuntime | null, options?: McpServerOptions): Promise<Response>;
399
366
 
400
- 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 };
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 };
package/dist/http.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { m as handleSuipayMcpHttpRequest } from './http-IivHoDeb.js';
1
+ export { k as handleSuipayMcpHttpRequest } from './http-C8xW9F1c.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-62LFIYB7.js";
3
+ } from "./chunk-KDOGSB5I.js";
4
4
  export {
5
5
  handleSuipayMcpHttpRequest
6
6
  };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  import { Wallet } from '@cmdoss/suipay-core/chain/types';
2
- import { M as McpConfig, a as McpAuthContext, b as McpTraceHooks } from './http-IivHoDeb.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-IivHoDeb.js';
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';
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, createReader } from '@cmdoss/suipay-sdk/agent-sdk/reads';
9
+ import { GetObjectJson } 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';
12
11
  import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
13
12
  import '@cmdoss/suipay-sdk/mcp/access-context';
14
13
  import '@cmdoss/suipay-sdk/buyer/settlement-dto';
@@ -49,6 +48,11 @@ interface PaymentProfile {
49
48
  * and point operators at delegate OAuth / delegated-signer flows.
50
49
  */
51
50
  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
+ */
52
56
  declare function ensureLocalSigningKey(opts?: {
53
57
  label?: string;
54
58
  }): Promise<LocalSigningKeyIdentity>;
@@ -315,38 +319,7 @@ declare function settlePreparedMcpPayment(args: {
315
319
  intent?: SpendIntent;
316
320
  }): Promise<DelegatedPayResult>;
317
321
 
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
-
343
- /**
344
- * MCP tool payloads. Settlement honesty matches the playground stamp:
345
- * money that moved is never reported as a tool error (that invites a second pay).
346
- */
347
-
348
322
  type ToolResult = CallToolResult;
349
-
350
323
  interface ToolDeps {
351
324
  fetchImpl?: typeof fetch;
352
325
  profileLoader?: () => PaymentProfile | null;
@@ -374,22 +347,17 @@ interface ToolDeps {
374
347
  * carries the delegate address only — never the seed.
375
348
  */
376
349
  onUrl?: (url: string) => void;
377
- createPayer?: typeof createPayer;
378
- createReader?: typeof createReader;
379
- startStdioLogin?: typeof startStdioLogin;
380
350
  }
381
351
  declare function pay(args: {
382
352
  url: string;
383
353
  method?: unknown;
384
354
  json?: unknown;
385
- file?: unknown;
386
- fileField?: unknown;
387
355
  recipient?: unknown;
388
356
  maxAmount?: unknown;
389
357
  }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
390
358
  declare function receipts(args: {
391
359
  challengeId?: string;
392
- }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
360
+ }, _cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
393
361
 
394
362
  declare function loadBootProfile(load?: typeof loadPaymentProfile): {
395
363
  profile: ReturnType<typeof loadPaymentProfile>;
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  loadBootProfile,
3
3
  main
4
- } from "./chunk-AFEXT5X4.js";
4
+ } from "./chunk-XAM2YQC6.js";
5
5
  import {
6
- MCP_TARGET_PRESETS,
7
6
  PACKAGE_NAME,
8
7
  TOOLS,
9
8
  buildSpendAccountPayKind,
@@ -14,21 +13,17 @@ import {
14
13
  inspectMcpEnvelope,
15
14
  loadLocalSigner,
16
15
  loadMcpConfig,
17
- parseMcpTargetFlag,
18
16
  pay,
19
17
  prepareSpendAccountPayment,
20
18
  receipts,
21
19
  resetAgentHeldProcessLedger,
22
20
  resolveAgentHeldSettlement,
23
21
  resolveGrantTarget,
24
- resolveMcpTarget,
25
- sameMcpGateway,
26
22
  settlePreparedMcpPayment,
27
23
  traceMcpHttpRequest,
28
24
  verifySpendAccountPayReconstructs
29
- } from "./chunk-62LFIYB7.js";
25
+ } from "./chunk-KDOGSB5I.js";
30
26
  export {
31
- MCP_TARGET_PRESETS,
32
27
  PACKAGE_NAME,
33
28
  TOOLS,
34
29
  buildSpendAccountPayKind,
@@ -41,15 +36,12 @@ export {
41
36
  loadLocalSigner,
42
37
  loadMcpConfig,
43
38
  main,
44
- parseMcpTargetFlag,
45
39
  pay,
46
40
  prepareSpendAccountPayment,
47
41
  receipts,
48
42
  resetAgentHeldProcessLedger,
49
43
  resolveAgentHeldSettlement,
50
44
  resolveGrantTarget,
51
- resolveMcpTarget,
52
- sameMcpGateway,
53
45
  settlePreparedMcpPayment,
54
46
  traceMcpHttpRequest,
55
47
  verifySpendAccountPayReconstructs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmdoss/suipay-mcp",
3
- "version": "0.2.2-dev.2",
3
+ "version": "0.2.2-dev.4",
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,46 +0,0 @@
1
- import {
2
- createServer,
3
- loadLocalSigner,
4
- loadLocalSigningKeyRecord,
5
- loadMcpConfig,
6
- loadPaymentProfile
7
- } from "./chunk-62LFIYB7.js";
8
-
9
- // src/index.ts
10
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
- function loadBootProfile(load = loadPaymentProfile) {
12
- try {
13
- return { profile: load(), unreadable: false };
14
- } catch {
15
- return { profile: null, unreadable: true };
16
- }
17
- }
18
- async function main() {
19
- const argv = process.argv.slice(2);
20
- const cfg = loadMcpConfig(process.env, argv);
21
- const target = cfg.target ?? "dev";
22
- const server = createServer(cfg);
23
- await server.connect(new StdioServerTransport());
24
- try {
25
- const boundGateway = loadLocalSigningKeyRecord()?.gatewayUrl ?? cfg.gatewayUrl;
26
- const local = loadLocalSigner();
27
- if (local) {
28
- console.error(
29
- `[suipay-mcp] ${target} ${boundGateway} \xB7 delegate ${local.address} \xB7 stdio ready`
30
- );
31
- } else {
32
- console.error(
33
- `[suipay-mcp] ${target} ${boundGateway} \xB7 not connected \xB7 run suipay_login \xB7 stdio ready`
34
- );
35
- }
36
- } catch {
37
- console.error(
38
- `[suipay-mcp] ${target} ${cfg.gatewayUrl} \xB7 credentials unreadable: run suipay_login or suipay_logout force=true \xB7 stdio ready`
39
- );
40
- }
41
- }
42
-
43
- export {
44
- loadBootProfile,
45
- main
46
- };