@haven_ai/mcp 0.1.23-alpha.0 → 0.1.23-alpha.2
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 +2 -5
- package/dist/cli.cjs +6 -118
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +7 -119
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -119
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { composeDescription, toolDescriptions as toolDescriptions$1, HavenClient, isSupportedNodeVersion, unsupportedNodeVersionMessage,
|
|
4
|
+
import { composeDescription, toolDescriptions as toolDescriptions$1, HavenClient, isSupportedNodeVersion, unsupportedNodeVersionMessage, HavenPaymentStateError, HavenSigningError, HavenApiError, AgentPaymentNextAction, HavenError, verifyPaymentReceipt, discoverMerchantMcpUrl, sameUrl } from '@haven_ai/sdk';
|
|
5
5
|
import { readFile, mkdir, writeFile, stat } from 'fs/promises';
|
|
6
6
|
import { z } from 'zod/v3';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
@@ -250,22 +250,6 @@ var toolSchemas = {
|
|
|
250
250
|
payment_id: z.string().optional(),
|
|
251
251
|
resume_state: z.unknown().optional()
|
|
252
252
|
},
|
|
253
|
-
haven_quote_mpp: {
|
|
254
|
-
url: z.string().url().optional(),
|
|
255
|
-
challenge: z.unknown().optional(),
|
|
256
|
-
method: z.string().optional(),
|
|
257
|
-
headers: headersSchema,
|
|
258
|
-
body: z.string().optional(),
|
|
259
|
-
idempotencyKey: z.string().optional()
|
|
260
|
-
},
|
|
261
|
-
haven_pay_mpp_challenge: {
|
|
262
|
-
quote: z.unknown(),
|
|
263
|
-
idempotencyKey: z.string().optional()
|
|
264
|
-
},
|
|
265
|
-
haven_resume_mpp_payment: {
|
|
266
|
-
payment_id: z.string().optional(),
|
|
267
|
-
resume_state: z.unknown().optional()
|
|
268
|
-
},
|
|
269
253
|
haven_get_payment_status: {
|
|
270
254
|
payment_id: z.string()
|
|
271
255
|
},
|
|
@@ -294,9 +278,6 @@ var toolDescriptions = {
|
|
|
294
278
|
haven_pay_x402_quote: composeDescription(toolDescriptions$1.payX402),
|
|
295
279
|
haven_pay_x402: composeDescription(toolDescriptions$1.payX402OneShot),
|
|
296
280
|
haven_resume_x402_payment: composeDescription(toolDescriptions$1.resumeX402),
|
|
297
|
-
haven_quote_mpp: composeDescription(toolDescriptions$1.quoteMpp),
|
|
298
|
-
haven_pay_mpp_challenge: composeDescription(toolDescriptions$1.payMpp),
|
|
299
|
-
haven_resume_mpp_payment: composeDescription(toolDescriptions$1.resumeMpp),
|
|
300
281
|
haven_get_payment_status: composeDescription(toolDescriptions$1.getPaymentStatus),
|
|
301
282
|
haven_get_resume_state: composeDescription(toolDescriptions$1.getResumeState),
|
|
302
283
|
haven_get_agent: composeDescription(toolDescriptions$1.getAgent),
|
|
@@ -382,13 +363,6 @@ function createToolHandlers(haven) {
|
|
|
382
363
|
try {
|
|
383
364
|
return { success: true, data: await haven.quoteX402(args.url, requestInit(args), { idempotencyKey: args.idempotencyKey }) };
|
|
384
365
|
} catch (err) {
|
|
385
|
-
if (err instanceof HavenApiError && err.message.includes("quoteX402 only supports standard x402")) {
|
|
386
|
-
return wrongTool(
|
|
387
|
-
"WRONG_RAIL",
|
|
388
|
-
"The URL responds with an MPP machine-payment challenge, not an x402 payment. Use haven_quote_mpp to inspect this merchant.",
|
|
389
|
-
"haven_quote_mpp"
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
366
|
return normalizeError(err);
|
|
393
367
|
}
|
|
394
368
|
},
|
|
@@ -402,13 +376,6 @@ function createToolHandlers(haven) {
|
|
|
402
376
|
"haven_quote_x402"
|
|
403
377
|
);
|
|
404
378
|
}
|
|
405
|
-
if (!quote.paymentRequired && quote.rail === "mpp") {
|
|
406
|
-
return wrongTool(
|
|
407
|
-
"WRONG_TOOL",
|
|
408
|
-
"The quote is for the MPP rail. Use haven_pay_mpp_challenge to pay an MPP quote.",
|
|
409
|
-
"haven_pay_mpp_challenge"
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
379
|
if (!quote.paymentRequired) {
|
|
413
380
|
return wrongTool(
|
|
414
381
|
"WRONG_TOOL",
|
|
@@ -430,95 +397,12 @@ function createToolHandlers(haven) {
|
|
|
430
397
|
},
|
|
431
398
|
haven_resume_x402_payment: async (input) => {
|
|
432
399
|
const args = objectInput("haven_resume_x402_payment", input);
|
|
433
|
-
if (args.resume_state && typeof args.resume_state === "object") {
|
|
434
|
-
const stateRail = args.resume_state.rail;
|
|
435
|
-
if (stateRail && stateRail !== "x402") {
|
|
436
|
-
return wrongTool(
|
|
437
|
-
"WRONG_TOOL",
|
|
438
|
-
`The resume state is for the '${stateRail}' rail, not x402. Use haven_resume_mpp_payment instead.`,
|
|
439
|
-
"haven_resume_mpp_payment"
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
400
|
return runTool(async () => {
|
|
444
401
|
const state = await resumeState(args, "x402");
|
|
445
402
|
const response = await haven.resumeX402Payment(state);
|
|
446
403
|
return responsePayload(response);
|
|
447
404
|
});
|
|
448
405
|
},
|
|
449
|
-
haven_quote_mpp: async (input) => {
|
|
450
|
-
const args = objectInput("haven_quote_mpp", input);
|
|
451
|
-
try {
|
|
452
|
-
if (args.challenge) {
|
|
453
|
-
return {
|
|
454
|
-
success: true,
|
|
455
|
-
data: await haven.quoteMpp(args.challenge, requestInit(args), {
|
|
456
|
-
idempotencyKey: args.idempotencyKey
|
|
457
|
-
})
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
if (!args.url) {
|
|
461
|
-
return normalizeError(new HavenApiError("haven_quote_mpp requires either url or challenge.", 400));
|
|
462
|
-
}
|
|
463
|
-
return { success: true, data: await haven.quoteMpp(args.url, requestInit(args), { idempotencyKey: args.idempotencyKey }) };
|
|
464
|
-
} catch (err) {
|
|
465
|
-
if (err instanceof Error && err.message.includes("No MACHINE-PAYMENT-CHALLENGE header found")) {
|
|
466
|
-
return wrongTool(
|
|
467
|
-
"WRONG_RAIL",
|
|
468
|
-
"The URL responds with an x402 payment requirement, not an MPP machine-payment challenge. Use haven_quote_x402 to inspect this merchant.",
|
|
469
|
-
"haven_quote_x402"
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
return normalizeError(err);
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
haven_pay_mpp_challenge: async (input) => {
|
|
476
|
-
const args = objectInput("haven_pay_mpp_challenge", input);
|
|
477
|
-
const quote = args.quote;
|
|
478
|
-
if (!quote || typeof quote !== "object") {
|
|
479
|
-
return wrongTool(
|
|
480
|
-
"WRONG_TOOL",
|
|
481
|
-
"The quote argument is missing or is not a valid MPP quote object. Call haven_quote_mpp first to obtain a quote.",
|
|
482
|
-
"haven_quote_mpp"
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
if (quote.paymentRequired || quote.rail === "x402") {
|
|
486
|
-
return wrongTool(
|
|
487
|
-
"WRONG_TOOL",
|
|
488
|
-
"The quote is for the x402 rail. Use haven_pay_x402_quote to pay an x402 quote.",
|
|
489
|
-
"haven_pay_x402_quote"
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
if (!quote.challenge) {
|
|
493
|
-
return wrongTool(
|
|
494
|
-
"WRONG_TOOL",
|
|
495
|
-
"The quote is missing the required challenge field. Call haven_quote_mpp first to obtain a valid MPP quote.",
|
|
496
|
-
"haven_quote_mpp"
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
return runTool(async () => {
|
|
500
|
-
const response = await haven.payMppChallenge(args.quote, { idempotencyKey: args.idempotencyKey });
|
|
501
|
-
return responsePayload(response);
|
|
502
|
-
});
|
|
503
|
-
},
|
|
504
|
-
haven_resume_mpp_payment: async (input) => {
|
|
505
|
-
const args = objectInput("haven_resume_mpp_payment", input);
|
|
506
|
-
if (args.resume_state && typeof args.resume_state === "object") {
|
|
507
|
-
const stateRail = args.resume_state.rail;
|
|
508
|
-
if (stateRail && stateRail !== "mpp") {
|
|
509
|
-
return wrongTool(
|
|
510
|
-
"WRONG_TOOL",
|
|
511
|
-
`The resume state is for the '${stateRail}' rail, not mpp. Use haven_resume_x402_payment instead.`,
|
|
512
|
-
"haven_resume_x402_payment"
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return runTool(async () => {
|
|
517
|
-
const state = await resumeState(args, "mpp");
|
|
518
|
-
const response = await haven.resumeMppPayment(state);
|
|
519
|
-
return responsePayload(response);
|
|
520
|
-
});
|
|
521
|
-
},
|
|
522
406
|
haven_get_payment_status: async (input) => {
|
|
523
407
|
const args = objectInput("haven_get_payment_status", input);
|
|
524
408
|
return runTool(async () => haven.getPaymentStatusWithPostPurchaseAllowance(args.payment_id));
|
|
@@ -555,7 +439,11 @@ function createToolHandlers(haven) {
|
|
|
555
439
|
status: entry.status,
|
|
556
440
|
verified_at: entry.verifiedAt,
|
|
557
441
|
// Which Haven pay tool reaches this entry from the local MCP surface.
|
|
558
|
-
|
|
442
|
+
// #1328: the 'mpp' rail's only-ever catalog row (the Haven MPP demo
|
|
443
|
+
// resource) is delisted with the mpp_demo retirement, so this
|
|
444
|
+
// fallback is unreachable today; it stays x402 rather than naming a
|
|
445
|
+
// deleted tool in case a future non-demo 'mpp' rail entry appears.
|
|
446
|
+
suggested_tool: entry.protocol === "mcp" ? "haven_pay_mcp_tool" : "haven_pay_x402"
|
|
559
447
|
}));
|
|
560
448
|
});
|
|
561
449
|
},
|
|
@@ -877,7 +765,7 @@ async function resolveHavenClient(options = {}) {
|
|
|
877
765
|
return { client, credentials };
|
|
878
766
|
}
|
|
879
767
|
var MCP_NAME = "@haven_ai/mcp";
|
|
880
|
-
var MCP_VERSION = "0.1.23-alpha.
|
|
768
|
+
var MCP_VERSION = "0.1.23-alpha.2";
|
|
881
769
|
var MCP_INSTRUCTIONS = [
|
|
882
770
|
"Haven local MCP server: signs in-process with the delegate key it holds on",
|
|
883
771
|
"this machine \u2014 the key never leaves this process. Call haven_get_agent",
|