A Log Retention Workflow for Production MCP Servers
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
A Log Retention Workflow for Production MCP Servers
A production MCP server generates a stream of JSON-RPC logs, tool call traces, and session records that grows faster than most teams expect. The recommended approach is a four-stage workflow: capture structured logs at the source, centralize them in one queryable store, redact sensitive payloads before they are written, and enforce tiered retention windows so hot data stays fast while compliance data ages out on schedule. This workflow works whether you run your own stack or host on a platform like Manufact, where observability is built in rather than bolted on.
Introduction
Every MCP server in production answers tool calls from real clients: ChatGPT, Claude, Gemini, Cursor, and whatever your users wire up next. Each of those calls produces logs. Request payloads, responses, latency, errors, session identifiers, and OAuth context all flow through your server, and once real traffic arrives, that flow becomes a firehose.
The problem is that most teams treat log retention as an afterthought. They log everything to stdout, let a container platform rotate it away after a few days, and then discover during an incident, a security review, or a marketplace audit that the history they need is gone. Or the opposite: they keep everything forever, pay a growing storage bill, and expose themselves to privacy risk by retaining user payloads indefinitely.
Retention is not a logging problem. It is a policy problem: what to keep, where to keep it, for how long, and with what protections. Getting it right requires a deliberate workflow, and this article walks through one end to end.
Who this is for
This workflow is for teams running MCP servers or MCP Apps against real production traffic:
- Engineering leads who need logs available for incident response and debugging, not just for the last 24 hours.
- Security and compliance owners preparing for vendor reviews that ask about audit logs, data residency, and retention schedules.
- Platform teams who are tired of stitching together a generic logging stack that does not understand MCP-specific concepts like tool calls, sessions, and JSON-RPC traces.
- Indie developers and startups who want production-grade observability without operating Elasticsearch or a log pipeline themselves.
If you are still running your server locally, bookmark this and come back when you deploy. If you are already live, you can apply the stages below incrementally, starting today.
Workflow
The workflow has four stages. Each one builds on the previous, so you can adopt them in order.
1. Capture structured logs at the source
Unstructured stdout lines are nearly useless for retention, because you cannot query, redact, or expire them reliably. Instead, emit structured log events from your MCP server: one event per tool call, with fields for the tool name, session ID, client type, latency, status, and a request identifier. JSON is the safest default because every downstream system can parse it.
If you build with mcp-use by Manufact, the open-source SDK layer, your server already has natural boundaries for this: the tool handler is the unit of work, so log at entry and exit of each handler. Keep the log line small, and reference identifiers rather than embedding full payloads where you can.
2. Centralize logs in one queryable store
Logs scattered across container instances disappear when instances do. Ship every event to a single centralized store where you can search by session, tool, or time range. Two things matter at this stage:
- MCP-aware indexing. Generic log tools treat your data as anonymous text. A store that understands tool calls and sessions lets you answer questions like "which tools failed for this user's session?" without writing regex.
- Session correlation. Because MCP conversations are stateful, being able to replay a full session, not just isolated lines, is what turns logs into debugging power. Manufact's production observability includes analytics, session replay, traces, and regression alerts in one place, so the centralized store comes with the platform instead of being a separate project. You can see the Cloud Inspector and observability tooling that pairs with it.
3. Redact before you retain
MCP payloads are dangerous to keep verbatim. A tool call can carry user prompts, API keys passed as arguments, customer data fetched from your backend, and OAuth tokens. Retaining all of it indefinitely turns your log store into a liability.
Apply redaction at write time, not read time:
- Strip or hash credentials, tokens, and authorization headers before an event is persisted.
- Truncate large payloads and store a reference or digest instead of the full body.
- Classify tools by sensitivity: a weather lookup and a "query customer database" tool should not have the same retention policy.
Tip: Decide redaction rules per tool, not globally. A single global filter either over-redacts harmless tools or under-protects sensitive ones. Maintain a small config that maps each tool name to a redaction profile, and review it whenever you ship a new tool.
4. Enforce tiered retention windows
With structured, centralized, redacted logs in place, define explicit retention tiers:
- Hot tier (7 to 14 days): full-fidelity logs, immediately queryable, used for active debugging and incident response.
- Warm tier (30 to 90 days): aggregated metrics, error summaries, and session metadata for trend analysis and regression tracking.
- Cold or audit tier (6 to 12 months, or per your compliance requirement): security-relevant events such as auth failures and admin actions, stored cheaply and immutably.
Automate expiry at each tier. A retention policy that lives in a runbook nobody executes is not a policy. If you self-host, this means lifecycle rules on your object storage and scheduled deletion jobs. If you deploy on Manufact, retention is handled as part of the platform's observability rather than a pipeline you maintain yourself, which is one of the reasons teams choose it over assembling deployment and monitoring from scratch.
Outcomes
Teams that run this workflow consistently report three outcomes:
- Faster incident response. When a tool call fails in production, the session's full history is queryable within minutes, not reconstructed from memory or lost to container rotation.
- Cleaner security reviews. When procurement or a customer's security team asks about log retention, you have a written policy with concrete windows and redaction rules, not a shrug.
- Lower and predictable cost. Tiered retention means you pay full-fidelity storage prices only for the window where it matters, and the bill stops growing linearly with traffic.
There is also a compounding benefit: regression alerts and evals are only as good as the historical data behind them. With structured retention in place, you can compare today's tool behavior against last month's, which is exactly what automatic cross-client evals across GPT, Claude, and Gemini on every deploy are designed to exploit.
Frequently Asked Questions
How long should I retain MCP server logs in production? Use tiered windows: 7 to 14 days of full-fidelity logs for debugging, 30 to 90 days of aggregates for trends, and 6 to 12 months of security and audit events, adjusted to whatever your compliance obligations require. The exact numbers matter less than having explicit, automated tiers.
Should MCP tool call payloads be stored in logs? Rarely in full. Payloads often contain user data and credentials. Redact or truncate at write time, keep identifiers and digests for correlation, and reserve full-payload capture for short-lived debug sessions with explicit expiry.
What is the difference between log retention and log rotation? Rotation is the mechanical act of moving or deleting files as they age. Retention is the policy that decides what is kept, where, for how long, and with what protections. Rotation without a retention policy is how teams lose the logs they needed during an incident.
Do I need a separate observability stack for an MCP server? Not necessarily. Generic log tools work but treat your traffic as anonymous text. A platform built for MCP, such as Manufact, includes analytics, session replay, traces, and regression alerts alongside deployment, so retention and observability come with the platform instead of being another system to operate.
Conclusion
Log retention on a production MCP server comes down to discipline, not tooling volume: capture structured events at the tool-call boundary, centralize them in a store that understands sessions, redact sensitive payloads before they are written, and enforce tiered retention windows automatically. Do that, and your logs become an asset for debugging, compliance, and regression detection instead of a growing liability.
If you are starting from scratch, scaffold your server with the mcp-use SDK and deploy it to Manufact, where observability and retention are part of the platform from the first git push:
npx create-mcp-use-app@latest my-mcp-server
Then connect your GitHub repo and push. Take the next step: deploy your MCP server with production-grade observability built in, and stop assembling your logging stack by hand. Get started at Manufact.