DEV Community

Cover image for The USB-C Port for AI: Demystifying Model Context Protocol (MCP)
Uzair ul Hassan
Uzair ul Hassan

Posted on

The USB-C Port for AI: Demystifying Model Context Protocol (MCP)

Model Context Protocol (MCP) is an open standard, originally introduced by Anthropic in November 2024, that gives AI host applications a consistent way to connect with external tools, databases, and local files[cite: 8]. Much like a USB-C port or the Language Server Protocol, it uses bidirectional JSON-RPC 2.0 messages over stdio or HTTP/SSE transports so one server can work across desktop apps, editors, and terminal agents[cite: 8]. Keep in mind that MCP standardizes communication and capability discovery, not model inference itself, centralized authentication out of the box, or protection against hallucinated tool calls[cite: 8].

Why This Matters

Inferred audience assumption: This guide is written for software developers, AI engineers, DevOps specialists, technical product managers, open-source contributors, and technology leaders connecting large language models to external systems, local files, databases, or CLI tools[cite: 8]. Based on the dossier, it assumes intermediate software development familiarity, basic comfort with REST or GraphQL APIs and command-line tools, and practical experience using AI assistants, without requiring prior protocol specification expertise[cite: 8].

Wiring every AI client to every external system by hand creates a tangle of custom glue code[cite: 8]. After reading this guide, you can explain MCP's host, client, and server architecture, build and wire up a basic MCP server across desktop and CLI environments, and spot key security and scaling trade-offs before shipping[cite: 8].

Escaping the Custom Glue Code Trap

Think about a developer maintaining connectors between three AI interfaces (a desktop chat app, an IDE assistant, and a terminal agent) and four data sources (a Postgres database, GitHub, a local workspace, and an internal API). Without a shared protocol, every combination demands custom adapter logic, inconsistent schemas, and separate maintenance lifecycles[cite: 8].

Definition: Model Context Protocol (MCP)
An open client-server protocol built on JSON-RPC 2.0 that standardizes how AI host applications discover and use external data sources, tools, and workflow prompts[cite: 8].

Instead of building custom integrations for every pair, MCP lets teams expose a capability once on an MCP server and reuse it across compatible clients[cite: 8]. Rather than multiplying custom connectors across every app and data source, an open protocol turns integration into a shared, reusable layer[cite: 8].

Core Architecture and Primitives

MCP separates responsibilities across a clear client-server topology using stateful JSON-RPC 2.0 messages[cite: 8].

Hosts, Clients, and Servers

  • MCP Host: The user-facing AI application (such as Claude Desktop, VS Code, Cursor, a CLI agent, or a custom web client) that manages connections and user approvals[cite: 8].
  • MCP Client: The connector layer inside the host that negotiates capabilities, discovers server offerings, and routes requests between the model and servers[cite: 8].
  • MCP Server: A local script or remote service that exposes context and capabilities to connected clients[cite: 8].

Server Primitives and Client Features

Servers expose three core primitives[cite: 8]:

  • Tools: Executable functions with structured input schemas that an AI model can invoke to take actions or query systems[cite: 8].
  • Resources: Data or files identified by URIs (such as schemas, logs, or documents) that provide context[cite: 8].
  • Prompts: Reusable prompt templates and workflow instructions offered to users or clients[cite: 8].

Clients can also support server-initiated capabilities such as Sampling (asking the host's LLM for a completion), Elicitation (requesting input from the user), and Notifications for live updates[cite: 8].

┌────────────────────────────────────────────────────────────────────────┐
│                              MCP HOST                                  │
│  (Claude Desktop / Cursor / VS Code / Claude Code CLI / Custom Web App)│
│                                                                        │
│   ┌───────────────────┐               ┌───────────────────────────┐    │
│   │   LLM Engine      │               │   MCP Client Controller   │    │
│   │ (Claude / GPT-4o) │ ◄───────────► │ (Auto-discovers tools &   │    │
│   └───────────────────┘               │  prompts user approvals)  │    │
│                                       └─────────────┬─────────────┘    │
└─────────────────────────────────────────────────────┼──────────────────┘
                                                      │
                       JSON-RPC 2.0 Over              │
                     stdio OR HTTP / SSE              ▼
┌────────────────────────────────────────────────────────────────────────┐
│                             MCP SERVER                                 │
│                   (Local Script or Remote Microservice)                │
│                                                                        │
│   ┌─────────────────────┐  ┌────────────────────┐  ┌───────────────┐   │
│   │        TOOLS        │  │     RESOURCES      │  │    PROMPTS    │   │
│   │ (SQL Queries, Git,  │  │ (Files, Schemas,   │  │ (Task         │   │
│   │  API Execution)     │  │  Log Streams)      │  │  Templates)   │   │
│   └──────────┬──────────┘  └─────────┬──────────┘  └───────┬───────┘   │
└──────────────┼───────────────────────┼─────────────────────┼───────────┘
               ▼                       ▼                     ▼
┌────────────────────────────────────────────────────────────────────────┐
│                        EXTERNAL INFRASTRUCTURE                         │
│     (PostgreSQL Database / GitHub API / Local File System / Slack)     │
└────────────────────────────────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode

Four-Step Developer Implementation Workflow

Follow this sequence to build a server, connect it to a host, and verify message flow before relying on it in daily work.

┌────────────────────────────────────────────────────────┐
│ Step 1: Design the MCP Server & Select Transport       │
│ • Local tools/files -> stdio transport                 │
│ • Cloud services/multi-tenant -> HTTP with SSE transport│
└──────────────────────────┬─────────────────────────────┘
                           │
                           ▼
┌────────────────────────────────────────────────────────┐
│ Step 2: Implement Core Primitives (TypeScript/Python)   │
│ • Define Tools (functions with JSON schema parameters) │
│ • Define Resources (URI data sources)                  │
│ • Log debug traces to stderr (keep stdout clean)       │
└──────────────────────────┬─────────────────────────────┘
                           │
                           ▼
┌────────────────────────────────────────────────────────┐
│ Step 3: Configure Host Applications (Desktop & CLI)     │
│ • Add server entry to claude_desktop_config.json        │
│ • Configure VS Code / Cursor / Claude Code CLI settings│
└──────────────────────────┬─────────────────────────────┘
                           │
                           ▼
┌────────────────────────────────────────────────────────┐
│ Step 4: Validate with MCP Inspector & Grant Permissions│
│ • Run npx @modelcontextprotocol/inspector              │
│ • Test tool calls and verify interactive approvals     │
└────────────────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode

1. Choose Scope and Transport

Pick stdio when the host launches a local process on the same machine, or HTTP with SSE (streamable HTTP/SSE) when connecting to a remote or shared service.

  • What success looks like: Your transport matches where the server runs and how credentials or network access are managed.

2. Implement Tools and Resources Safely

Use the official TypeScript (@modelcontextprotocol/sdk) or Python (mcp) SDK to define typed tool parameters and resource handlers.

  • Common mistake: Writing log or debug messages to stdout on a stdio server breaks JSON-RPC stream parsing. Always write logs to stderr (such as console.error()).

  • What success looks like: Tools validate inputs cleanly, stdout carries only valid protocol messages, and diagnostics appear on stderr.

3. Register the Server in GUI and CLI Hosts

Add your server configuration to desktop or editor settings (such as claude_desktop_config.json) or register it via CLI commands (such as claude mcp add my-db-tool node /path/to/server/build/index.js).

{
  "mcpServers": {
    "my-db-tool": {
      "command": "node",
      "args": ["/path/to/server/build/index.js"],
      "env": { "DB_URL": "postgresql://localhost:5432/mydb" }
    }
  }
}

Enter fullscreen mode Exit fullscreen mode
  • What success looks like: The host starts the server and lists its tools and resources without configuration errors.

4. Inspect Schemas and Approval Prompts

Run the MCP Inspector (npx @modelcontextprotocol/inspector node build/index.js) to examine JSON-RPC requests and responses interactively, then verify tool calls in your target host.

  • What success looks like: Input schemas, tool outputs, and human-in-the-loop approval prompts behave as expected.

Ecosystem Adoption and Practical Scenarios

Since Anthropic introduced MCP in November 2024, adoption has expanded across desktop apps, editors, CLI agents, and model setups. Compatible clients include Claude Desktop, Cursor, VS Code, Claude Code, and Goose CLI, alongside adapters for models such as ChatGPT/GPT-4o, DeepSeek, Gemini, and local runtimes like Ollama or vLLM.

Integration Layer Examples in Research Primary Role
Desktop & IDE Hosts Claude Desktop, Cursor, VS Code Interactive chat, code editing, and tool approvals

|
| CLI & Local Runtimes | Claude Code, Goose CLI, Ollama, vLLM | Terminal workflows and local model execution

|
| Backends & Data Sources | PostgreSQL, GitHub, Slack, filesystems | Live data reads, queries, and external actions

|

Consider two real-world scenarios:

  • Local debugging with database context: A developer connects a Postgres MCP server to Claude Desktop to inspect schemas as resources and query orders and logs via tools when troubleshooting a failed order.

  • Agentic coding in the terminal: A developer uses Claude Code CLI with a GitHub MCP server to inspect issues, update code on a branch, run tests, and open a pull request.

Two common misconceptions are worth clearing up:

  • MCP is not locked to Anthropic models or Claude Desktop; it is an open standard usable with other models, IDEs, and CLI tools.

  • MCP does not replace REST or GraphQL APIs; it wraps existing APIs and systems in a standard discovery and invocation interface for AI clients.

Security, Context Limits, and Protocol Trade-Offs

Adding tool execution and data access introduces real operational trade-offs that teams need to manage deliberately:

  • Local execution risk: A stdio server runs code on the host machine, so untrusted or unvetted servers can pose serious risks if users grant broad permissions without checking what tools expose.

  • Context window overhead: Exposing many servers with large tool schemas inflates context usage and can add latency across turns.

  • Evolving authentication boundaries: Local stdio setups often pass secrets via environment variables, while remote HTTP/SSE deployments continue expanding OAuth 2.1 support rather than solving every enterprise auth requirement out of the box.

Sources

Top comments (0)