# Function withLogging

MCP exports - MCP server implementation Split from index.ts for file size compliance (Issue #285) Updated Issue #538: Added missing tool registration exports

- withLogging<TArgs, TResult>(
  toolName: string,
  handler: (args: TArgs) => Promise<TResult>,
  logger: ILogger,
  ): (args: TArgs) => Promise<TResult>

  Higher-order function that wraps a tool handler with logging.

  #### Type Parameters

  - TArgs

    Tool argument type

  - TResult

    Tool result type

  #### Parameters

  - toolName: string

    Name of the tool

  - handler: (args: TArgs) => Promise<TResult>

    The tool handler function

  - logger: ILogger

    The logger to use

  #### Returns (args: TArgs) => Promise<TResult>

  A wrapped handler with automatic logging

  #### Example

      const wrappedHandler = withLogging(
        'my_tool',
        async (args) => { ... },
        logger
      );

  - Defined in packages/nexus-agents/src/mcp/middleware/logging.ts:170