Skip to content

Model Context Protocol (MCP): A Field Guide for Engineering Teams

Model Context Protocol (MCP) is an open standard for connecting AI agents to tools and data. Learn the architecture, primitives, security model, and rollout plan.

TechnoKeen Engineering 9 min read Published
On this page

The Model Context Protocol (MCP) is an open standard that defines how an AI application discovers and calls external tools, reads data, and uses reusable prompts. In practice, it replaces a pile of one-off integrations with a single client-server contract. That means a tool you build once can be used by any MCP-compatible agent, IDE, or desktop assistant. This guide covers how the protocol actually works, what to build first, and where teams get burned.

Key takeaways

  • MCP is a client-server protocol built on JSON-RPC 2.0. Servers expose tools, resources, and prompts; clients can offer sampling, roots, and elicitation back to servers.
  • It standardizes the plumbing of tool integration, not the quality of your tools. Bad tool design over MCP is still bad tool design.
  • Use stdio transport for local, single-user servers and Streamable HTTP for shared, remote servers. Remote servers need real authentication and authorization.
  • Treat every MCP server as untrusted code with access to your data. Tool descriptions and tool outputs are both prompt injection surfaces.
  • Start with one internal server that wraps a high-value system, put it behind a gateway, and measure tool-call quality before scaling to dozens.

What problem MCP solves

Before MCP, every agent framework and every AI product had its own tool format. If you wanted your ticketing system available in a coding assistant, a chat assistant, and a custom support agent, you wrote three integrations. Each had its own schema conventions, auth handling, and error semantics.

MCP turns that M-by-N problem into M-plus-N. Each host application implements the client side once. Each system of record gets wrapped in a server once. The two sides meet at a shared protocol.

The comparison people often reach for is the Language Server Protocol, which did the same thing for editors and programming languages. The analogy holds well: LSP did not make language tooling good, it made good tooling portable. MCP does the same for agent tools.

The official specification and SDKs live at modelcontextprotocol.io. The spec is versioned by date, and it has evolved meaningfully, so pin the revision you build against and read its changelog when you upgrade.

How the architecture fits together

MCP has three roles. Getting them straight saves a lot of confusion in design reviews.

+-------------------------------------------+
|  Host (IDE, chat app, your agent runtime) |
|                                           |
|   +-----------+        +-----------+      |
|   | MCP client|        | MCP client|      |
|   +-----+-----+        +-----+-----+      |
+---------|--------------------|------------+
          | stdio              | Streamable HTTP
          v                    v
   +-------------+      +----------------+
   | MCP server  |      |  MCP server    |
   | (local git) |      | (remote CRM)   |
   +-------------+      +----------------+
  • Host: the application the user interacts with. It owns the model, the conversation, and the security policy.
  • Client: a connector inside the host. Each client holds a one-to-one, stateful session with a single server.
  • Server: a program that exposes capabilities. It can be a local process or a remote service.

Sessions begin with an initialization handshake where both sides declare their protocol version and capabilities. After that, messages are ordinary JSON-RPC requests, responses, and notifications. A server that supports dynamic tool lists, for example, can notify the client when its tools change.

Server primitives

Servers can expose three kinds of things, and the distinction is about who controls them.

Primitive Controlled by Typical use Example
Tools The model Actions and queries the model decides to invoke create_ticket, search_orders
Resources The application Read-only context the host chooses to attach A file, a schema, a runbook
Prompts The user Templated workflows the user selects “Summarize this incident”

Teams new to MCP tend to model everything as a tool. That works, but it pushes every context decision onto the model. If a piece of data should always be in context for a given workflow, a resource the host attaches deterministically is often more reliable than hoping the model calls a get_schema tool.

Client primitives

The protocol also runs the other direction. A server can ask the client for help:

  • Sampling lets a server request a model completion through the host, so the server can do LLM work without holding its own API keys. The host stays in control and can require user approval.
  • Roots tell a server which filesystem locations or URIs it is allowed to operate within.
  • Elicitation lets a server ask the user for structured input mid-operation, such as confirming a destructive action or supplying a missing parameter.

These are optional capabilities. Check what your target hosts support before you design a server that depends on them.

Transports

MCP defines two standard transports:

  • stdio: the host launches the server as a subprocess and exchanges messages over standard input and output. Simple, fast, and scoped to one user on one machine.
  • Streamable HTTP: the server runs as an independent HTTP service. Clients POST JSON-RPC messages, and the server can respond with a single JSON body or stream messages back using server-sent events. This replaced an earlier HTTP-plus-SSE transport.

For remote servers, the spec defines an authorization model based on OAuth 2.1. If you are exposing a server beyond localhost, plan for this from day one rather than bolting on a static API key.

Building a server: a realistic example

Here is a small server using the official Python SDK’s FastMCP interface. It wraps a hypothetical internal orders API with one read tool, one write tool, and a resource.

# orders_server.py
import os
from typing import Literal

import httpx
from mcp.server.fastmcp import FastMCP

ORDERS_API = os.environ["ORDERS_API_URL"]
API_TOKEN = os.environ["ORDERS_API_TOKEN"]

mcp = FastMCP("orders")


def _client() -> httpx.AsyncClient:
    return httpx.AsyncClient(
        base_url=ORDERS_API,
        headers={"Authorization": f"Bearer {API_TOKEN}"},
        timeout=10.0,
    )


@mcp.tool()
async def search_orders(
    customer_email: str,
    status: Literal["open", "shipped", "cancelled", "any"] = "any",
    limit: int = 10,
) -> str:
    """Find a customer's orders by email address.

    Use this before any order-specific action. Returns at most `limit`
    orders (max 25), newest first, as one line per order:
    order_id | created_at | status | total.
    """
    limit = max(1, min(limit, 25))
    params = {"email": customer_email, "limit": limit}
    if status != "any":
        params["status"] = status

    async with _client() as client:
        resp = await client.get("/orders", params=params)

    if resp.status_code == 404:
        return f"No customer found with email {customer_email}."
    resp.raise_for_status()

    orders = resp.json()["orders"]
    if not orders:
        return f"Customer {customer_email} has no {status} orders."
    return "\n".join(
        f"{o['id']} | {o['created_at']} | {o['status']} | {o['total']}"
        for o in orders
    )


@mcp.tool()
async def cancel_order(order_id: str, reason: str) -> str:
    """Cancel an open order. Only works if status is 'open'.

    This is irreversible. Confirm the order_id with search_orders first.
    `reason` is stored on the order and shown to the customer.
    """
    async with _client() as client:
        resp = await client.post(
            f"/orders/{order_id}/cancel", json={"reason": reason}
        )

    if resp.status_code == 409:
        return (
            f"Order {order_id} cannot be cancelled because it is no longer "
            "open. Check its status with search_orders."
        )
    resp.raise_for_status()
    return f"Order {order_id} cancelled."


@mcp.resource("orders://policies/cancellation")
def cancellation_policy() -> str:
    """The current customer-facing cancellation policy."""
    with open("policies/cancellation.md", encoding="utf-8") as f:
        return f.read()


if __name__ == "__main__":
    mcp.run()  # stdio by default

A few details in this example matter more than the protocol itself:

  • Docstrings are the tool description. The SDK sends them to the model. They say when to use the tool, what it returns, and what the limits are.
  • Type hints become the input schema. The Literal type gives the model an enum instead of a free-text field it can get wrong.
  • Expected failures return useful text. A 409 is not an exception the agent should crash on. It is information the model can act on.
  • Output is compact. One line per order, not the raw JSON payload with forty fields the model doesn’t need.

For more on this, see our guide to tool design for AI agents. Everything in it applies directly to MCP tools.

Calling it from a client

If you are building your own agent runtime rather than plugging into an existing host, the SDK also provides a client:

import asyncio

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

params = StdioServerParameters(
    command="python",
    args=["orders_server.py"],
    env={"ORDERS_API_URL": "https://orders.internal", "ORDERS_API_TOKEN": "..."},
)


async def main() -> None:
    async with stdio_client(params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()

            tools = await session.list_tools()
            for tool in tools.tools:
                print(tool.name, "-", tool.description.splitlines()[0])

            result = await session.call_tool(
                "search_orders",
                arguments={"customer_email": "[email protected]", "status": "open"},
            )
            for block in result.content:
                if block.type == "text":
                    print(block.text)


asyncio.run(main())

In a real agent, you would convert tools.tools into your model provider’s tool format, pass them to the model, and route the model’s tool calls back through session.call_tool. That loop is the same one described in Anthropic’s Building effective agents; MCP only standardizes how the tools arrive.

Security: where MCP deployments go wrong

MCP makes it easy to connect an agent to powerful systems. That is the point, and it is also the risk. The protocol gives you hooks for consent and authorization, but it does not enforce good judgment.

Treat tool metadata as untrusted input

Tool names and descriptions are injected into the model’s context. A malicious or compromised server can write a description that instructs the model to do something unrelated, such as reading files from another server and passing their contents along. This is sometimes called tool poisoning.

Mitigations:

  1. Only install servers from sources you trust, and pin versions or image digests.
  2. Review tool descriptions on install and alert on changes. A description that changes after approval deserves scrutiny.
  3. Namespace tools per server in the host so one server cannot shadow another’s tool names.

Treat tool output as untrusted input

A tool that reads email, tickets, web pages, or documents will return text written by people outside your control. That text can contain instructions. The OWASP Top 10 for LLM Applications lists prompt injection first for good reason. The short version of the defense: the agent’s permissions should assume it will eventually be tricked.

Scope credentials to the user, not the server

A common anti-pattern is a remote MCP server that holds one powerful service account and serves every user. Now every user’s agent has the union of everyone’s access. Prefer servers that act on behalf of the authenticated user, using delegated OAuth tokens, so the downstream system’s own permissions still apply.

Do not pass the token the client sent you straight through to an upstream API. The spec explicitly warns against this “token passthrough” pattern because it breaks audience validation and makes audit trails unreliable.

Gate destructive tools

The cancel_order tool above is irreversible. In production, the host should require explicit confirmation for tools like that, either through its own approval UI or through elicitation. MCP supports tool annotations such as hints that a tool is read-only or destructive. Annotations are useful for UX, but they are self-declared by the server, so don’t use them as a security boundary.

Operating MCP servers in production

Once you have more than a handful of servers, operational questions dominate.

Put a gateway in front of remote servers

A gateway or proxy layer gives you one place to enforce authentication, rate limits, allow-lists of tools per agent, and logging. It also lets you swap or version servers without reconfiguring every host.

Trace every tool call

Each tool call should produce a span with the tool name, arguments (redacted where needed), latency, result size, and error status. The OpenTelemetry GenAI semantic conventions include attributes for tool execution, which keeps your traces portable across vendors. See observability for AI agents for a fuller setup.

Watch your tool count

Every tool you expose costs context tokens and adds a decision for the model. Connecting ten servers with fifteen tools each puts 150 tool definitions in front of the model on every turn. Selection accuracy tends to degrade as the list grows, and token cost rises with it. Expose only the tools a given agent needs, and consider loading tool sets dynamically based on the task. This is a context engineering problem as much as a protocol one.

A rollout plan that works

Here is the sequence we recommend for teams adopting MCP:

  1. Pick one system of record that agents genuinely need, such as your ticketing system or internal knowledge base.
  2. Design five or fewer tools around user tasks, not API endpoints. Write the descriptions as if onboarding a new engineer.
  3. Ship it over stdio to a small group of internal users in an existing MCP host. Collect transcripts.
  4. Build an eval set from those transcripts: tasks, expected tool calls, and expected outcomes.
  5. Move to Streamable HTTP behind a gateway with OAuth once the tool design stabilizes.
  6. Add the second server only after the first one has traces, evals, and an owner.

The hardest part is rarely the protocol. It is deciding what the tools should be and who owns them when they break.

FAQ

Is MCP the same as function calling?

No. Function calling is a model capability: the model emits a structured request to call a function you defined. MCP is a protocol for discovering and invoking those functions across process and network boundaries. A host typically fetches tools from MCP servers and then presents them to the model using the provider’s native function calling.

How does MCP relate to A2A?

They solve different problems. MCP connects an agent to tools and data, while the A2A protocol connects agents to other agents that have their own reasoning and state. Many systems use both. Our A2A guide covers where the boundary sits.

Should we wrap every internal API as an MCP server?

Usually not. Wrapping APIs one-to-one tends to produce too many low-level tools that are hard for models to use well. Start with the workflows agents actually perform, design a small set of task-shaped tools for them, and expand based on observed gaps.

Can we use MCP with any model provider?

Yes. MCP is model-agnostic. The host is responsible for translating MCP tool definitions into whatever format its model provider expects, and many agent frameworks include adapters that do this for you.

Working with TechnoKeen

We help engineering teams design MCP servers, secure them behind gateways, and connect them to production agents with evals and tracing in place. If you are planning an MCP rollout, talk to us about where to start, or browse our glossary for related terms.

  • #model context protocol
  • #MCP
  • #agent tooling
  • #integrations

TechnoKeen Engineering

TechnoKeen is an enterprise agentic AI company. Our engineers design, deploy, and govern AI agents for organizations in regulated and complex industries, and share what we learn in the field.

About TechnoKeen →

Keep reading

Engineering 9 min read

How to Choose an AI Agent Framework in 2026

How to choose an AI agent framework: compare graph, role-based, provider SDK, and minimal approaches by control, observability, lock-in, and team fit.

Ready to put agents to work?

Book a 45-minute executive briefing. We will review your priority workflows, current AI efforts, and risk posture, then outline a clear path to agents in production.