XBSTACK XBSTACK
Xiaobai

Xiaobai

Developer · Builder

Building AI engineering systems, developer tools and long-term digital assets at XBSTACK.

About Xiaobai & XBSTACK →
MCP Protocol Boundaries: How to Layer Client, Server, Tools, and Resources: MODEL CONTEXT PROTOCOL article cover

MCP Protocol Boundaries: How to Layer Client, Server, Tools, and Resources

MCP Protocol Boundaries: Break down the MCP protocol by the boundaries of Clients, Servers, Tools, Resources, Prompts, and transport layers.

Published · 2026-04-244 min readXBSTACK
#MCP#JSON-RPC#AI Agent#Developer Tools#Architecture Design

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

  1. 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.
  2. MCP Server (Protocol Relay): A lightweight process written by developers that encapsulates the actual logic and exposes a capability manifest.
  3. Tools & Resources (Underlying Limbs): Concrete code logic, including executable Tools (e.g., querying a database) and readable Resources (e.g., reading file streams).

3. Comparison: Stdio Transport Mode vs. SSE Transport Mode

DimensionStdio Mode (Standard I/O)SSE Mode (Server-Sent Events)
Connection CostVery low (launches local process directly)Moderate (requires running an HTTP server)
Communication LatencyMinimal (inter-process communication within the system)Depends on network quality
Concurrency CapabilitySuitable for single-user/single-sessionSupports multiple clients connected simultaneously
SecurityNetwork isolation (local only)Requires handling CORS and Token authentication
Use CasesPersonal configurations for Cursor, Claude DesktopEnterprise internal tool libraries, remote NAS mapping

Practical Pitfalls and Error Logs Guide

  1. Error: Stdio Stream Pollution
    • Cause: Your code contains print() or console.log(). These impurities disrupt JSON-RPC communication over Stdio.
    • Solution: All debug logs must be output via stderr (Python’s sys.stderr or TypeScript’s console.error).
  2. Error: Zombie Process Detected
    • Cause: After the client exits abnormally, the MCP Server process is not properly terminated.
    • Solution: Listen for the SIGTERM signal and implement “watchdog” logic. If there is no heartbeat for 5 minutes, execute process.exit(0).
  3. 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.

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.

Topic path / MCP

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.

More to Explore

Topic hub →
How to Configure MCP, Function Calling, and API Gateway: A Three-Layer Architecture for AI Agent Tool IntegrationMCP, Function Calling, and API Gateway solve different layers of AI tool integration: model tool selection, reusable tool/context protocol, and production access control.MCP vs. Semantic Kernel: Protocol, Agent Orchestration, and Enterprise Project SelectionMCP vs Semantic Kernel: compare protocol interoperability for tools/resources/prompts with an SDK for plugins, function calling, agents, and orchestration.MCP -32700 Parse Error: stdout Pollution, Tool List Failed, and Version ChecksFix MCP -32700 Parse Error by separating stdout/stderr, malformed JSON, startup failures, SDK v2 migration, and legacy 2025 versus stateless 2026-07-28 lifecycle issues.MCP OAuth Authentication in Practice: Why Remote MCP Servers Can't Go UnprotectedMCP OAuth Authentication in Practice: A practical guide to designing OAuth authentication and authorization for remote MCP servers, covering Protected Resource Metadata.

AI Engineering Weekly

Production changes, real failures, experiments and new XBSTACK assets.

Comments & evidence

DISCUSSION

Questions, verification and corrections

Sign in to comment. Every new comment is reviewed before publication; while pending, it is visible only to you and the administrator.

Sign-in required Reviewed before public
Loading the discussion…