@hashgraphonline/hedera-agent-kit
Version:
Build LLM-powered applications that interact with the Hedera Network. Create conversational agents that can understand user requests in natural language and execute Hedera transactions, or build backend systems that leverage AI for on-chain operations.
189 lines (187 loc) • 7.49 kB
TypeScript
import { CreditBalance, PaymentTransaction, PaymentVerification, PaymentStatus, PaymentHistory, CreditHistory, PricingConfiguration, AuthChallenge, AuthSignatureParams, AuthResponse, ApiKeyList, RotateKeyResponse, RevokeKeyResponse, MCPClientConfig, HealthCheckResult, ServerInfo, GenerateTransactionParams, GenerateTransactionResult, ScheduleTransactionParams, ScheduleTransactionResult, ExecuteTransactionParams, ExecuteTransactionResult, ProcessPaymentParams, ProcessPaymentResult, ProfileRefreshResult, ExecuteQueryParams, ExecuteQueryResult } from './types';
/**
* MCP Client for communicating with the Hedera MCP Server
* Provides access to credit management, authentication, and tool execution
*/
export declare class MCPClient {
private client;
private isConnected;
private logger;
private apiKey;
private serverUrl;
private clientName;
private clientVersion;
private static instance;
static getInstance(config?: MCPClientConfig): MCPClient;
static setInstance(instance: MCPClient | null): void;
constructor(config?: MCPClientConfig);
/**
* Set the API key for authentication
* @param apiKey The API key to use for authentication
*/
setApiKey(apiKey: string | null): void;
/**
* Get the current API key
* @returns The current API key or null
*/
getApiKey(): string | null;
/**
* Connects to the MCP server using streaming HTTP transport
* @returns Promise that resolves when connected
*/
connect(): Promise<void>;
/**
* Calls a tool on the MCP server
* @param toolName The name of the tool to call
* @param args Arguments to pass to the tool
* @returns The tool result
*/
callTool<T = unknown>(toolName: string, args?: Record<string, unknown>): Promise<T>;
/**
* Gets credit balance for an account
* @param accountId The Hedera account ID
* @returns The credit balance information
*/
getCreditBalance(accountId: string): Promise<CreditBalance>;
/**
* Creates a payment transaction for purchasing credits
* @param payerAccountId The payer's Hedera account ID
* @param amount The amount of HBAR to pay
* @param memo Optional transaction memo
* @returns Transaction details including bytes and ID
*/
createPaymentTransaction(payerAccountId: string, amount: number, memo?: string): Promise<PaymentTransaction>;
/**
* Verifies a payment transaction and allocates credits
* @param transactionId The transaction ID to verify
* @returns Verification result
*/
verifyPayment(transactionId: string): Promise<PaymentVerification>;
/**
* Checks payment status
* @param transactionId The transaction ID to check
* @returns Payment status
*/
checkPaymentStatus(transactionId: string): Promise<PaymentStatus>;
/**
* Gets payment history for an account
* @param accountId The Hedera account ID
* @param limit Maximum number of records to return
* @returns Payment history with transactions
*/
getPaymentHistory(accountId: string, limit?: number): Promise<PaymentHistory>;
/**
* Gets pricing configuration
* @returns Pricing tiers and configuration
*/
getPricingConfiguration(): Promise<PricingConfiguration>;
/**
* Request authentication challenge from MCP server
* @param hederaAccountId The Hedera account ID requesting authentication
* @returns Authentication challenge details
*/
requestAuthChallenge(hederaAccountId: string): Promise<AuthChallenge>;
/**
* Verify signature and authenticate with MCP server
* @param params Authentication parameters including signature and challenge
* @returns API key and authentication details
*/
verifyAuthSignature(params: AuthSignatureParams): Promise<AuthResponse>;
/**
* Get API keys for the authenticated account
* @param hederaAccountId The Hedera account ID (optional, uses authenticated account if not provided)
* @returns List of API keys for the account
*/
getApiKeys(hederaAccountId?: string): Promise<ApiKeyList>;
/**
* Rotate an API key
* @param params Rotation parameters
* @returns New API key details
*/
rotateApiKey(params: {
keyId: string;
hederaAccountId: string;
}): Promise<RotateKeyResponse>;
/**
* Revoke an API key
* @param params Revocation parameters
* @returns Revocation status
*/
revokeApiKey(params: {
keyId: string;
hederaAccountId: string;
}): Promise<RevokeKeyResponse>;
/**
* Gets credit transaction history
* @param accountId The Hedera account ID
* @param limit Maximum number of records to return
* @returns Credit transaction history
*/
getCreditHistory(accountId: string, limit?: number): Promise<CreditHistory>;
/**
* Check server health and status
* @returns Server health information
*/
healthCheck(): Promise<HealthCheckResult>;
/**
* Get server configuration and capabilities
* @returns Server information including version and capabilities
*/
getServerInfo(): Promise<ServerInfo>;
/**
* Generate transaction bytes for any Hedera operation without execution
* @param params Transaction parameters
* @returns Transaction bytes and metadata
*/
generateTransactionBytes(params: GenerateTransactionParams): Promise<GenerateTransactionResult>;
/**
* Create scheduled transaction for any Hedera operation
* @param params Schedule transaction parameters
* @returns Scheduled transaction details
*/
scheduleTransaction(params: ScheduleTransactionParams): Promise<ScheduleTransactionResult>;
/**
* Execute any Hedera transaction immediately
* @param params Transaction execution parameters
* @returns Transaction result
*/
executeTransaction(params: ExecuteTransactionParams): Promise<ExecuteTransactionResult>;
/**
* Manually process an HBAR payment for credit allocation
* @param params Payment processing parameters
* @returns Payment processing result
*/
processHbarPayment(params: ProcessPaymentParams): Promise<ProcessPaymentResult>;
/**
* Refresh server HCS-11 profile and registration status
* @returns Profile refresh result
*/
refreshProfile(): Promise<ProfileRefreshResult>;
/**
* Execute read-only queries on Hedera network
* @param params Query parameters
* @returns Query result
*/
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
/**
* Gets the current connection status
* @returns True if connected, false otherwise
*/
get connected(): boolean;
/**
* Disconnects from the MCP server
* @returns Promise that resolves when disconnected
*/
disconnect(): Promise<void>;
}
/**
* Gets the singleton MCP client instance for communicating with the Hedera MCP Server
* @param config Optional configuration to override defaults
* @returns The singleton MCPClient instance
*/
export declare function getMCPClient(config?: MCPClientConfig): MCPClient;
/**
* Resets the MCP client instance by disconnecting the current client and clearing the singleton
* @returns A promise that resolves when the client has been disconnected and reset
*/
export declare function resetMCPClient(): Promise<void>;