LogRocket MCP Replay
Records the requests your MCP server handles as LogRocket sessions so you can see how users' agents interact with your product: which tools they call and with what arguments, which resources and prompts they fetch, what they got back, and where errors happen.
Works with MCP servers built on the official mcp SDK, both 2.x (MCPServer, low-level Server) and 1.x (FastMCP, low-level Server), and on the standalone fastmcp package (2.x, 3.x, 4.x), over any transport (stdio, SSE, Streamable HTTP).
Installation
uv add logrocket-mcp-replay
# or: pip install logrocket-mcp-replay
Usage
import os
from logrocket_mcp_replay import instrument
server = build_my_mcp_server()
instrument(
server,
api_key=os.environ["LOGROCKET_INGEST_KEY"],
get_user=lambda ctx: {"id": ctx.request.headers["x-user-id"]} if ctx.request else None,
)
instrument records every request the server handles - tool calls, resource reads, prompt gets, listings, and any handler registered afterwards - and uploads batched request events to LogRocket from a background thread. Errors raised by handlers will be surfaced as LogRocket issues.
API key
Create an API key for your app in the LogRocket dashboard and pass it as api_key. The key both authenticates uploads and determines which LogRocket app sessions are recorded to. There is no separate appID to configure.
Short-lived processes
Events are buffered and flushed when the buffer fills, on a timer, and at interpreter exit. On platforms that freeze the process as soon as a response is sent (e.g., AWS Lambda), pass a recorder and flush it before returning:
from logrocket_mcp_replay import InstrumentOptions, RecorderOptions, create_recorder, instrument
recorder = create_recorder(RecorderOptions(api_key=os.environ["LOGROCKET_INGEST_KEY"]))
instrument(server, InstrumentOptions(api_key=os.environ["LOGROCKET_INGEST_KEY"], recorder=recorder))
def handler(event, context):
try:
return run_server(event)
finally:
recorder.shutdown()
Sessions and identity
LogRocket assigns requests to sessions server-side, emulating web visits: one person using one MCP client is one session, ended by 30 minutes of inactivity. Requests are grouped per client app (name and version) by the best available identity signal:
- The identified user, when
get_useris provided. - A SHA-256 hash of the bearer token, for OAuth-protected servers. The token itself is never sent.
- The client IP and user agent, for unauthenticated servers.
- A random per-process ID, for transports with no HTTP request (e.g., stdio), where one server process serves one user.
Provide get_user for the best results. It receives the SDK's per-request context (mcp.server.context.ServerRequestContext on mcp 2.x, mcp.shared.context.RequestContext on 1.x). On both, ctx.request is the Starlette Request on HTTP transports (None on stdio), so the user can be resolved from headers, the validated OAuth token (ctx.request.scope["user"].access_token), or whatever your auth middleware attached.
W3C trace context (traceparent/baggage in _meta) is captured on every request and shown with the request's headers in the replay, so requests can be correlated with your tracing backend. It is not used for session grouping.
Options
| Option | Description |
|---|---|
api_key (required) |
LogRocket API key; identifies the app recorded to (see above) |
server_url |
Ingest server origin override |
release |
Your server's release (e.g., version, git SHA) for release tracking |
get_user |
Resolve the LogRocket user from the request context |
capture_params |
Capture request params (default True) |
capture_results |
Capture request results (default True) |
capture_headers |
Capture HTTP request headers (default True) |
redact_headers |
Additional header names to redact |
max_value_length |
Max JSON-serialized length of captured values (default 100000) |
sanitize_event |
Transform or drop (return None) events before upload |
recorder |
Share one recorder across instrument() calls |
max_batch_size |
Flush when the buffer reaches this many events (default 25) |
flush_interval_ms |
Timer-based flush interval (default 5000) |
upload_timeout_ms |
Abort an ingest upload after this long (default 10000) |
on_error |
Callback for upload/serialization errors |
Options can be passed as keyword arguments to instrument() or as an InstrumentOptions instance.
Sanitization
HTTP request headers are captured so they appear alongside each request in the Network view. Credential-bearing headers (Authorization, Cookie, X-Api-Key, and similar) are always replaced with [REDACTED]. This can't be disabled. Use redact_headers to redact additional headers, or capture_headers=False to skip header capture entirely.
Params and results are truncated to max_value_length by default. To handle requests containing sensitive data, use sanitize_event to redact fields or drop events entirely:
def sanitize(event):
if event["method"] == "tools/call" and event.get("target") == "create_payment":
return {**event, "params": None}
return event
instrument(server, api_key=os.environ["LOGROCKET_INGEST_KEY"], sanitize_event=sanitize)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logrocket_mcp_replay-0.1.0.tar.gz.
File metadata
- Download URL: logrocket_mcp_replay-0.1.0.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc50482908ff8e7e391326eef048dbf806c9a5f6517c0f3fc84df7ba3dee921d
|
|
| MD5 |
a5bf174279b3d60d66bec056da5ebf74
|
|
| BLAKE2b-256 |
bb3bc1d5280dd40d4804476b364188f4a3a930abb1ed0f4d557047c0b13f6570
|
File details
Details for the file logrocket_mcp_replay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: logrocket_mcp_replay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9bfe2fe4fc3e0dfb0fabc70ed36336fddfe0a1e3c0eb216b11cd852eea1c7ad
|
|
| MD5 |
d5b2ec7b251f7cada3d5d495158f793e
|
|
| BLAKE2b-256 |
1b05f5525abb11eb704a9b82750718081c13a134815e2e3caf3d4bd77fb073e9
|