/** * A single MCP JSON-RPC message. ContextVM stringifies this into the `content` * field of a Nostr event; the shell wraps and unwraps the transport for the napplet. * * The embedded `id` is the MCP/JSON-RPC correlation id and is independent of the * NIP-5D envelope `id` used to correlate `cvm.request` with `cvm.request.result`. */ interface McpMessage { jsonrpc: '2.0'; /** JSON-RPC correlation id (distinct from the NIP-5D envelope id). */ id?: string | number; /** JSON-RPC method (e.g. `tools/call`); present on requests and notifications. */ method?: string; /** Method parameters. */ params?: unknown; /** Successful result payload (present on responses). */ result?: unknown; /** Error payload (present on failed responses). */ error?: unknown; } /** * An MCP tool definition, as returned by `tools/list`. */ interface McpTool { /** Unique tool name used as the `tools/call` argument. */ name: string; /** Human-readable description of what the tool does. */ description?: string; /** JSON Schema describing the tool's input arguments. */ inputSchema: { type: 'object'; properties?: Record; required?: string[]; }; } /** * An MCP resource descriptor, as returned by `resources/list`. */ interface McpResource { /** Canonical resource URI. */ uri: string; /** Programmatic resource name. */ name: string; /** Optional display title. */ title?: string; /** Human-readable description. */ description?: string; /** Resource MIME type, when known. */ mimeType?: string; /** Resource size in bytes, when known. */ size?: number; } /** Binary contents of an MCP resource (`resources/read`); `blob` is base64-encoded. */ interface McpBlobResourceContents { uri: string; mimeType?: string; /** Base64-encoded resource bytes. */ blob: string; } /** * Identifies a ContextVM server by its Nostr public key, with optional relay hints. * The shell decides which relays to actually route through per its relay policy. */ interface CvmServerRef { /** Hex-encoded Nostr public key of the ContextVM server. */ pubkey: string; /** Optional relay URL hints; the shell MAY use, ignore, or augment these. */ relays?: string[]; } /** * Filter for `cvm.discover`. All fields are optional; an empty query asks the * shell for whatever public ContextVM server announcements it knows about. */ interface CvmDiscoverQuery { /** Free-text search over server name/description/capabilities. */ search?: string; /** Restrict to specific Nostr event kinds (announcement kinds). */ kinds?: number[]; /** Relay URL hints to search. */ relays?: string[]; /** Maximum number of servers to return. */ limit?: number; } /** * A discovered ContextVM server announcement. */ interface CvmServer extends CvmServerRef { /** Display name from the server announcement. */ name?: string; /** Human-readable description. */ description?: string; /** Advertised capability tags (e.g. MCP capabilities). */ capabilities?: string[]; /** Whether the server requires value exchange before serving requests. */ paymentRequired?: boolean; } /** * Per-request options for `cvm.request` and the MCP convenience wrappers. */ interface CvmRequestOptions { /** Wall-clock budget for the request, in milliseconds. */ timeoutMs?: number; /** Ask the shell to perform MCP initialization before this request. */ initialize?: boolean; /** * Payment posture if the server requires value exchange: * - `deny` -- never pay (fail with `payment required`) * - `prompt` -- ask the user * - `allow` -- pay within the user's explicit allowance */ payment?: 'deny' | 'prompt' | 'allow'; } export type { CvmDiscoverQuery as C, McpBlobResourceContents as M, CvmRequestOptions as a, CvmServer as b, CvmServerRef as c, McpMessage as d, McpResource as e, McpTool as f };