/** * Analytics middleware for tool handlers * Automatically tracks tool executions with performance metrics */ import { ToolExecutionMetadata } from './types.js'; /** * Wrapper function that adds analytics tracking to tool handlers * Captures execution time, errors, and custom metadata * * @param toolName - Name of the MCP tool being executed * @param handler - The tool handler function to wrap * @param metadataExtractor - Optional function to extract metadata from handler result * @returns Wrapped handler with analytics tracking * * @example * ```typescript * export async function getForecastHandler(args: ForecastArgs) { * return withAnalytics('get_forecast', async () => { * // ... handler implementation * return result; * }, (result) => ({ * service: result.source, * cache_hit: result.cached, * })); * } * ``` */ export declare function withAnalytics(toolName: string, handler: () => Promise, metadataExtractor?: (result: T) => Partial): Promise; /** * Helper to create metadata extractor for common patterns */ export declare function createMetadataExtractor(extractor: (result: T) => Partial): (result: T) => Partial; //# sourceMappingURL=middleware.d.ts.map