UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

100 lines 3.44 kB
/** * Observability callbacks manager for MCP-use. * * This module provides a centralized manager for handling observability callbacks * from various platforms (Langfuse, Laminar, etc.) in a clean and extensible way. */ import type { BaseCallbackHandler } from "@langchain/core/callbacks/base"; export interface ObservabilityConfig { /** Custom callbacks to use instead of defaults */ customCallbacks?: BaseCallbackHandler[]; /** Whether to enable verbose logging */ verbose?: boolean; /** Whether to enable observability (defaults to true) */ observe?: boolean; /** Agent ID for tagging traces */ agentId?: string; /** Metadata to add to traces */ metadata?: Record<string, any>; /** Function to get current metadata from agent */ metadataProvider?: () => Record<string, any>; /** Function to get current tags from agent */ tagsProvider?: () => string[]; } export declare class ObservabilityManager { private customCallbacks?; private availableHandlers; private handlerNames; private initialized; private verbose; private observe; private agentId?; private metadata?; private metadataProvider?; private tagsProvider?; constructor(config?: ObservabilityConfig); /** * Collect all available observability handlers from configured platforms. */ private collectAvailableHandlers; /** * Get the list of callbacks to use. * @returns List of callbacks - either custom callbacks if provided, or all available observability handlers. */ getCallbacks(): Promise<BaseCallbackHandler[]>; /** * Get the names of available handlers. * @returns List of handler names (e.g., ["Langfuse", "Laminar"]) */ getHandlerNames(): Promise<string[]>; /** * Check if any callbacks are available. * @returns True if callbacks are available, False otherwise. */ hasCallbacks(): Promise<boolean>; /** * Get the current observability status including metadata and tags. * @returns Object containing enabled status, callback count, handler names, metadata, and tags. */ getStatus(): Promise<{ enabled: boolean; callbackCount: number; handlerNames: string[]; metadata: Record<string, any>; tags: string[]; }>; /** * Add a callback to the custom callbacks list. * @param callback The callback to add. */ addCallback(callback: BaseCallbackHandler): void; /** * Clear all custom callbacks. */ clearCallbacks(): void; /** * Flush all pending traces to observability platforms. * Important for serverless environments and short-lived processes. */ flush(): Promise<void>; /** * Shutdown all handlers gracefully (for serverless environments). */ shutdown(): Promise<void>; /** * String representation of the ObservabilityManager. */ toString(): string; } /** * Get the default ObservabilityManager instance. * @returns The default ObservabilityManager instance (singleton). */ export declare function getDefaultManager(): ObservabilityManager; /** * Create a new ObservabilityManager instance. * @param config Configuration options * @returns A new ObservabilityManager instance. */ export declare function createManager(config?: ObservabilityConfig): ObservabilityManager; //# sourceMappingURL=manager.d.ts.map