Model Context Protocol (MCP) Stdio JSON-RPC Stream Isolation
Enforces absolute channel isolation for stdio MCP servers: stdout is strictly reserved for JSON-RPC message framing, while all diagnostic logs MUST be directed to stderr.
RFC-2119 Invariant Mandates
The keywords “MUST”, “MUST NOT”, and “SHOULD” in this document are to be interpreted as described in BCP 14 / RFC 2119.
MCP server processes communicating via StdioServerTransport MUST NOT emit any arbitrary strings or console.log outputs to process.stdout.
All diagnostic, telemetry, and debugging logs MUST be written exclusively to process.stderr or emitted via server.sendLoggingMessage().
Tool parameters MUST be declared using strict Zod schemas or typed Pydantic models with exhaustive descriptions.
Complete RFC Specification Document
# RFC-002: Model Context Protocol (MCP) Stdio Stream Isolation
## 1. Specification Mandate
The Model Context Protocol (MCP) allows AI agents to inspect databases, execute CLI tools, and query APIs. When operating over standard input/output (stdio), the communication channel requires rigorous stream purity.
## 2. Invariant Code Standard
```typescript
// CORRECT (Compliant with RFC-002):
process.stderr.write("[DEBUG] Fetching user records\n");
// FATAL ERROR (Violates RFC-002):
console.log("[DEBUG] Fetching user records"); // Corrupts stdio transport
```
Community Consensus Rating
Do these behavioral constraints represent the highest engineering standard for your team?