agents 0.2.0 → 0.2.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.
@@ -6,6 +6,12 @@ import { Network, FacilitatorConfig, PaymentRequirements } from 'x402/types';
6
6
  import { RequestOptions } from '@modelcontextprotocol/sdk/shared/protocol.js';
7
7
  import { Account } from 'viem';
8
8
 
9
+ /**
10
+ * X402 MCP Integration
11
+ *
12
+ * Based on Coinbase's x402 (Apache 2.0): https://github.com/coinbase/x402
13
+ */
14
+
9
15
  type X402Config = {
10
16
  network: Network;
11
17
  recipient: `0x${string}`;
package/dist/mcp/x402.js CHANGED
@@ -3005,7 +3005,7 @@ function withX402(server, cfg) {
3005
3005
  const payload = { x402Version, error: "PRICE_COMPUTE_FAILED" };
3006
3006
  return {
3007
3007
  isError: true,
3008
- _meta: { "x402.error": payload },
3008
+ _meta: { "x402/error": payload },
3009
3009
  content: [{ type: "text", text: JSON.stringify(payload) }]
3010
3010
  };
3011
3011
  }
@@ -3017,13 +3017,13 @@ function withX402(server, cfg) {
3017
3017
  payTo: cfg.recipient,
3018
3018
  asset: asset.address,
3019
3019
  maxTimeoutSeconds: 300,
3020
- resource: `mcp://tool/${name}`,
3020
+ resource: `x402://${name}`,
3021
3021
  mimeType: "application/json",
3022
3022
  description,
3023
3023
  extra: "eip712" in asset ? asset.eip712 : void 0
3024
3024
  };
3025
3025
  const headers = extra?.requestInfo?.headers ?? {};
3026
- const token = extra?._meta?.["x402.payment"] ?? headers["X-PAYMENT"];
3026
+ const token = extra?._meta?.["x402/payment"] ?? headers["X-PAYMENT"];
3027
3027
  const paymentRequired = (reason = "PAYMENT_REQUIRED", extraFields = {}) => {
3028
3028
  const payload = {
3029
3029
  x402Version,
@@ -3033,7 +3033,7 @@ function withX402(server, cfg) {
3033
3033
  };
3034
3034
  return {
3035
3035
  isError: true,
3036
- _meta: { "x402.error": payload },
3036
+ _meta: { "x402/error": payload },
3037
3037
  content: [{ type: "text", text: JSON.stringify(payload) }]
3038
3038
  };
3039
3039
  };
@@ -3072,7 +3072,7 @@ function withX402(server, cfg) {
3072
3072
  const s = await settle(decoded, requirements);
3073
3073
  if (s.success) {
3074
3074
  result._meta ??= {};
3075
- result._meta["x402.payment-response"] = {
3075
+ result._meta["x402/payment-response"] = {
3076
3076
  success: true,
3077
3077
  transaction: s.transaction,
3078
3078
  network: s.network,
@@ -3135,7 +3135,7 @@ function withX402Client(client, x402Config) {
3135
3135
  const callToolWithPayment = async (x402ConfirmationCallback, params, resultSchema, options) => {
3136
3136
  const res = await _callTool(params, resultSchema, options);
3137
3137
  console.log("res", res);
3138
- const maybeX402Error = res._meta?.["x402.error"];
3138
+ const maybeX402Error = res._meta?.["x402/error"];
3139
3139
  if (res.isError && maybeX402Error && maybeX402Error.accepts && Array.isArray(maybeX402Error.accepts) && maybeX402Error.accepts.length > 0) {
3140
3140
  const accepts = maybeX402Error.accepts;
3141
3141
  const confirmationCallback = x402ConfirmationCallback ?? x402Config.confirmationCallback;
@@ -3169,7 +3169,7 @@ function withX402Client(client, x402Config) {
3169
3169
  ...params,
3170
3170
  _meta: {
3171
3171
  ...params._meta,
3172
- "x402.payment": token
3172
+ "x402/payment": token
3173
3173
  }
3174
3174
  },
3175
3175
  resultSchema,