Skip to main content

init

Initializes mcp-tap and patches all detected SDKs. Must be called before any AI SDK calls.

instrumentServer

Instruments an MCP Server object to capture all incoming tools/call requests.

session

Scoped session context. All events emitted inside fn are tagged with the given session name.
If called with only a function (no name), a random session ID is generated:

Emitter

Buffers events and sends them in batches. Created automatically by init() — you rarely need to use this directly.

makeEvent

Creates a TapEvent object with sensible defaults.

generateEventId

Returns a unique event ID in the format evt_<16 hex chars>.

generateSessionId

Returns a unique session ID in the format ses_<16 hex chars>.

Receipt utilities

Individual patch functions

Each patch can be applied independently if you don’t want init() to patch everything: