UNPKG

@toolprint/hypertool-mcp

Version:

HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers

129 lines • 3.1 kB
/** * Efficient lookup structures for tool storage and retrieval */ import { DiscoveredTool } from "./types.js"; /** * Tool lookup index for fast retrieval */ export interface ToolLookupIndex { byName: Map<string, DiscoveredTool[]>; byServer: Map<string, DiscoveredTool[]>; byNamespaced: Map<string, DiscoveredTool>; byDescription: Map<string, DiscoveredTool[]>; searchableText: Map<string, string[]>; } /** * Search query options */ export interface SearchQuery { name?: string; server?: string; keywords?: string[]; fuzzy?: boolean; limit?: number; offset?: number; } /** * Search result with relevance scoring */ export interface SearchResult { tool: DiscoveredTool; score: number; matchType: "exact" | "prefix" | "fuzzy" | "keyword"; matchedField: "name" | "namespacedName" | "description" | "schema"; } /** * Tool lookup manager with efficient indexing and search */ export declare class ToolLookupManager { private index; private tools; constructor(); /** * Add or update a tool in the lookup index */ addTool(tool: DiscoveredTool): void; /** * Remove a tool from the lookup index */ removeTool(tool: DiscoveredTool): boolean; /** * Get a tool by exact namespaced name */ getByNamespacedName(namespacedName: string): DiscoveredTool | null; /** * Get tools by original name */ getByName(name: string): DiscoveredTool[]; /** * Get tools by server name */ getByServer(serverName: string): DiscoveredTool[]; /** * Search tools with relevance scoring */ search(query: SearchQuery): SearchResult[]; /** * Get all tools */ getAllTools(): DiscoveredTool[]; /** * Get tool count by server */ getServerCounts(): Record<string, number>; /** * Clear all tools */ clear(): void; /** * Clear tools for a specific server */ clearServer(serverName: string): void; /** * Get lookup statistics */ getStats(): { totalTools: number; serverCount: number; uniqueNames: number; indexSize: { byName: number; byServer: number; byNamespaced: number; searchableText: number; }; }; /** * Create empty index structure */ private createEmptyIndex; /** * Generate unique key for a tool */ private getToolKey; /** * Update index when adding or removing a tool */ private updateIndex; /** * Extract keywords from a tool for searching */ private extractKeywords; /** * Calculate prefix match score */ private calculatePrefixScore; /** * Calculate keyword match score */ private calculateKeywordScore; /** * Calculate fuzzy match score using simple string similarity */ private calculateFuzzyScore; /** * Remove duplicate results based on tool key */ private deduplicateResults; } //# sourceMappingURL=lookup.d.ts.map