UNPKG

agents

Version:

A home for your AI agents

156 lines (154 loc) • 5 kB
import { t as LegacyCallToolResultSchema } from "../../invoker-DoLFPJZV.js"; import { ZodRawShape, z } from "zod"; import { CallToolRequest, CallToolRequestOptions, Client } from "@modelcontextprotocol/client"; import { CallToolResult, McpServer, RegisteredTool, ServerContext } from "@modelcontextprotocol/server"; import { CallToolResult as CallToolResult$1, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js"; import { McpServer as McpServer$1, RegisteredTool as RegisteredTool$1, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js"; import { Client as Client$1 } from "@modelcontextprotocol/sdk/client/index.js"; import { FacilitatorConfig, FacilitatorConfig as FacilitatorConfig$1 } from "@x402/core/server"; 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/client/invoker-compat.d.ts type CompatibleMcpClient = Client | Client$1; //#endregion //#region src/mcp/client/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; }; /** * The tool body passed to `paidTool`. On an SDK v1 server it is the v1 * `ToolCallback`; on an SDK v2 server it receives the v2 `ServerContext`. */ type PaidToolCallback< Args extends ZodRawShape, Server extends McpServer$1 | McpServer = McpServer$1 > = Server extends McpServer ? ( args: z.infer<z.ZodObject<Args>>, ctx: ServerContext ) => CallToolResult | Promise<CallToolResult> : ToolCallback<Args>; interface X402AugmentedServer< Server extends McpServer$1 | McpServer = McpServer$1 > { paidTool<Args extends ZodRawShape>( name: string, description: string, priceUSD: number, paramsSchema: Args, annotations: ToolAnnotations, cb: PaidToolCallback<Args, Server> ): Server extends McpServer ? RegisteredTool : RegisteredTool$1; } /** * Add `paidTool` to an MCP server. Accepts an SDK v1 `McpServer` * (`@modelcontextprotocol/sdk`) or an SDK v2 `McpServer` * (`@modelcontextprotocol/server`). */ declare function withX402<T extends McpServer>( server: T, cfg: X402Config ): T & X402AugmentedServer<McpServer>; declare function withX402<T extends McpServer$1>( server: T, cfg: X402Config ): T & X402AugmentedServer; interface X402AugmentedClient { callTool( x402ConfirmationCallback: | ((payment: PaymentRequirements$1[]) => Promise<boolean>) | null, params: CallToolRequest["params"], options?: CallToolRequestOptions ): Promise<CallToolResult$1>; /** * @deprecated Prefer the request-options overload. Explicit legacy result * schemas remain honored through the SDK v2 request funnel. */ callTool( x402ConfirmationCallback: | ((payment: PaymentRequirements$1[]) => Promise<boolean>) | null, params: CallToolRequest["params"], resultSchema: LegacyCallToolResultSchema, options?: CallToolRequestOptions ): Promise<CallToolResult$1>; } 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 CompatibleMcpClient>( client: T, x402Config: X402ClientConfig ): X402AugmentedClient & T; //#endregion export { type ClientEvmSigner, type FacilitatorConfig, type Network, PaidToolCallback, type PaymentRequired, type PaymentRequirements, X402AugmentedClient, X402AugmentedServer, X402ClientConfig, X402Config, normalizeNetwork, withX402, withX402Client }; //# sourceMappingURL=x402.d.ts.map