agents
Version:
A home for your AI agents
53 lines (52 loc) • 3.33 kB
TypeScript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { CallToolRequest, CallToolResult, CallToolResultSchema, CompatibilityCallToolResultSchema, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
import { ZodRawShape } from "zod";
import { McpServer, RegisteredTool, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
import { FacilitatorConfig, FacilitatorConfig as FacilitatorConfig$1 } from "@x402/core/server";
import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
import { Network, Network as Network$1, PaymentRequired, PaymentRequirements, PaymentRequirements as PaymentRequirements$1 } from "@x402/core/types";
import { ClientEvmSigner, ClientEvmSigner as ClientEvmSigner$1 } from "@x402/evm";
//#region src/mcp/x402.d.ts
/**
* Normalize a network identifier to CAIP-2 format.
* Accepts both legacy v1 names ("base-sepolia") and CAIP-2 ("eip155:84532").
*/
declare function normalizeNetwork(network: string): Network$1;
type X402Config = {
/**
* Network identifier.
* Accepts both legacy names ("base-sepolia") and CAIP-2 format ("eip155:84532").
*/
network: string; /** Payment recipient address */
recipient: `0x${string}`; /** Facilitator configuration. Defaults to https://x402.org/facilitator */
facilitator?: FacilitatorConfig$1; /** @deprecated No longer used in v2. The protocol version is determined automatically. */
version?: number;
};
interface X402AugmentedServer {
paidTool<Args extends ZodRawShape>(name: string, description: string, priceUSD: number, paramsSchema: Args, annotations: ToolAnnotations, cb: ToolCallback<Args>): RegisteredTool;
}
declare function withX402<T extends McpServer>(server: T, cfg: X402Config): T & X402AugmentedServer;
interface X402AugmentedClient {
callTool(x402ConfirmationCallback: ((payment: PaymentRequirements$1[]) => Promise<boolean>) | null, params: CallToolRequest["params"], resultSchema?: typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema, options?: RequestOptions): Promise<CallToolResult>;
}
type X402ClientConfig = {
/**
* EVM account/signer for signing payment authorizations.
* Use `privateKeyToAccount()` from viem/accounts to create one.
*/
account: ClientEvmSigner$1;
/**
* Preferred network identifier (optional).
* Accepts both legacy names ("base-sepolia") and CAIP-2 format ("eip155:84532").
* When set, the client prefers payment requirements matching this network.
* If omitted, the client automatically selects from available requirements.
*/
network?: string; /** Maximum payment value in atomic units (default: 0.10 USDC = 100000) */
maxPaymentValue?: bigint; /** @deprecated No longer used in v2. The protocol version is determined automatically. */
version?: number; /** Confirmation callback for payment approval */
confirmationCallback?: (payment: PaymentRequirements$1[]) => Promise<boolean>;
};
declare function withX402Client<T extends Client>(client: T, x402Config: X402ClientConfig): X402AugmentedClient & T;
//#endregion
export { type ClientEvmSigner, type FacilitatorConfig, type Network, type PaymentRequired, type PaymentRequirements, X402AugmentedClient, X402AugmentedServer, X402ClientConfig, X402Config, normalizeNetwork, withX402, withX402Client };
//# sourceMappingURL=x402.d.ts.map