@paybond/kit 0.9.6 → 0.9.8

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # `@paybond/kit`
2
2
 
3
+ <!-- mcp-name: io.github.nonameuserd/paybond -->
4
+
3
5
  Paybond Kit for TypeScript is the npm package for tenant-bound Paybond integrations and delegated agent spend controls. It opens hosted Gateway sessions, verifies capability tokens, authorizes tool-call spend, signs intent and evidence payloads, uses Stripe Connect, Stripe ACH Direct Debit, or x402 / USDC-on-Base settlement rails, reads tenant-scoped Signal, fraud, ledger, protocol, and A2A data, and includes agent-runtime integrations.
4
6
 
5
7
  Paybond is the SDK to use when you do not want to build your own delegated agent spend-governance middleware. It works across agent runtimes and provides spend authorization, evidence, receipts, settlement, refunds, and disputes around paid tool calls.
package/dist/index.d.ts CHANGED
@@ -4,6 +4,10 @@
4
4
  */
5
5
  import { type BuildSignedCreateIntentParams, type SettlementRail } from "./principal-intent.js";
6
6
  import { type SignPayeeEvidenceParams } from "./payee-evidence.js";
7
+ export type SpendScope = {
8
+ scope_type: string;
9
+ scope_key: string;
10
+ };
7
11
  export type VerifyCapabilityResult = {
8
12
  allow: boolean;
9
13
  auditId: string;
@@ -11,6 +15,28 @@ export type VerifyCapabilityResult = {
11
15
  intentId: string;
12
16
  code?: string;
13
17
  message?: string;
18
+ decisionId?: string;
19
+ approvalRequestId?: string;
20
+ policyVersion?: number;
21
+ reasonCodes?: string[];
22
+ spendScope?: SpendScope;
23
+ remainingCents?: number;
24
+ retryAfter?: number;
25
+ /** True when gateway policy requires operator approval before execution may proceed. */
26
+ approvalRequired?: boolean;
27
+ };
28
+ export type PaybondSpendAuthorizationInput = {
29
+ operation: string;
30
+ requestedSpendCents?: number;
31
+ vendorId?: string;
32
+ taskId?: string;
33
+ workflowId?: string;
34
+ toolCallId?: string;
35
+ toolName?: string;
36
+ currency?: string;
37
+ agentSubject?: string;
38
+ approvalToken?: string;
39
+ idempotencyKey?: string;
14
40
  };
15
41
  export type SubmitEvidenceResult = {
16
42
  intentId: string;
@@ -715,14 +741,19 @@ export declare class PaybondCapabilityBinding {
715
741
  authorizeSpend(input: PaybondSpendAuthorizationInput): Promise<VerifyCapabilityResult>;
716
742
  }
717
743
  export type PaybondSpendGuardInit = {
718
- harbor: Pick<HarborClient | GatewayHarborClient, "tenantId" | "verifyCapability">;
744
+ harbor: Pick<HarborClient | GatewayHarborClient, "tenantId" | "verifyCapability"> & {
745
+ completeSpendDecision?: (input: {
746
+ decisionId: string;
747
+ outcome: "consumed" | "released";
748
+ }) => Promise<void>;
749
+ };
719
750
  intentId: string;
720
751
  capabilityToken: string;
721
752
  };
722
- export type PaybondSpendAuthorizationInput = {
723
- operation: string;
724
- requestedSpendCents?: number;
725
- };
753
+ export declare class PaybondSpendApprovalRequiredError extends Error {
754
+ readonly result: VerifyCapabilityResult;
755
+ constructor(result: VerifyCapabilityResult);
756
+ }
726
757
  export declare class PaybondSpendDeniedError extends Error {
727
758
  readonly result: VerifyCapabilityResult;
728
759
  constructor(result: VerifyCapabilityResult);
@@ -730,13 +761,15 @@ export declare class PaybondSpendDeniedError extends Error {
730
761
  export type PaybondToolHandler<TArgs extends unknown[], TResult> = (...args: TArgs) => TResult | Promise<TResult>;
731
762
  export type PaybondGuardedToolHandler<TArgs extends unknown[], TResult> = (...args: TArgs) => Promise<Awaited<TResult>>;
732
763
  export declare class PaybondSpendGuard {
733
- readonly harbor: Pick<HarborClient | GatewayHarborClient, "tenantId" | "verifyCapability">;
764
+ readonly harbor: PaybondSpendGuardInit["harbor"];
734
765
  readonly intentId: string;
735
766
  readonly capabilityToken: string;
736
767
  constructor(init: PaybondSpendGuardInit | PaybondCapabilityBinding);
737
768
  verifySpendCapability(input: PaybondSpendAuthorizationInput): Promise<VerifyCapabilityResult>;
738
769
  authorizeSpend(input: PaybondSpendAuthorizationInput): Promise<VerifyCapabilityResult>;
739
770
  assertSpendAuthorized(input: PaybondSpendAuthorizationInput): Promise<VerifyCapabilityResult>;
771
+ /** Finalizes scope reservations tied to an authorization decision after tool execution. */
772
+ completeSpendAuthorization(decisionId: string, outcome: "consumed" | "released"): Promise<void>;
740
773
  guardTool<TArgs extends unknown[], TResult>(input: PaybondSpendAuthorizationInput, handler: PaybondToolHandler<TArgs, TResult>): PaybondGuardedToolHandler<TArgs, TResult>;
741
774
  }
742
775
  export declare function authorizeSpend(source: PaybondSpendGuardInit | PaybondCapabilityBinding, input: PaybondSpendAuthorizationInput): Promise<VerifyCapabilityResult>;
@@ -799,11 +832,9 @@ export declare class HarborClient {
799
832
  * @throws HarborHttpError when HTTP fails
800
833
  * @throws Error when Harbor echoes a different tenant / intent than requested
801
834
  */
802
- verifyCapability(input: {
835
+ verifyCapability(input: PaybondSpendAuthorizationInput & {
803
836
  intentId: string;
804
837
  token: string;
805
- operation: string;
806
- requestedSpendCents?: number;
807
838
  }): Promise<VerifyCapabilityResult>;
808
839
  verifySpendCapability(input: {
809
840
  intentId: string;
@@ -897,11 +928,9 @@ export declare class GatewayHarborClient {
897
928
  private fetchWithRetries;
898
929
  private postJSON;
899
930
  private mutationHeaders;
900
- verifyCapability(input: {
931
+ verifyCapability(input: PaybondSpendAuthorizationInput & {
901
932
  intentId: string;
902
933
  token: string;
903
- operation: string;
904
- requestedSpendCents?: number;
905
934
  }): Promise<VerifyCapabilityResult>;
906
935
  verifySpendCapability(input: {
907
936
  intentId: string;
@@ -915,6 +944,11 @@ export declare class GatewayHarborClient {
915
944
  operation: string;
916
945
  requestedSpendCents?: number;
917
946
  }): Promise<VerifyCapabilityResult>;
947
+ /** Finalizes active spend reservations after tool execution completes or is aborted. */
948
+ completeSpendDecision(input: {
949
+ decisionId: string;
950
+ outcome: "consumed" | "released";
951
+ }): Promise<void>;
918
952
  createIntent(body: Record<string, unknown>, options: GatewayHarborMutationOptions): Promise<Record<string, unknown>>;
919
953
  fundIntent(intentId: string, options: GatewayHarborMutationOptions & {
920
954
  paymentSignature?: string;
package/dist/index.js CHANGED
@@ -4,6 +4,77 @@
4
4
  */
5
5
  import { buildSignedCreateIntentBody, } from "./principal-intent.js";
6
6
  import { signPayeeEvidenceBinding } from "./payee-evidence.js";
7
+ function parseVerifyCapabilityBody(body, expectedTenant, expectedIntentId) {
8
+ const tenant = String(body.tenant ?? "");
9
+ const intentId = String(body.intent_id ?? "");
10
+ if (tenant !== expectedTenant) {
11
+ throw new Error(`verify tenant mismatch: client=${expectedTenant} remote=${tenant}`);
12
+ }
13
+ if (intentId !== expectedIntentId) {
14
+ throw new Error(`verify intent mismatch: requested=${expectedIntentId} remote=${intentId}`);
15
+ }
16
+ const reasonCodes = Array.isArray(body.reason_codes)
17
+ ? body.reason_codes.map((value) => String(value))
18
+ : undefined;
19
+ const spendScope = body.spend_scope && typeof body.spend_scope === "object" && !Array.isArray(body.spend_scope)
20
+ ? {
21
+ scope_type: String(body.spend_scope.scope_type ?? ""),
22
+ scope_key: String(body.spend_scope.scope_key ?? ""),
23
+ }
24
+ : undefined;
25
+ const code = body.code != null ? String(body.code) : undefined;
26
+ const approvalRequired = code === "approval_required" ||
27
+ reasonCodes?.includes("approval_threshold_exceeded") ||
28
+ reasonCodes?.includes("approval_required_pending") ||
29
+ reasonCodes?.includes("anomaly_new_vendor") ||
30
+ reasonCodes?.includes("anomaly_amount_spike") ||
31
+ reasonCodes?.includes("anomaly_rapid_auth") ||
32
+ reasonCodes?.includes("anomaly_cap_proximity") ||
33
+ false;
34
+ return {
35
+ allow: Boolean(body.allow),
36
+ auditId: String(body.audit_id ?? ""),
37
+ tenant,
38
+ intentId,
39
+ code,
40
+ message: body.message != null ? String(body.message) : undefined,
41
+ decisionId: body.decision_id != null ? String(body.decision_id) : undefined,
42
+ approvalRequestId: body.approval_request_id != null ? String(body.approval_request_id) : undefined,
43
+ policyVersion: typeof body.policy_version === "number" ? body.policy_version : undefined,
44
+ reasonCodes,
45
+ spendScope,
46
+ remainingCents: typeof body.remaining_cents === "number" ? body.remaining_cents : undefined,
47
+ retryAfter: typeof body.retry_after === "number" ? body.retry_after : undefined,
48
+ approvalRequired,
49
+ };
50
+ }
51
+ function verifyCapabilityPayload(input) {
52
+ const payload = {
53
+ intent_id: input.intentId,
54
+ token: input.token,
55
+ operation: input.operation,
56
+ requested_spend_cents: input.requestedSpendCents ?? 0,
57
+ };
58
+ if (input.vendorId?.trim())
59
+ payload.vendor_id = input.vendorId.trim();
60
+ if (input.taskId?.trim())
61
+ payload.task_id = input.taskId.trim();
62
+ if (input.workflowId?.trim())
63
+ payload.workflow_id = input.workflowId.trim();
64
+ if (input.toolCallId?.trim())
65
+ payload.tool_call_id = input.toolCallId.trim();
66
+ if (input.toolName?.trim())
67
+ payload.tool_name = input.toolName.trim();
68
+ if (input.currency?.trim())
69
+ payload.currency = input.currency.trim();
70
+ if (input.agentSubject?.trim())
71
+ payload.agent_subject = input.agentSubject.trim();
72
+ if (input.approvalToken?.trim())
73
+ payload.approval_token = input.approvalToken.trim();
74
+ if (input.idempotencyKey?.trim())
75
+ payload.idempotency_key = input.idempotencyKey.trim();
76
+ return payload;
77
+ }
7
78
  export const DEFAULT_PAYBOND_GATEWAY_BASE_URL = "https://api.paybond.ai";
8
79
  function defaultGatewayBaseUrl(value) {
9
80
  const trimmed = value?.trim();
@@ -158,16 +229,24 @@ export class PaybondCapabilityBinding {
158
229
  }
159
230
  async verifySpendCapability(input) {
160
231
  return this.harbor.verifyCapability({
232
+ ...input,
161
233
  intentId: this.intentId,
162
234
  token: this.capabilityToken,
163
- operation: input.operation,
164
- requestedSpendCents: input.requestedSpendCents,
165
235
  });
166
236
  }
167
237
  async authorizeSpend(input) {
168
238
  return this.verifySpendCapability(input);
169
239
  }
170
240
  }
241
+ export class PaybondSpendApprovalRequiredError extends Error {
242
+ result;
243
+ constructor(result) {
244
+ const reason = result.message ?? result.code ?? "approval_required";
245
+ super(`Paybond spend authorization requires approval: ${reason}`);
246
+ this.name = "PaybondSpendApprovalRequiredError";
247
+ this.result = result;
248
+ }
249
+ }
171
250
  export class PaybondSpendDeniedError extends Error {
172
251
  result;
173
252
  constructor(result) {
@@ -188,10 +267,9 @@ export class PaybondSpendGuard {
188
267
  }
189
268
  async verifySpendCapability(input) {
190
269
  return this.harbor.verifyCapability({
270
+ ...input,
191
271
  intentId: this.intentId,
192
272
  token: this.capabilityToken,
193
- operation: input.operation,
194
- requestedSpendCents: input.requestedSpendCents,
195
273
  });
196
274
  }
197
275
  async authorizeSpend(input) {
@@ -200,14 +278,42 @@ export class PaybondSpendGuard {
200
278
  async assertSpendAuthorized(input) {
201
279
  const result = await this.authorizeSpend(input);
202
280
  if (!result.allow) {
281
+ if (result.approvalRequired) {
282
+ throw new PaybondSpendApprovalRequiredError(result);
283
+ }
203
284
  throw new PaybondSpendDeniedError(result);
204
285
  }
205
286
  return result;
206
287
  }
288
+ /** Finalizes scope reservations tied to an authorization decision after tool execution. */
289
+ async completeSpendAuthorization(decisionId, outcome) {
290
+ const complete = this.harbor.completeSpendDecision;
291
+ if (!complete) {
292
+ return;
293
+ }
294
+ await complete.call(this.harbor, { decisionId, outcome });
295
+ }
207
296
  guardTool(input, handler) {
208
297
  return async (...args) => {
209
- await this.assertSpendAuthorized(input);
210
- return await handler(...args);
298
+ const auth = await this.assertSpendAuthorized(input);
299
+ try {
300
+ const result = await handler(...args);
301
+ if (auth.decisionId) {
302
+ await this.completeSpendAuthorization(auth.decisionId, "consumed");
303
+ }
304
+ return result;
305
+ }
306
+ catch (err) {
307
+ if (auth.decisionId) {
308
+ try {
309
+ await this.completeSpendAuthorization(auth.decisionId, "released");
310
+ }
311
+ catch {
312
+ // Best-effort release when the guarded handler fails.
313
+ }
314
+ }
315
+ throw err;
316
+ }
211
317
  };
212
318
  }
213
319
  }
@@ -245,6 +351,9 @@ export function paybondRuntimeToolCallAdapter(init) {
245
351
  if (init.onDeny) {
246
352
  return await init.onDeny(result, call);
247
353
  }
354
+ if (result.approvalRequired) {
355
+ throw new PaybondSpendApprovalRequiredError(result);
356
+ }
248
357
  throw new PaybondSpendDeniedError(result);
249
358
  }
250
359
  return await init.execute(call);
@@ -384,17 +493,13 @@ export class HarborClient {
384
493
  */
385
494
  async verifyCapability(input) {
386
495
  const url = `${this.base}verify`;
387
- const payload = {
388
- intent_id: input.intentId,
389
- token: input.token,
390
- operation: input.operation,
391
- requested_spend_cents: input.requestedSpendCents ?? 0,
392
- };
496
+ const payload = verifyCapabilityPayload(input);
393
497
  const res = await this.fetchWithRetries(url, {
394
498
  method: "POST",
395
499
  headers: {
396
500
  "content-type": "application/json",
397
501
  "x-tenant-id": this.tenantId,
502
+ ...(input.idempotencyKey?.trim() ? { "idempotency-key": input.idempotencyKey.trim() } : {}),
398
503
  },
399
504
  body: JSON.stringify(payload),
400
505
  }, { retryBody: payload });
@@ -407,20 +512,7 @@ export class HarborClient {
407
512
  });
408
513
  }
409
514
  const body = JSON.parse(text);
410
- if (body.tenant !== this.tenantId) {
411
- throw new Error(`verify tenant mismatch: client=${this.tenantId} harbor=${body.tenant}`);
412
- }
413
- if (body.intent_id !== input.intentId) {
414
- throw new Error(`verify intent mismatch: requested=${input.intentId} harbor=${body.intent_id}`);
415
- }
416
- return {
417
- allow: body.allow,
418
- auditId: body.audit_id,
419
- tenant: body.tenant,
420
- intentId: body.intent_id,
421
- code: body.code,
422
- message: body.message,
423
- };
515
+ return parseVerifyCapabilityBody(body, this.tenantId, input.intentId);
424
516
  }
425
517
  async verifySpendCapability(input) {
426
518
  return this.verifyCapability(input);
@@ -722,13 +814,12 @@ export class GatewayHarborClient {
722
814
  });
723
815
  }
724
816
  async verifyCapability(input) {
725
- const payload = {
726
- intent_id: input.intentId,
727
- token: input.token,
728
- operation: input.operation,
729
- requested_spend_cents: input.requestedSpendCents ?? 0,
730
- };
731
- const { res, text, url } = await this.postJSON("/verify", payload);
817
+ const payload = verifyCapabilityPayload(input);
818
+ const headers = {};
819
+ if (input.idempotencyKey?.trim()) {
820
+ headers["idempotency-key"] = input.idempotencyKey.trim();
821
+ }
822
+ const { res, text, url } = await this.postJSON("/verify", payload, headers);
732
823
  if (!res.ok) {
733
824
  throw new HarborHttpError(`Gateway verify HTTP ${res.status}: ${text}`, {
734
825
  statusCode: res.status,
@@ -737,20 +828,7 @@ export class GatewayHarborClient {
737
828
  });
738
829
  }
739
830
  const body = JSON.parse(text);
740
- if (body.tenant !== this.tenantId) {
741
- throw new Error(`verify tenant mismatch: client=${this.tenantId} gateway=${body.tenant}`);
742
- }
743
- if (body.intent_id !== input.intentId) {
744
- throw new Error(`verify intent mismatch: requested=${input.intentId} gateway=${body.intent_id}`);
745
- }
746
- return {
747
- allow: body.allow,
748
- auditId: body.audit_id,
749
- tenant: body.tenant,
750
- intentId: body.intent_id,
751
- code: body.code,
752
- message: body.message,
753
- };
831
+ return parseVerifyCapabilityBody(body, this.tenantId, input.intentId);
754
832
  }
755
833
  async verifySpendCapability(input) {
756
834
  return this.verifyCapability(input);
@@ -758,6 +836,17 @@ export class GatewayHarborClient {
758
836
  async authorizeSpend(input) {
759
837
  return this.verifyCapability(input);
760
838
  }
839
+ /** Finalizes active spend reservations after tool execution completes or is aborted. */
840
+ async completeSpendDecision(input) {
841
+ const { res, text, url } = await this.postJSON(`/v1/spend/decisions/${encodeURIComponent(input.decisionId)}/complete`, { outcome: input.outcome });
842
+ if (!res.ok) {
843
+ throw new HarborHttpError(`Gateway spend complete HTTP ${res.status}: ${text}`, {
844
+ statusCode: res.status,
845
+ url,
846
+ bodyText: text,
847
+ });
848
+ }
849
+ }
761
850
  async createIntent(body, options) {
762
851
  const { res, text, url } = await this.postJSON("/harbor/intents", body, this.mutationHeaders("createIntent", options));
763
852
  if (!res.ok) {
package/dist/init.js CHANGED
@@ -170,7 +170,7 @@ export async function openPaybondFromEnv(options: OpenPaybondFromEnvOptions = {}
170
170
 
171
171
  return Paybond.open({
172
172
  apiKey,
173
- gatewayBaseUrl: process.env.PAYBOND_GATEWAY_BASE_URL,
173
+ gatewayBaseUrl: process.env.PAYBOND_GATEWAY_URL ?? process.env.PAYBOND_GATEWAY_BASE_URL,
174
174
  expectedEnvironment: "sandbox",
175
175
  });
176
176
  }
@@ -3,12 +3,276 @@
3
3
  import { readFileSync } from "node:fs";
4
4
  import { GatewayAuthError, GatewayFraudClient, GatewaySignalClient, SignalHttpError, DEFAULT_PAYBOND_GATEWAY_BASE_URL, } from "./index.js";
5
5
  const SERVER_NAME = "Paybond MCP";
6
- const SERVER_VERSION = "0.6.0";
6
+ const SERVER_VERSION = "0.9.8";
7
7
  const MCP_PROTOCOL_VERSION = "2025-11-25";
8
8
  const DEFAULT_PRINCIPAL_PATH = "/v1/auth/principal";
9
9
  const DEFAULT_RECOGNITION_VERIFIER_ID = "paybond-gateway";
10
10
  const agentRecognitionProofHeader = "x-paybond-agent-recognition-proof";
11
11
  const DEFAULT_ENV_FILE = ".env.local";
12
+ const TOOL_SELECTION_METADATA = {
13
+ paybond_get_principal: {
14
+ title: "Get Paybond Principal",
15
+ annotations: readOnlyToolAnnotations("Get Paybond Principal"),
16
+ outputSchema: outputObjectSchema({
17
+ tenant_id: { type: "string", description: "Tenant bound to the configured Paybond API key." },
18
+ subject: { type: "string" },
19
+ roles: { type: "array", items: { type: "string" } },
20
+ }),
21
+ },
22
+ paybond_verify_capability: {
23
+ title: "Verify Paybond Capability",
24
+ description: "Use this when you need raw capability-token verification for one tenant-bound Harbor intent. " +
25
+ "Do not use this to create, fund, or modify intents; use paybond_authorize_agent_spend as the clearer gate before side-effecting agent tools.",
26
+ annotations: additiveMutationToolAnnotations("Verify Paybond Capability"),
27
+ outputSchema: outputObjectSchema({
28
+ allow: { type: "boolean", description: "Whether the requested operation is allowed." },
29
+ tenant: { type: "string", description: "Tenant echoed by the gateway." },
30
+ intent_id: { type: "string", description: "Verified Harbor intent UUID." },
31
+ audit_id: { type: "string", description: "Gateway audit identifier when available." },
32
+ }, ["tenant", "intent_id"]),
33
+ },
34
+ paybond_authorize_agent_spend: {
35
+ title: "Authorize Agent Spend",
36
+ description: "Use this when an agent has an intent_id and capability_token and needs a tenant-bound spend gate before calling a side-effecting tool, paid API, vendor action, or settlement workflow. " +
37
+ "Do not use this for creating, funding, or changing intents; call paybond_create_spend_intent or paybond_fund_intent first when no funded capability token exists.",
38
+ annotations: additiveMutationToolAnnotations("Authorize Agent Spend"),
39
+ outputSchema: outputObjectSchema({
40
+ allow: { type: "boolean", description: "Whether the requested operation is allowed." },
41
+ tenant: { type: "string", description: "Tenant echoed by the gateway." },
42
+ intent_id: { type: "string", description: "Verified Harbor intent UUID." },
43
+ audit_id: { type: "string", description: "Gateway audit identifier when available." },
44
+ }, ["tenant", "intent_id"]),
45
+ },
46
+ paybond_bootstrap_sandbox_guardrail: {
47
+ title: "Bootstrap Sandbox Guardrail",
48
+ description: "Use this when building or testing a first paid-tool integration and you need a sandbox-only guardrail intent with no live settlement rails. " +
49
+ "Do not use this for production live money movement or already-created Harbor intents.",
50
+ annotations: additiveMutationToolAnnotations("Bootstrap Sandbox Guardrail"),
51
+ outputSchema: outputObjectSchema({
52
+ tenant_id: { type: "string" },
53
+ intent_id: { type: "string" },
54
+ capability_token: { type: "string" },
55
+ operation: { type: "string" },
56
+ requested_spend_cents: { type: "integer" },
57
+ sandbox_lifecycle_status: { type: "string" },
58
+ settlement_rail: { type: "string" },
59
+ settlement_mode: { type: "string" },
60
+ }, ["tenant_id", "intent_id", "capability_token", "operation", "requested_spend_cents", "sandbox_lifecycle_status"]),
61
+ },
62
+ paybond_submit_sandbox_guardrail_evidence: {
63
+ title: "Submit Sandbox Guardrail Evidence",
64
+ description: "Use this when a sandbox guardrail intent needs evidence to complete simulator settlement or predicate checks. " +
65
+ "Do not use this for live Harbor spend evidence; use paybond_submit_spend_evidence for production spend intents.",
66
+ annotations: additiveMutationToolAnnotations("Submit Sandbox Guardrail Evidence"),
67
+ outputSchema: outputObjectSchema({
68
+ tenant_id: { type: "string" },
69
+ intent_id: { type: "string" },
70
+ operation: { type: "string" },
71
+ requested_spend_cents: { type: "integer" },
72
+ sandbox_lifecycle_status: { type: "string" },
73
+ predicate_passed: { type: "boolean" },
74
+ payload_digest: { type: "string" },
75
+ }, ["tenant_id", "intent_id", "operation", "requested_spend_cents", "sandbox_lifecycle_status"]),
76
+ },
77
+ paybond_list_intents: {
78
+ title: "List Harbor Intents",
79
+ annotations: readOnlyToolAnnotations("List Harbor Intents"),
80
+ outputSchema: outputObjectSchema({
81
+ items: { type: "array", items: { type: "object", additionalProperties: true } },
82
+ next_cursor: { type: "string" },
83
+ }),
84
+ },
85
+ paybond_get_intent: {
86
+ title: "Get Harbor Intent",
87
+ annotations: readOnlyToolAnnotations("Get Harbor Intent"),
88
+ outputSchema: outputObjectSchema({
89
+ intent_id: { type: "string" },
90
+ state: { type: "string" },
91
+ tenant_id: { type: "string" },
92
+ }),
93
+ },
94
+ paybond_get_reputation_receipt: {
95
+ title: "Get Reputation Receipt",
96
+ annotations: readOnlyToolAnnotations("Get Reputation Receipt"),
97
+ outputSchema: outputObjectSchema({
98
+ tenant_id: { type: "string" },
99
+ operator_did: { type: "string" },
100
+ signature_hex: { type: "string" },
101
+ }),
102
+ },
103
+ paybond_get_portfolio_summary: {
104
+ title: "Get Portfolio Summary",
105
+ annotations: readOnlyToolAnnotations("Get Portfolio Summary"),
106
+ outputSchema: outputObjectSchema({
107
+ tenant_id: { type: "string" },
108
+ score_model_version: { type: "string" },
109
+ operators: { type: "array", items: { type: "object", additionalProperties: true } },
110
+ }),
111
+ },
112
+ paybond_get_signed_portfolio_artifact: {
113
+ title: "Get Signed Portfolio Artifact",
114
+ annotations: readOnlyToolAnnotations("Get Signed Portfolio Artifact"),
115
+ outputSchema: outputObjectSchema({
116
+ tenant_id: { type: "string" },
117
+ kind: { type: "string" },
118
+ signature_hex: { type: "string" },
119
+ checkpoint_last_ledger_seq: { type: "integer" },
120
+ }),
121
+ },
122
+ paybond_get_fraud_assessment: {
123
+ title: "Get Fraud Assessment",
124
+ annotations: readOnlyToolAnnotations("Get Fraud Assessment"),
125
+ outputSchema: outputObjectSchema({
126
+ tenant_id: { type: "string" },
127
+ operator_did: { type: "string" },
128
+ fraud_assessment: { type: "object", additionalProperties: true },
129
+ }),
130
+ },
131
+ paybond_get_fraud_metrics: {
132
+ title: "Get Fraud Metrics",
133
+ annotations: readOnlyToolAnnotations("Get Fraud Metrics"),
134
+ outputSchema: outputObjectSchema({
135
+ tenant_id: { type: "string" },
136
+ window: { type: "string" },
137
+ flagged_operator_count: { type: "integer" },
138
+ critical_signal_count: { type: "integer" },
139
+ }),
140
+ },
141
+ paybond_get_a2a_agent_card: {
142
+ title: "Get A2A Agent Card",
143
+ annotations: readOnlyToolAnnotations("Get A2A Agent Card"),
144
+ outputSchema: outputObjectSchema({
145
+ name: { type: "string" },
146
+ version: { type: "string" },
147
+ skills: { type: "array", items: { type: "object", additionalProperties: true } },
148
+ }),
149
+ },
150
+ paybond_list_a2a_task_contracts: {
151
+ title: "List A2A Task Contracts",
152
+ annotations: readOnlyToolAnnotations("List A2A Task Contracts"),
153
+ outputSchema: outputObjectSchema({
154
+ contracts: { type: "array", items: { type: "object", additionalProperties: true } },
155
+ }),
156
+ },
157
+ paybond_get_a2a_task_contract: {
158
+ title: "Get A2A Task Contract",
159
+ annotations: readOnlyToolAnnotations("Get A2A Task Contract"),
160
+ outputSchema: outputObjectSchema({
161
+ id: { type: "string" },
162
+ name: { type: "string" },
163
+ description: { type: "string" },
164
+ }),
165
+ },
166
+ paybond_verify_agent_mandate_v1: {
167
+ title: "Verify Agent Mandate",
168
+ annotations: readOnlyToolAnnotations("Verify Agent Mandate"),
169
+ outputSchema: outputObjectSchema({
170
+ valid: { type: "boolean" },
171
+ mandate_digest_sha256_hex: { type: "string" },
172
+ }),
173
+ },
174
+ paybond_verify_agent_recognition_proof_v1: {
175
+ title: "Verify Agent Recognition Proof",
176
+ annotations: readOnlyToolAnnotations("Verify Agent Recognition Proof"),
177
+ outputSchema: outputObjectSchema({
178
+ valid: { type: "boolean" },
179
+ proof: { type: "object", additionalProperties: true },
180
+ }),
181
+ },
182
+ paybond_import_agent_mandate_v1: {
183
+ title: "Import Agent Mandate",
184
+ annotations: additiveMutationToolAnnotations("Import Agent Mandate"),
185
+ outputSchema: outputObjectSchema({
186
+ valid: { type: "boolean" },
187
+ intent_id: { type: "string" },
188
+ mandate_digest_sha256_hex: { type: "string" },
189
+ authorization_receipt: { type: "object", additionalProperties: true },
190
+ }),
191
+ },
192
+ paybond_get_settlement_receipt_v1: {
193
+ title: "Get Settlement Receipt",
194
+ annotations: readOnlyToolAnnotations("Get Settlement Receipt"),
195
+ outputSchema: outputObjectSchema({
196
+ tenant_id: { type: "string" },
197
+ receipt_id: { type: "string" },
198
+ intent_id: { type: "string" },
199
+ }, ["tenant_id", "receipt_id"]),
200
+ },
201
+ paybond_verify_protocol_receipt_v1: {
202
+ title: "Verify Protocol Receipt",
203
+ annotations: readOnlyToolAnnotations("Verify Protocol Receipt"),
204
+ outputSchema: outputObjectSchema({
205
+ valid: { type: "boolean" },
206
+ receipt_id: { type: "string" },
207
+ }),
208
+ },
209
+ paybond_create_intent: {
210
+ title: "Create Harbor Intent",
211
+ description: "Use this when you already have a fully signed Harbor intent request body and replay-safe recognition proof for the gateway /harbor/intents route. " +
212
+ "Do not use this for the normal agent spend-control path unless you specifically need the low-level Harbor API; prefer paybond_create_spend_intent.",
213
+ annotations: additiveMutationToolAnnotations("Create Harbor Intent"),
214
+ outputSchema: outputObjectSchema({
215
+ intent_id: { type: "string" },
216
+ state: { type: "string" },
217
+ capability_token: { type: "string" },
218
+ }),
219
+ },
220
+ paybond_create_spend_intent: {
221
+ title: "Create Spend Intent",
222
+ description: "Use this when an agent workflow needs a new Paybond spend intent with bounded budget, allowed operations, evidence requirements, and settlement review. " +
223
+ "Do not use this for checking an already funded capability token; use paybond_authorize_agent_spend before the paid action.",
224
+ annotations: additiveMutationToolAnnotations("Create Spend Intent"),
225
+ outputSchema: outputObjectSchema({
226
+ intent_id: { type: "string" },
227
+ state: { type: "string" },
228
+ capability_token: { type: "string" },
229
+ }),
230
+ },
231
+ paybond_fund_intent: {
232
+ title: "Fund Intent",
233
+ description: "Use this when an existing Harbor intent needs to advance through funding via the gateway and you have a replay-safe recognition proof. " +
234
+ "Do not use this to create a new intent or to authorize a downstream tool call; use the returned intent_id and capability_token with paybond_authorize_agent_spend.",
235
+ annotations: liveMutationToolAnnotations("Fund Intent"),
236
+ outputSchema: outputObjectSchema({
237
+ intent_id: { type: "string" },
238
+ state: { type: "string" },
239
+ capability_token: { type: "string" },
240
+ }),
241
+ },
242
+ paybond_submit_evidence: {
243
+ title: "Submit Harbor Evidence",
244
+ description: "Use this when you already have a Harbor evidence request body and recognition proof for the gateway /harbor/intents/{id}/evidence route. " +
245
+ "Do not use this for the high-level spend-control path unless you need the low-level Harbor API; prefer paybond_submit_spend_evidence.",
246
+ annotations: additiveMutationToolAnnotations("Submit Harbor Evidence"),
247
+ outputSchema: outputObjectSchema({
248
+ intent_id: { type: "string" },
249
+ state: { type: "string" },
250
+ evidence_id: { type: "string" },
251
+ }),
252
+ },
253
+ paybond_submit_spend_evidence: {
254
+ title: "Submit Spend Evidence",
255
+ description: "Use this when a Paybond spend intent needs signed evidence so release, refund, review, and receipt generation use the same audit-ready record. " +
256
+ "Do not use this to create or fund intents, and do not use it for sandbox guardrail evidence.",
257
+ annotations: additiveMutationToolAnnotations("Submit Spend Evidence"),
258
+ outputSchema: outputObjectSchema({
259
+ intent_id: { type: "string" },
260
+ state: { type: "string" },
261
+ evidence_id: { type: "string" },
262
+ }),
263
+ },
264
+ paybond_confirm_settlement: {
265
+ title: "Confirm Settlement",
266
+ description: "Use this when a Harbor intent is ready for final settlement confirmation and you have the signed body plus recognition proof. " +
267
+ "Do not use this for evidence submission or capability authorization.",
268
+ annotations: liveMutationToolAnnotations("Confirm Settlement"),
269
+ outputSchema: outputObjectSchema({
270
+ intent_id: { type: "string" },
271
+ state: { type: "string" },
272
+ receipt_id: { type: "string" },
273
+ }),
274
+ },
275
+ };
12
276
  function readEnvFileValue(envFile, key) {
13
277
  let body;
14
278
  try {
@@ -393,8 +657,11 @@ export class PaybondMCPServer {
393
657
  listTools() {
394
658
  return this.tools.map((tool) => ({
395
659
  name: tool.name,
660
+ title: tool.title,
396
661
  description: tool.description,
397
662
  inputSchema: tool.inputSchema,
663
+ ...(tool.outputSchema === undefined ? {} : { outputSchema: tool.outputSchema }),
664
+ ...(tool.annotations === undefined ? {} : { annotations: tool.annotations }),
398
665
  }));
399
666
  }
400
667
  async callTool(name, args = {}) {
@@ -445,7 +712,10 @@ export class PaybondMCPServer {
445
712
  },
446
713
  serverInfo: {
447
714
  name: SERVER_NAME,
715
+ title: "Paybond MCP",
448
716
  version: SERVER_VERSION,
717
+ description: "Tenant-bound Paybond gateway tools for agent spend controls, Harbor intents, Signal reputation, fraud review, and protocol verification.",
718
+ websiteUrl: "https://paybond.ai",
449
719
  },
450
720
  instructions: "This MCP server is tenant-bound to the configured Paybond service-account API key. " +
451
721
  "Use paybond_create_spend_intent or paybond_fund_intent to obtain the intent_id and " +
@@ -872,7 +1142,7 @@ export class PaybondMCPServer {
872
1142
  }),
873
1143
  },
874
1144
  ];
875
- return tools;
1145
+ return tools.map((tool) => toolWithSelectionMetadata(tool));
876
1146
  }
877
1147
  }
878
1148
  export function settingsFromEnv(env = process.env) {
@@ -882,7 +1152,9 @@ export function settingsFromEnv(env = process.env) {
882
1152
  throw new Error("PAYBOND_API_KEY is required; run paybond login or configure your MCP host environment");
883
1153
  }
884
1154
  return {
885
- gatewayBaseUrl: optionalEnv(env.PAYBOND_GATEWAY_BASE_URL) ?? DEFAULT_PAYBOND_GATEWAY_BASE_URL,
1155
+ gatewayBaseUrl: optionalEnv(env.PAYBOND_GATEWAY_URL) ??
1156
+ optionalEnv(env.PAYBOND_GATEWAY_BASE_URL) ??
1157
+ DEFAULT_PAYBOND_GATEWAY_BASE_URL,
886
1158
  apiKey,
887
1159
  principalPath: optionalEnv(env.PAYBOND_PRINCIPAL_PATH) ?? DEFAULT_PRINCIPAL_PATH,
888
1160
  maxRetries: optionalEnv(env.PAYBOND_MCP_MAX_RETRIES)
@@ -985,6 +1257,52 @@ function emptyObjectSchema() {
985
1257
  additionalProperties: false,
986
1258
  };
987
1259
  }
1260
+ function outputObjectSchema(properties, required = []) {
1261
+ return {
1262
+ type: "object",
1263
+ properties,
1264
+ additionalProperties: true,
1265
+ ...(required.length === 0 ? {} : { required }),
1266
+ };
1267
+ }
1268
+ function readOnlyToolAnnotations(title) {
1269
+ return {
1270
+ title,
1271
+ readOnlyHint: true,
1272
+ openWorldHint: false,
1273
+ };
1274
+ }
1275
+ function additiveMutationToolAnnotations(title) {
1276
+ return {
1277
+ title,
1278
+ readOnlyHint: false,
1279
+ destructiveHint: false,
1280
+ idempotentHint: false,
1281
+ openWorldHint: true,
1282
+ };
1283
+ }
1284
+ function liveMutationToolAnnotations(title) {
1285
+ return {
1286
+ title,
1287
+ readOnlyHint: false,
1288
+ destructiveHint: true,
1289
+ idempotentHint: false,
1290
+ openWorldHint: true,
1291
+ };
1292
+ }
1293
+ function toolWithSelectionMetadata(tool) {
1294
+ const metadata = TOOL_SELECTION_METADATA[tool.name];
1295
+ if (metadata === undefined) {
1296
+ throw new Error(`missing MCP tool selection metadata for ${tool.name}`);
1297
+ }
1298
+ return {
1299
+ ...tool,
1300
+ title: metadata.title,
1301
+ description: metadata.description ?? tool.description,
1302
+ outputSchema: metadata.outputSchema,
1303
+ annotations: metadata.annotations,
1304
+ };
1305
+ }
988
1306
  function toToolResult(value) {
989
1307
  if (value === null) {
990
1308
  return {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@paybond/kit",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
+ "mcpName": "io.github.nonameuserd/paybond",
4
5
  "description": "Paybond Kit for TypeScript: agent spend governance for paid tool calls with spend authorization, evidence receipts, refunds, disputes, hosted Gateway sessions, and settlement.",
5
6
  "license": "Apache-2.0",
6
7
  "type": "module",