run402-mcp
Version:
MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.
80 lines • 3.22 kB
TypeScript
import { HTTP_PROFILE, MCP_PROFILE } from "./constants.js";
export type RequestBindingProfile = typeof HTTP_PROFILE | typeof MCP_PROFILE;
/**
* The request-binding fields carried in `PaymentRequirements.extra`.
*/
export interface RequestBindingExtra {
requestHash: string;
requestBindingProfile: RequestBindingProfile;
requestBindingParams: Record<string, unknown>;
}
/**
* A request binding computed from the actual request or tool call.
*/
export interface RequestBinding extends RequestBindingExtra {
/** For `http:1`, the request URL that `PaymentRequired.resource.url` must equal. */
resourceUrl?: string;
}
/**
* HTTP request inputs for the `http:1` profile.
*/
export interface HttpRequestInput {
/** HTTP method, case preserved (RFC 9421 `@method`). */
method: string;
/** Absolute http(s) target URI including the query, no fragment or userinfo. */
url: string;
/** Content bytes after transfer decoding, before content decoding; empty if absent. */
body?: Uint8Array;
/** Lowercase header names to bind, configured by the server for the resource. */
boundHeaders: readonly string[];
/** Header lookup by lowercase name; `undefined` when absent. */
getHeader: (name: string) => string | readonly string[] | undefined;
}
/**
* MCP `tools/call` inputs for the `mcp:1` profile.
*/
export interface McpToolCallInput {
/** Configured absolute URI identifying the MCP server. */
server: string;
/** Actual `params.name`. */
name: string;
/** Actual `params.arguments`, before defaults; `undefined` when omitted. */
arguments?: unknown;
/** Actual `params._meta`; `undefined` when omitted. */
meta?: unknown;
/** `_meta` member names to bind, configured by the server for the tool. */
boundMetadata: readonly string[];
}
/**
* Computes the `http:1` binding for an HTTP request.
*
* @param input - The actual request and the configured bound headers
* @returns The binding, including the expected `PaymentRequired.resource.url`
* @throws LnbtcError `invalid_exact_lnbtc_request_binding` on malformed input
*/
export declare function httpRequestBinding(input: HttpRequestInput): RequestBinding;
/**
* Computes the `mcp:1` binding for an MCP `tools/call`.
*
* @param input - The actual tool call and the configured server and metadata names
* @returns The binding
* @throws LnbtcError `invalid_exact_lnbtc_request_binding` on malformed input
*/
export declare function mcpToolCallBinding(input: McpToolCallInput): RequestBinding;
/**
* Validates the binding fields of a requirements `extra` object.
*
* @param extra - `PaymentRequirements.extra`
* @returns The validated binding fields
* @throws LnbtcError `invalid_exact_lnbtc_request_binding` when missing or malformed
*/
export declare function parseBindingExtra(extra: Record<string, unknown> | undefined): RequestBindingExtra;
/**
* Compares two validated bindings: hash, profile, and JCS-equal parameters.
*
* @param a - First binding
* @param b - Second binding
* @returns Whether they are equal
*/
export declare function bindingsEqual(a: RequestBindingExtra, b: RequestBindingExtra): boolean;
//# sourceMappingURL=binding.d.ts.map