@vfarcic/dot-ai
Version:
AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance
40 lines • 1.5 kB
TypeScript
/**
* Tool Execution Tracing for MCP Tools
*
* Provides generic tracing wrapper for all MCP tool executions,
* creating INTERNAL spans with GenAI semantic conventions.
*
* Supports both STDIO (MCP) and HTTP (REST) transports transparently.
*/
import { McpClientInfo } from '../telemetry';
/**
* Options for tool tracing
*/
export interface ToolTracingOptions {
/** MCP client info for telemetry attribution */
mcpClient?: McpClientInfo;
}
/**
* Wraps a tool handler with OpenTelemetry tracing
*
* Creates an INTERNAL span for tool execution with:
* - Tool name and input arguments
* - Execution duration and success status
* - Exception tracking for errors
* - GenAI semantic conventions (gen_ai.tool.*)
*
* @param toolName - Name of the MCP tool being executed
* @param args - Tool input arguments (will be serialized to JSON)
* @param handler - Async function that implements the tool logic
* @param options - Optional tracing options (e.g., MCP client info)
* @returns Promise resolving to the tool handler result
*
* @example
* ```typescript
* const result = await withToolTracing('recommend', { intent: 'deploy postgres' }, async (args) => {
* return await handleRecommendTool(args);
* }, { mcpClient: { name: 'claude-code', version: '1.0.0' } });
* ```
*/
export declare function withToolTracing<T, A = unknown>(toolName: string, args: A, handler: (args: A) => Promise<T>, options?: ToolTracingOptions): Promise<T>;
//# sourceMappingURL=tool-tracing.d.ts.map