MCP Protocol Boundaries: How to Layer Client, Server, Tools, and Resources
This article documents my real-world experiments in the lab. I believe that building your own digital assets with AI is the ultimate moat for developers.
Quick Answer
- ✓ Break down the MCP protocol by the boundaries of Clients, Servers, Tools, Resources, Prompts, and transport layers. This helps developers build a foundational understanding of protocol layering before diving into SQLite implementation, file gateways, remote deployment, and OAuth security.
Who Should Read This
- ● Developers evaluating MCP / JSON-RPC / AI Agent / Developer Tools for production use.
- ● Indie builders who need a practical implementation path instead of another generic concept article.
- ● Readers comparing architecture trade-offs, risks, tooling boundaries and next actions.
Article Positioning: MCP Protocol Layers and Boundaries
This article is solely responsible for answering the protocol boundaries of MCP: what responsibilities Client, Server, Tools, Resources, Prompts, stdio, and remote transports each bear. For specific code walkthroughs, see MCP Server SQLite Private Data Mounting; for secure file gateways, see MCP File and Data Gateway in Action; for public network deployment, see MCP Streamable HTTP in Action.
Protocol Boundary Review Checklist
After reading this article, you should at least be able to distinguish:
- The Client is responsible for maintaining context and initiating protocol requests, and should not directly handle business permissions.
- The Server is responsible for exposing resource and tool manifests, and must enforce permission controls, timeouts, and logging governance.
- Resources lean toward read-only context, while Tools may produce side effects, meaning they carry different security levels.
- stdio is suitable for local single-user scenarios; remote team sharing should utilize HTTP transport and authentication layers.
- MCP is not a universal plugin marketplace; its true value lies in standardization, auditability, and governability.
The Key Point: MCP Defines the Protocol Boundary for AI Calling Local Tools
The value of MCP is not “allowing models to arbitrarily operate on the local machine,” but rather encapsulating local tools, files, databases, and remote services into a discoverable, permission-scoped, and auditable capability manifest. It is well-suited for private database mounting, internal enterprise toolchain integration, and automated code refactoring, but requires pre-designed permissions, logging, timeouts, and isolation boundaries.
- Suitable Scenarios: Local private database mounting, enterprise-grade internal toolchain integration, automated code refactoring workflows.
What This Guide Covers: Query Intent Locking
- What is MCP (Model Context Protocol) and why does it matter?
- How to build a production-grade TypeScript MCP Server from scratch?
- How to choose between Stdio mode and SSE mode in actual development?
- How to handle high-concurrency deadlocks and buffer overflows in MCP Servers?
- How to implement cross-region remote MCP connections via Cloudflare Tunnel?
Who This Guide Is For
- AI Application Developers: Looking to add powerful local extension capabilities to their applications.
- Full-Stack Engineers: Want to master the most mainstream AI plugin development standards of 2026.
- System Architects: Designing the underlying connection protocols for enterprise-grade AI agent platforms.
1. Xiaobai’s Note
There is always a thin layer of mist over Guiyang in the early mornings. Sitting in my “Local Development Environment” studio, I watched Cursor on my screen frantically conversing with my local database via the MCP (Model Context Protocol). I couldn’t help but sigh: In 2026, if you still don’t understand MCP, your collaboration efficiency with AI might still be stuck in the Stone Age. If Agents are the “command center” I build, then MCP is the “USB-C port” of this system. It not only unifies the communication protocol between AI and the external world but also thoroughly breaks down “local data silos.” Today, I will take a practical perspective to deconstruct this underlying protocol that is reshaping the AI ecosystem.
1. MCP: The Underlying Physical Standard for Breaking Data Silos in the AI Era
In the past, AI was like a genius locked in a glass room. If you wanted it to glance at your local financial spreadsheets, you had to manually copy and paste or write an extremely fragile, specific plugin. Now, with MCP, you simply install a standardized “drawer” on the glass room. When AI needs something, it directly requests it through the drawer (protocol request), and you place the data inside (protocol response).
MCP provides a JSON-RPC communication specification between AI models (such as Claude, GPT-4o) and external data sources, ensuring dynamic discovery of capabilities and persistent connections.
2. MCP Client, Server, Tools
- MCP Client (Brain Container): The protocol initiator, such as Cursor or Claude Desktop. It is responsible for maintaining context and deciding when to trigger calls.
- MCP Server (Protocol Relay): A lightweight process written by developers that encapsulates the actual logic and exposes a capability manifest.
- Tools & Resources (Underlying Limbs): Concrete code logic, including executable
Tools(e.g., querying a database) and readableResources(e.g., reading file streams).
3. Comparison: Stdio Transport Mode vs. SSE Transport Mode
| Dimension | Stdio Mode (Standard I/O) | SSE Mode (Server-Sent Events) |
|---|---|---|
| Connection Cost | Very low (launches local process directly) | Moderate (requires running an HTTP server) |
| Communication Latency | Minimal (inter-process communication within the system) | Depends on network quality |
| Concurrency Capability | Suitable for single-user/single-session | Supports multiple clients connected simultaneously |
| Security | Network isolation (local only) | Requires handling CORS and Token authentication |
| Use Cases | Personal configurations for Cursor, Claude Desktop | Enterprise internal tool libraries, remote NAS mapping |
Practical Pitfalls and Error Logs Guide
- Error:
Stdio Stream Pollution- Cause: Your code contains
print()orconsole.log(). These impurities disrupt JSON-RPC communication over Stdio. - Solution: All debug logs must be output via
stderr(Python’ssys.stderror TypeScript’sconsole.error).
- Cause: Your code contains
- Error:
Zombie Process Detected- Cause: After the client exits abnormally, the MCP Server process is not properly terminated.
- Solution: Listen for the
SIGTERMsignal and implement “watchdog” logic. If there is no heartbeat for 5 minutes, executeprocess.exit(0).
- Error:
JSON-RPC Buffer Overflow- Cause: Attempting to return multi-megabyte files via Resources, which overwhelms the Stdio buffer.
- Solution: Never return large files through MCP. Instead, extract summaries or use chunked retrieval (RAG).
7. Frequently Asked Questions
Q: Why can’t my Cursor recognize the newly added Tool?
A: Click the Refresh button in the Cursor MCP configuration interface. If it still fails, check whether your function has proper Docstrings. AI models rely heavily on comments to understand tool intent.
Q: How do I secure MCP connections to remote servers?
A: We recommend using Cloudflare Tunnel. Map your local MCP port to an HTTPS domain and configure authentication headers on the client side to achieve secure, controlled remote context injection.
Recommended In-Depth Reading
- 👉 MCP Server in Practice: A 5-Step Guide with Pitfall Avoidance for Enabling Claude to Access Local SQLite
- 👉 AI Agent Architecture: 5 Core Modules for Building Autonomous Agent Systems
- 👉 LangGraph in Action: 3 Design Patterns for Building Robust AI Agent Workflows
I’ve been diving deep into:
- The performance of the MCP protocol within large-scale distributed Agent clusters
- A unified workflow standard for cross-IDE environments (Cursor, Zed, VSCode) based on MCP
- A custom security gateway solution for MCP using Server-Sent Events (SSE)
If you encounter bizarre protocol errors while building an MCP Server, feel free to leave a comment so we can discuss.
-
MCP vs Function Calling: Why It’s the USB Interface of the AI Era
-
MCP Server in Action: Enabling Claude to Access Local SQLite
-
Q: How do I handle MCP Tool timeouts? A: I recommend breaking large tasks into subtasks or increasing the
timeoutparameter in your configuration file. -
Q: How can I ensure local database security? A: Use a read-only account and restrict physical path access via environment variables.
Continue from protocol details to production MCP governance
The MCP hub connects protocol fundamentals, transports, authentication, security, JSON-RPC debugging and production deployment without splitting the search intent across isolated guides.
Next Reading
View Hub →How to Configure MCP, Function Calling, and API Gateway: A Three-Layer Architecture for AI Agent Tool Integration
MCP, Function Calling, and API Gateway are not mutually exclusive. This article breaks down the three-layer division of labor in model invocation, protocol integration, permission governance, logging and auditing, rate limiting and isolation, and production deployment from the perspective of AI agent tool integration architecture.
OpenClaw Secure Sandbox Architecture: Building a Physically Isolated Agent Based on the MCP Protocol
A detailed breakdown of OpenClaw's core architecture, explaining how to use the MCP protocol and eBPF sandboxing to achieve read-write separation and zero-trust security auditing for agent execution environments.
MCP vs. Semantic Kernel: Protocol, Agent Orchestration, and Enterprise Project Selection
A direct comparison of MCP and Microsoft Semantic Kernel: MCP standardizes connections to tools, resources, and prompts, while Semantic Kernel organizes plugins, function calling, and agent orchestration within applications, along with guidance on combining both.
Gemini 3 and MCP Protocol in Practice: A Hands-On Guide to Building a Local AI Financial Audit System
A practical demonstration of refactoring a financial audit system using the MCP protocol, handling 2M+ token contexts, and enabling second-level audits and risk alerts for local private data.

Xiaobai
Full-Stack AI Engineer
Xiaobai, a full-stack AI engineer building production Agent systems, product tools and independent software assets.
About Xiaobai & XBSTACK →Liked this article?
Join the newsletter
Every issue condenses production AI engineering changes, real failures, reproducible experiments, useful tools and new XBSTACK assets. No generic news digest and no filler.