@toolprint/hypertool-mcp
Version:
HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers
140 lines • 4.05 kB
TypeScript
/**
* Tool discovery service implementation
*/
import { EventEmitter } from "events";
import { IConnectionManager } from "../connection/types.js";
import { IToolDiscoveryEngine, DiscoveryConfig, DiscoveredTool, ServerToolState, ToolLookupOptions, DiscoveryStats } from "./types.js";
import { SearchResult } from "./lookup.js";
/**
* Tool discovery engine implementation
*/
export declare class ToolDiscoveryEngine extends EventEmitter implements IToolDiscoveryEngine {
private connectionManager;
private config;
private cache;
private lookupManager;
private hashManager;
private isInitialized;
private isStarted;
private refreshTimer?;
private serverStates;
private discoveryStats;
constructor(connectionManager: IConnectionManager);
/**
* Initialize the discovery engine
*/
initialize(config?: DiscoveryConfig): Promise<void>;
/**
* Discover tools from a specific server or all connected servers
*/
discoverTools(serverName?: string): Promise<DiscoveredTool[]>;
/**
* Discover tools from a specific server
*/
private discoverServerTools;
/**
* Get a tool by its name or namespaced name
*/
getToolByName(name: string): Promise<DiscoveredTool | null>;
/**
* Output tool server status
*/
outputToolServerStatus(): Promise<void>;
/**
* Search for tools matching criteria
*/
searchTools(options: ToolLookupOptions): Promise<DiscoveredTool[]>;
/**
* Advanced search with relevance scoring
*/
searchToolsWithScoring(options: ToolLookupOptions & {
keywords?: string[];
}): SearchResult[];
/**
* Get all available tools
*/
getAvailableTools(connectedOnly?: boolean): DiscoveredTool[];
/**
* Refresh tool cache for a specific server or all servers
*/
refreshCache(serverName?: string): Promise<void>;
/**
* Get discovery statistics
*/
getStats(): DiscoveryStats;
/**
* Get server tool states
*/
getServerStates(): ServerToolState[];
/**
* Clear cache for a specific server or all servers
*/
clearCache(serverName?: string): Promise<void>;
/**
* Start automatic discovery and refresh
*/
start(): Promise<void>;
/**
* Stop automatic discovery and refresh
*/
stop(): Promise<void>;
/**
* Create namespaced tool name
*/
private createNamespacedName;
/**
* Update server state
*/
private updateServerState;
/**
* Handle MCP tools list changed notification
*/
handleToolsListChanged(serverName: string): Promise<void>;
/**
* Get tools for a specific server
*/
getToolsByServer(serverName: string): DiscoveredTool[];
/**
* Setup connection manager event handlers
*/
private setupConnectionEvents;
/**
* Setup MCP notification handlers for tool changes
*/
private setupMCPNotificationHandlers;
/**
* Initialize discovery statistics
*/
private initializeStats;
/**
* Update discovery statistics
*/
private updateDiscoveryStats;
/**
* Resolve a tool reference and return tool + server metadata
* Uses optimized lookup maps and strict validation by default
*
* @param ref Tool reference with namespacedName and/or refId
* @param options.allowStaleRefs If true, allows mismatched tools to continue (INSECURE)
*/
resolveToolReference(ref: {
namespacedName?: string;
refId?: string;
}, options?: {
allowStaleRefs?: boolean;
}): {
exists: boolean;
tool?: DiscoveredTool;
serverName?: string;
serverStatus?: import("../connection/types.js").ConnectionStatus;
namespacedNameMatch: boolean;
refIdMatch: boolean;
warnings: string[];
errors: string[];
};
/**
* Ensure the engine is initialized
*/
private ensureInitialized;
}
//# sourceMappingURL=service.d.ts.map