agent_signal

Guide

MCP Servers Explained: How They Work and How to Build One

By Agent Signal · Published 2026-10-19 · Updated 2026-10-19

Short answer

An MCP server is a program that exposes tools, resources and prompts to AI applications through the Model Context Protocol, an open standard Anthropic released in Nov 2024. The host app creates one client per server and talks JSON-RPC over stdio (local) or Streamable HTTP (remote).

An MCP server is the piece of code that gives an AI application access to your tools and data through one standard protocol, instead of a custom integration for every app. This guide covers what a server is, the parts it exposes, how it talks to clients, how to build a minimal one, and what to lock down before you ship it. Every claim links to the official MCP docs, the spec, or Anthropic's launch post.

What is an MCP server?

The Model Context Protocol (MCP) is an open standard that Anthropic open-sourced on Nov 25, 2024 for "connecting AI assistants to the systems where data lives." The pitch was to replace "fragmented integrations with a single protocol" (Anthropic announcement). The launch shipped three pieces: the specification and SDKs, local MCP server support in the Claude Desktop apps, and an open-source repository of MCP servers (Anthropic; repo: modelcontextprotocol/servers).

The official docs define an MCP server as "a program that provides context to MCP clients." That applies whether it runs on your laptop or on someone else's platform (MCP architecture overview).

One scope note from the docs is worth keeping in mind: MCP "focuses solely on the protocol for context exchange—it does not dictate how AI applications use LLMs or manage the provided context" (architecture). Your agent framework still owns the loop, memory and approvals.

How do MCP hosts, clients and servers fit together?

MCP has three participants (architecture):

The docs' example: when VS Code connects to the Sentry MCP server and to a local filesystem server, it creates two separate client objects, one per connection (architecture).

What can an MCP server expose?

Servers offer three core primitives (architecture):

Primitive What it is Example
Tools Executable functions the AI app can invoke File operations, API calls, database queries
Resources Data sources that provide context File contents, database records, API responses
Prompts Reusable templates for interacting with the model System prompts, few-shot examples

Each primitive has list methods (*/list) for discovery, plus retrieval or execution methods such as tools/call. Lists can change at runtime (architecture). The docs' database example uses all three: tools to run queries, a resource holding the schema, and a prompt with few-shot examples.

Clients can offer things back to servers too. Elicitation lets a server ask the user for more information or for confirmation of an action. Sampling (asking the client's model for a completion) and logging are deprecated as of protocol version 2026-07-28. New servers should call LLM APIs directly and log to stderr or OpenTelemetry instead (architecture).

How does an MCP server talk to a client?

MCP has two layers (architecture).

Data layer: a JSON-RPC 2.0 protocol for discovery, primitives and notifications. The current docs describe MCP as stateless. Every request carries the protocol version and client capabilities in its _meta field. Servers must implement server/discover, which returns supported versions and capabilities, though clients don't have to call it first.

Transport layer: there are two transports.

In practice, a local stdio server typically serves one client, while a remote Streamable HTTP server typically serves many (architecture).

A tool call is plain JSON-RPC. The client lists tools with tools/list and gets back each tool's name, title, description and inputSchema (a JSON Schema). Then it invokes one with tools/call, passing name and arguments (tools spec).

How do I build a simple MCP server?

The official Build an MCP server tutorial builds a weather server with two tools, get_alerts and get_forecast. It covers Python, TypeScript, Java, Kotlin, C#, Ruby, Rust and Go. The Python version, condensed:

uv init weather && cd weather
uv venv && source .venv/bin/activate
uv add "mcp[cli]"
from mcp.server import MCPServer

mcp = MCPServer("weather")

@mcp.tool()
async def get_alerts(state: str) -> str:
    """Get weather alerts for a US state.

    Args:
        state: Two-letter US state code (e.g. CA, NY)
    """
    ...  # call the API, return text

if __name__ == "__main__":
    mcp.run(transport="stdio")

What the tutorial tells you:

How should tool results and errors be returned?

From the tools spec:

Is an MCP server safe to give to an agent?

Only with guardrails. The spec puts responsibilities on both sides (tools spec).

The protocol tells the client to ask a human. It doesn't make the action safe to repeat. If an approved tool charges a card or sends an email, your agent still needs to make sure a retry or a resumed run can't fire it twice. That's the side-effect problem our templates are built around. See LangGraph idempotent approval and OpenAI Agents SDK approval + resume.

FAQ

What is the difference between an MCP server and an MCP client?

The server is the program that exposes tools, resources and prompts. The client lives inside the host app and keeps one dedicated connection to one server (architecture).

Should I use stdio or Streamable HTTP?

Use stdio for a local server launched by the host on the same machine. Use Streamable HTTP for a remote server that many clients reach over the network, ideally with OAuth-issued tokens (architecture).

What are MCP tools, resources and prompts?

Tools are functions the AI app can call. Resources are data it can read for context. Prompts are reusable interaction templates (architecture).

Why does my stdio MCP server break when I add print statements?

Stdout carries the JSON-RPC messages, so anything else written there corrupts them. Log to stderr instead (build-server tutorial).

Does MCP require human approval for tool calls?

The spec says there SHOULD always be a human able to deny tool invocations, and clients SHOULD confirm sensitive operations. The protocol doesn't force a particular UI (tools spec).

Who created MCP?

Anthropic open-sourced it on Nov 25, 2024. It was created by David Soria Parra and Justin Spahr-Summers (Anthropic).


Related on Agent Signal:

Agent Signal is a weekly newsletter for people building AI agents, with tested templates at tryagentsignal.com.

Free starter pack

The approval-flow starter pack

Tested human-in-the-loop approval starters for LangGraph, OpenAI Agents SDK, Vercel AI SDK and Google ADK, plus the Agent Signal newsletter. Free.

Get the Agent Signal newsletter