@haven_ai/mcp 0.1.22-alpha.0 → 0.1.23-alpha.1

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/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, HavenApiError, HavenPaymentStateError, HavenSigningError, AgentPaymentNextAction, HavenError, verifyPaymentReceipt, discoverMerchantMcpUrl, sameUrl } from '@haven_ai/sdk';
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
  },
@@ -277,6 +261,7 @@ var toolSchemas = {
277
261
  haven_sweep_delegate: {},
278
262
  haven_discover_tools: {
279
263
  category: z.string().optional(),
264
+ search: z.string().optional(),
280
265
  rail: z.enum(["x402", "mpp"]).optional()
281
266
  },
282
267
  haven_list_receipts: {
@@ -293,9 +278,6 @@ var toolDescriptions = {
293
278
  haven_pay_x402_quote: composeDescription(toolDescriptions$1.payX402),
294
279
  haven_pay_x402: composeDescription(toolDescriptions$1.payX402OneShot),
295
280
  haven_resume_x402_payment: composeDescription(toolDescriptions$1.resumeX402),
296
- haven_quote_mpp: composeDescription(toolDescriptions$1.quoteMpp),
297
- haven_pay_mpp_challenge: composeDescription(toolDescriptions$1.payMpp),
298
- haven_resume_mpp_payment: composeDescription(toolDescriptions$1.resumeMpp),
299
281
  haven_get_payment_status: composeDescription(toolDescriptions$1.getPaymentStatus),
300
282
  haven_get_resume_state: composeDescription(toolDescriptions$1.getResumeState),
301
283
  haven_get_agent: composeDescription(toolDescriptions$1.getAgent),
@@ -381,13 +363,6 @@ function createToolHandlers(haven) {
381
363
  try {
382
364
  return { success: true, data: await haven.quoteX402(args.url, requestInit(args), { idempotencyKey: args.idempotencyKey }) };
383
365
  } catch (err) {
384
- if (err instanceof HavenApiError && err.message.includes("quoteX402 only supports standard x402")) {
385
- return wrongTool(
386
- "WRONG_RAIL",
387
- "The URL responds with an MPP machine-payment challenge, not an x402 payment. Use haven_quote_mpp to inspect this merchant.",
388
- "haven_quote_mpp"
389
- );
390
- }
391
366
  return normalizeError(err);
392
367
  }
393
368
  },
@@ -401,13 +376,6 @@ function createToolHandlers(haven) {
401
376
  "haven_quote_x402"
402
377
  );
403
378
  }
404
- if (!quote.paymentRequired && quote.rail === "mpp") {
405
- return wrongTool(
406
- "WRONG_TOOL",
407
- "The quote is for the MPP rail. Use haven_pay_mpp_challenge to pay an MPP quote.",
408
- "haven_pay_mpp_challenge"
409
- );
410
- }
411
379
  if (!quote.paymentRequired) {
412
380
  return wrongTool(
413
381
  "WRONG_TOOL",
@@ -429,95 +397,12 @@ function createToolHandlers(haven) {
429
397
  },
430
398
  haven_resume_x402_payment: async (input) => {
431
399
  const args = objectInput("haven_resume_x402_payment", input);
432
- if (args.resume_state && typeof args.resume_state === "object") {
433
- const stateRail = args.resume_state.rail;
434
- if (stateRail && stateRail !== "x402") {
435
- return wrongTool(
436
- "WRONG_TOOL",
437
- `The resume state is for the '${stateRail}' rail, not x402. Use haven_resume_mpp_payment instead.`,
438
- "haven_resume_mpp_payment"
439
- );
440
- }
441
- }
442
400
  return runTool(async () => {
443
401
  const state = await resumeState(args, "x402");
444
402
  const response = await haven.resumeX402Payment(state);
445
403
  return responsePayload(response);
446
404
  });
447
405
  },
448
- haven_quote_mpp: async (input) => {
449
- const args = objectInput("haven_quote_mpp", input);
450
- try {
451
- if (args.challenge) {
452
- return {
453
- success: true,
454
- data: await haven.quoteMpp(args.challenge, requestInit(args), {
455
- idempotencyKey: args.idempotencyKey
456
- })
457
- };
458
- }
459
- if (!args.url) {
460
- return normalizeError(new HavenApiError("haven_quote_mpp requires either url or challenge.", 400));
461
- }
462
- return { success: true, data: await haven.quoteMpp(args.url, requestInit(args), { idempotencyKey: args.idempotencyKey }) };
463
- } catch (err) {
464
- if (err instanceof Error && err.message.includes("No MACHINE-PAYMENT-CHALLENGE header found")) {
465
- return wrongTool(
466
- "WRONG_RAIL",
467
- "The URL responds with an x402 payment requirement, not an MPP machine-payment challenge. Use haven_quote_x402 to inspect this merchant.",
468
- "haven_quote_x402"
469
- );
470
- }
471
- return normalizeError(err);
472
- }
473
- },
474
- haven_pay_mpp_challenge: async (input) => {
475
- const args = objectInput("haven_pay_mpp_challenge", input);
476
- const quote = args.quote;
477
- if (!quote || typeof quote !== "object") {
478
- return wrongTool(
479
- "WRONG_TOOL",
480
- "The quote argument is missing or is not a valid MPP quote object. Call haven_quote_mpp first to obtain a quote.",
481
- "haven_quote_mpp"
482
- );
483
- }
484
- if (quote.paymentRequired || quote.rail === "x402") {
485
- return wrongTool(
486
- "WRONG_TOOL",
487
- "The quote is for the x402 rail. Use haven_pay_x402_quote to pay an x402 quote.",
488
- "haven_pay_x402_quote"
489
- );
490
- }
491
- if (!quote.challenge) {
492
- return wrongTool(
493
- "WRONG_TOOL",
494
- "The quote is missing the required challenge field. Call haven_quote_mpp first to obtain a valid MPP quote.",
495
- "haven_quote_mpp"
496
- );
497
- }
498
- return runTool(async () => {
499
- const response = await haven.payMppChallenge(args.quote, { idempotencyKey: args.idempotencyKey });
500
- return responsePayload(response);
501
- });
502
- },
503
- haven_resume_mpp_payment: async (input) => {
504
- const args = objectInput("haven_resume_mpp_payment", input);
505
- if (args.resume_state && typeof args.resume_state === "object") {
506
- const stateRail = args.resume_state.rail;
507
- if (stateRail && stateRail !== "mpp") {
508
- return wrongTool(
509
- "WRONG_TOOL",
510
- `The resume state is for the '${stateRail}' rail, not mpp. Use haven_resume_x402_payment instead.`,
511
- "haven_resume_x402_payment"
512
- );
513
- }
514
- }
515
- return runTool(async () => {
516
- const state = await resumeState(args, "mpp");
517
- const response = await haven.resumeMppPayment(state);
518
- return responsePayload(response);
519
- });
520
- },
521
406
  haven_get_payment_status: async (input) => {
522
407
  const args = objectInput("haven_get_payment_status", input);
523
408
  return runTool(async () => haven.getPaymentStatusWithPostPurchaseAllowance(args.payment_id));
@@ -534,6 +419,7 @@ function createToolHandlers(haven) {
534
419
  return runTool(async () => {
535
420
  const entries = await haven.discoverTools({
536
421
  category: typeof args.category === "string" ? args.category : void 0,
422
+ search: typeof args.search === "string" ? args.search : void 0,
537
423
  rail: args.rail === "x402" || args.rail === "mpp" ? args.rail : void 0
538
424
  });
539
425
  return entries.map((entry) => ({
@@ -553,7 +439,11 @@ function createToolHandlers(haven) {
553
439
  status: entry.status,
554
440
  verified_at: entry.verifiedAt,
555
441
  // Which Haven pay tool reaches this entry from the local MCP surface.
556
- suggested_tool: entry.protocol === "mcp" ? "haven_pay_mcp_tool" : entry.rail === "x402" ? "haven_pay_x402" : "haven_quote_mpp"
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"
557
447
  }));
558
448
  });
559
449
  },
@@ -875,7 +765,7 @@ async function resolveHavenClient(options = {}) {
875
765
  return { client, credentials };
876
766
  }
877
767
  var MCP_NAME = "@haven_ai/mcp";
878
- var MCP_VERSION = "0.1.22-alpha.0";
768
+ var MCP_VERSION = "0.1.23-alpha.1";
879
769
  var MCP_INSTRUCTIONS = [
880
770
  "Haven local MCP server: signs in-process with the delegate key it holds on",
881
771
  "this machine \u2014 the key never leaves this process. Call haven_get_agent",