ZTDS FRAMEWORK MAPPINGS v1.0
MODEL CONTEXT PROTOCOL · STDIO · JSON-RPC

MCP Server Security: PII Sanitization on the stdio Transport

The Model Context Protocol uses JSON-RPC 2.0 messages. Its stdio transport has the client launch the server as a subprocess and exchange newline-delimited messages over standard input and output. That local boundary is a natural place to sanitize traffic before it reaches a model.

Summary

With stdio, the MCP client starts the server as a child process and writes JSON-RPC messages to its stdin while reading responses from its stdout. The server may write logs to stderr. Nothing other than valid MCP messages may be written to stdin or stdout.

A ZTDS gateway wraps that boundary. Tool results that flow back toward the model are tokenized before the client forwards them, and tool arguments that come back from the model are restored locally. The model sees surrogates; the local tools operate on real values.

Scope notice. This page maps a technical control to a published framework as a Statutory Risk Minimization and Defense-in-Depth measure. It is not legal advice, not a certification by the framework owner, and not a statement that any regulation is fully satisfied. Consult qualified counsel for jurisdiction-specific determinations.

Message Flow and Sanitization Points

FlowContentGateway action
Server to client (tool result)Records, file contents, and query results that may include PII or secrets.Tokenize before the result is placed into model context.
Client to server (tool call)Arguments chosen by the model, which may contain surrogates.Restore surrogates locally so the tool receives real values.
Server stderrDiagnostic logs.Excluded from model context; review logging separately.
Remote transportsStreamable HTTP servers run outside the local boundary.Out of this page scope; apply the same step in the client before forwarding.

How ZTDS Applies

Deployment pattern for a local agent client:

  • Configure the client to launch the gateway as the stdio command, with the original server as its child.
  • Keep the token map in the gateway process memory only (Invariant 3).
  • Verify no cleartext appears on any network interface using the perimeter scanner.
  • Document which tools are wrapped and which are not.

What This Control Does Not Cover

  • It does not defend against prompt injection embedded in tool output.
  • It does not constrain what an authorized tool is allowed to do. That is an authorization question.
  • Remote servers outside the local process boundary need the same sanitization in the client before forwarding.
  • The protocol details here follow the public MCP specification; verify against the version your client implements.

Frequently Asked Questions

How does the MCP stdio transport work?

The client launches the MCP server as a subprocess, writes newline-delimited JSON-RPC messages to its standard input, and reads responses from its standard output. The server can write diagnostic text to standard error.

Where should PII sanitization sit in an MCP setup?

At the local boundary between the tool output and the model context, so surrogates reach the model while tools keep working with real values.

Does stdio sanitization protect against malicious tool output?

No. It reduces personal data exposure. Injection and tool authorization risks need separate controls.