Overview
MCPcat automatically tracks MCP protocol events like tool calls and session initialization. Custom events let you go further and track actions specific to your application: feature usage, billing milestones, or anything else that matters to your product. Custom events appear in the session timeline alongside automatic events, so you get the full picture of what happened during a session.Publishing Events
After callingmcpcat.track(), use publishCustomEvent to send events tied to the current session. Pass the tracked server instance as the first argument.
Using a Session ID
If you have a session ID instead of the server instance, you can pass it directly as a string. MCPcat will derive a stable session from it.Function Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
serverOrSessionId | Server | string | Yes | A tracked MCP server instance, or a session ID string |
projectId | string | Yes | Your MCPcat project ID (e.g. proj_abc123xyz) |
eventData | object | No | The event payload (see below) |
Event Data
| Field | Type | Description |
|---|---|---|
resourceName | string | A name for the event. Shows as the label in the dashboard timeline. If omitted, the event shows as “Custom”. |
parameters | object | Arbitrary data to attach to the event. Visible in the event detail panel. |
response | object | Response data to attach to the event. |
message | string | A human-readable description of what happened. |
duration | number | Duration of the event in milliseconds. |
isError | boolean | Set to true to mark this event as an error. |
error | object | Error details. Typically includes message and optionally type or code. |
eventData are optional. You can call publishCustomEvent with just the server and project ID to record a minimal custom event.
Examples
Tracking Feature Usage
Tracking Errors
Capture application-level errors that aren’t tied to a specific tool call.Tracking User Milestones
Viewing Custom Events
Custom events appear in the session replay timeline with a bolt icon, alongside automatic MCP events. TheresourceName is used as the label. Click on any custom event to see its full details, including parameters, response, and message.
If isError is set to true, the event is styled as an error in the timeline.