UNPKG

askexperts

Version:

AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol

99 lines (98 loc) 3.12 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; /** * Interface for BidMCP objects returned by findExperts */ export interface BidMCP { id: string; expert_pubkey: string; offer: string; } /** * Interface for ReplyMCP objects returned by askExperts/askExpert */ export interface ReplyMCP { expert_pubkey: string; content?: string; amount_sats?: number; error?: string; } /** * AskExpertsMCP class that extends McpServer and provides a simplified interface * for clients to interact with the AskExpertsClient */ export declare class AskExpertsMCP extends McpServer { private client; private paymentManager; private bidMap; /** * Creates a new AskExpertsMCP instance * * @param nwcString - NWC connection string for payments * @param discoveryRelays - Optional list of discovery relays */ constructor(nwcString: string, discoveryRelays?: string[]); /** * Register all tools with the MCP server */ private registerTools; /** * Handles quote events from experts * * @param quote - Quote from expert * @param prompt - Prompt sent to expert * @param max_amount_sats - Maximum amount to pay in satoshis * @returns Promise resolving to the invoice amount if it's within max_amount_sats, otherwise 0 * @private */ private handleQuote; /** * Handles payment for quotes * * @param quote - Quote from expert * @param prompt - Prompt sent to expert * @returns Promise resolving to Proof object * @private */ private handlePayment; private gc; /** * Finds experts based on a summary and hashtags * * @param summary - Summary of the question * @param hashtags - Hashtags for discovery * @returns Promise resolving to array of BidMCP objects */ findExperts(summary: string, hashtags: string[]): Promise<BidMCP[]>; /** * Asks multiple experts a question * * @param question - Question to ask * @param bids - Array of BidMCP objects * @param max_amount_sats - Maximum amount to pay in satoshis * @returns Promise resolving to array of ReplyMCP objects */ askExperts(question: string, bids: BidMCP[], max_amount_sats: number): Promise<ReplyMCP[]>; /** * Asks a single expert a question * * @param question - Question to ask * @param expert_pubkey - Expert's public key * @param max_amount_sats - Maximum amount to pay in satoshis * @returns Promise resolving to ReplyMCP object */ askExpert(question: string, expert_pubkey: string, max_amount_sats: number): Promise<ReplyMCP>; /** * Internal method to ask an expert a question * * @param question - Question to ask * @param bid - Bid object * @param max_amount_sats - Maximum amount to pay in satoshis * @returns Promise resolving to ReplyMCP object * @private */ private askExpertInternal; /** * Disposes of resources when the object is no longer needed */ [Symbol.dispose](): void; }