/** * Structured logging service for MCP protocol * * Provides dual output: MCP notifications (visible to AI clients) + stderr (visible to developers). * Log level filtering for MCP notifications is handled by the SDK (logging/setLevel). * * LoggingService is a class that holds the MCP server reference as instance state, * avoiding module-level mutable singletons that are incompatible with * Cloudflare Workers (where module scope persists across requests). */ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { Logger, WriteStderrFn } from './interfaces/index.js'; export type { Logger, WriteStderrFn }; /** * Logging service that holds MCP server reference as instance state. * * Each server instance should create its own LoggingService, so that * multiple servers running in the same isolate don't share state. * * @param writeStderr - Optional writer function for stderr-style output. * Defaults to `console.error`. Pass `console.log` or a no-op for * platforms without stderr (e.g. Cloudflare Workers). */ export declare class LoggingService { private mcpServer; private readonly writeStderr; constructor(writeStderr?: WriteStderrFn); /** * Register the MCP server instance for sending log notifications. * Must be called after server creation but before tools are invoked. */ setServer(server: McpServer): void; /** * Create a named logger instance. * * @param name - Logger name identifying the source module */ createLogger(name: string): Logger; private log; private sendMcpLog; } /** * Create a stderr-only logger (no MCP notifications). * * Use this for bootstrap / transport code that runs before * a ServerContext is available, or outside of a request scope. * * @param name - Logger name identifying the source module * @param writeStderr - Optional writer function (defaults to console.error) */ export declare function createStderrLogger(name: string, writeStderr?: WriteStderrFn): Logger; //# sourceMappingURL=logging.d.ts.map