instrumentServer() when you’re building an MCP server and want to log every incoming tool call without client-side setup.
How it works
The function finds theCallTool / call_tool request handler in the server’s requestHandlers map and wraps it. Every tool invocation is timed, its inputs/outputs captured, and an event emitted with source: "mcp_server".
Setup
- TypeScript
- Python
instrumentServer API in the TypeScript API reference or Python API reference.