Repository navigation
Show and tell: Hardening Custom MCP Tool Backends Alongside Microsoft Learn MCP — Stdio Isolation & Read-Only SQL Guardrails #219
Ahmed (A7mdMe)
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Context: Multi-Server MCP Setups in Developer Workstations
In modern AI agent setups (Claude Desktop, Cursor, VS Code Extension for MCP), developers frequently run the official Microsoft Learn MCP Server alongside custom internal tools and database connectors in their
mcpServersconfiguration.When running multiple local MCP servers concurrently over standard input/output (stdio), two operational challenges frequently arise:
Stdio Stream Pollution Breaking Client Protocol Deserialization:
Desktop MCP clients require clean, unbroken JSON-RPC 2.0 message framing over
process.stdout. If custom TypeScript servers output internal logs or library traces viaconsole.log(),stdoutis corrupted, causing desktop clients to drop the connection or fail to enumerate tool lists across the workspace.Accidental Mutations from Agent SQL Generation:
When agents retrieve technical documentation, code snippets, or schema definitions and subsequently synthesize SQL queries for internal databases, prompt variations can lead to destructive mutations (
DROP TABLE,ALTER, multi-statement injections).Production Hardening Patterns
The open-source MCP Production Kit demonstrates two architectural patterns designed to maintain rock-solid workstation stability:
1. Dual-Stream Stdio Logging
Redirects all diagnostic, audit, and operational logging strictly to
process.stderr, reservingprocess.stdoutsolely for JSON-RPC 2.0 protocol frames:2. Application-Level Token & Regex SQL Inspection
Before an agent-generated SQL query reaches a persistent database pool, a token-based guardrail inspects the input:
--and/* */SQL comments commonly used to mask injection payloads.status = 'DROP_PENDING') don't trigger false alarms.SELECTorWITH, and validates against 16 mutation keywords (DROP,DELETE,TRUNCATE,ALTER,UPDATE,INSERT,CREATE,REPLACE, etc.).(Note: This application-level guardrail uses token & regex sanitization, not a full SQL AST compiler, and is engineered to work in tandem with database-level read-only permissions like
GRANT SELECT).Architecture Comparison: Open-Source Core vs. Pro Pack ($19 USD)
USER nodeMaintainer Disclosure & Community Discussion
Disclosure: I am the maintainer of MCP Production Kit and author of the commercial Pro Pack add-on on Whop.
We'd love feedback from the Microsoft MCP developer community:
All reactions