The three messages every Model Context Protocol server answers

Changelogs for products that add an MCP endpoint tend to read the same way: remote MCP over HTTP, JSON-RPC support for initialize, tools/list and tools/call, version negotiation handled by the official SDK. If you have not worked with the protocol before, that sentence hides a lot. What do these methods actually exchange, in what order, and what breaks when one of them is wrong?
This article explains the core message flow with concrete JSON examples. It is for developers who want to build, test or debug an MCP server and would rather understand the wire format than treat the SDK as a black box. You will also see how to write automated checks for the metadata your server publishes, so tool selection keeps working when someone uses a smaller model.
Frequently asked questions
What is JSON-RPC?
JSON-RPC 2.0 is a simple remote procedure call format. Each request is a JSON object with a method name, optional params and an id; each response carries the same id with either a result or an error. Messages without an id are notifications that expect no reply.
What does initialize do?
It opens a session. The client states which protocol version and capabilities it supports, the server replies with the version it will use and its own capabilities, such as offering tools. Nothing else should happen before this exchange.
What does tools/list return?
An array of tool definitions, each with a name, a human-readable description and an input schema in JSON Schema format. Clients pass these definitions to the model so it knows which tools exist and how to call them.
What does tools/call do?
It runs one tool with arguments the model produced. The server returns a result containing content items, typically text, and may mark the result as an error so the model can react.
How does MCP differ from ordinary function calling in a chat API?
Function calling is how a model asks for a tool inside one API request. MCP is a protocol between an AI client and external servers that provide tools. The client translates MCP tool definitions into the model's function-calling format and back.
Which transport should a new server use, stdio or HTTP?
Stdio suits tools that run on the user's machine and are launched by the client. HTTP suits shared or hosted services. The messages are the same JSON-RPC either way; only the delivery differs.
Does the model talk to the MCP server directly?
No. The model only produces text, including structured tool-call requests. The client reads those, sends tools/call to the server and feeds the result back into the next model request.
- The shape of the conversation
- initialize: agreeing on version and capabilities
- tools/list: describing what the server can do
- tools/call: running a tool and returning results
- Transports: same messages, different pipes
- A minimal server with the official Python SDK
- Testing your metadata, not just your code
- Where to go from here
The shape of the conversation
An MCP session follows a fixed rhythm. First the client sends initialize and waits for the reply. Then it sends a notification, notifications/initialized, to confirm it is ready. After that it usually calls tools/list to discover what the server offers. From then on, each time the model wants a tool, the client sends tools/call.
The protocol also defines resources, prompts and other features, but tools are what most servers implement first and what most clients use. Understanding these three methods covers the majority of real-world debugging.
Requests, responses and notifications
Requests carry an id and expect a response with the same id. Notifications have no id and get no reply. Mixing these up, for example sending initialized with an id, is a classic cause of a client hanging while it waits for an answer that never comes.
The server can also speak first
Over some transports, servers may send notifications to the client, for example to announce that the tool list has changed. Clients that support this then call tools/list again.
initialize: agreeing on version and capabilities
The first request tells the server who is calling and what the client can handle. The server answers with the protocol version it selected, its own name and version, and a capabilities object. If the server supports tools, the capabilities include a tools entry.
Version negotiation matters because the protocol evolves. The client proposes the version it prefers; the server responds with that version if it supports it, or with another version it does support. If the client cannot work with the server's choice, it should disconnect rather than continue with mismatched expectations.
Why the SDK usually handles this
Official SDKs implement negotiation for you. Writing it by hand is possible, but the SDK keeps up with protocol changes, which is why most product changelogs mention relying on it.
{"jsonrpc": "2.0", "id": 1, "method": "initialize",
"params": {"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": {"name": "example-client", "version": "1.0.0"}}}
{"jsonrpc": "2.0", "id": 1,
"result": {"protocolVersion": "2025-06-18",
"capabilities": {"tools": {"listChanged": false}},
"serverInfo": {"name": "notes-server", "version": "0.3.1"}}}
tools/list: describing what the server can do
The tool list is the most important thing your server publishes, because the model never sees your code, only these definitions. Each tool has a name, a description and an inputSchema. The description tells the model when to use the tool; the schema tells it how to format arguments.
Good definitions are short, specific and unambiguous. "Search saved articles by keyword; returns up to 10 titles with URLs" is better than "Search". Each argument should have a type and its own description, and required fields should be listed explicitly.
Definitions cost tokens on every turn
Clients include tool definitions in each model request. Verbose descriptions across many tools add up quickly, which is why measuring this overhead is worthwhile; see why token counts vary.
Pagination exists for large lists
If a server has many tools, tools/list can return a cursor for the next page. Most servers stay small enough that this never comes up, and smaller lists also help models choose correctly.
{"jsonrpc": "2.0", "id": 2,
"result": {"tools": [{
"name": "search_articles",
"description": "Search saved articles by keyword. Returns up to 10 matches with title and URL.",
"inputSchema": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Keywords, 1-6 words"},
"limit": {"type": "integer", "minimum": 1, "maximum": 10}
},
"required": ["query"]
}
}]}}tools/call: running a tool and returning results
When the model decides to use a tool, the client sends tools/call with the tool name and an arguments object. The server runs the tool and returns a result whose content is a list of items. Text items are the most common; the protocol also supports other content types for clients that handle them.
If the tool fails in a way the model should know about, such as invalid input or no results, the server returns a normal result with isError set to true and a helpful message. Protocol-level problems, like an unknown method, use a JSON-RPC error object instead.
Tool errors versus protocol errors
Use isError for problems the model can fix by retrying with different arguments. Use JSON-RPC errors for broken requests. Getting this distinction right lets agents recover gracefully instead of giving up.
{"jsonrpc": "2.0", "id": 3, "method": "tools/call",
"params": {"name": "search_articles", "arguments": {"query": "sleep research", "limit": 3}}}
{"jsonrpc": "2.0", "id": 3,
"result": {"content": [{"type": "text", "text": "1. Why naps help memory - https://example.org/a\n2. ..."}],
"isError": false}}
Transports: same messages, different pipes
Over stdio, the client launches the server as a subprocess and exchanges newline-delimited JSON messages over standard input and output. Logging must go to standard error, never standard output, or it corrupts the message stream.
Over HTTP, the current approach is often called Streamable HTTP: the client POSTs JSON-RPC messages to a single endpoint, and the server replies either with plain JSON or with a stream of events. The server may assign a session identifier in a response header that the client then sends on later requests.
Print statements break stdio servers
A stray debug print to standard output is one of the most common reasons a local server connects and then behaves erratically. Route all logs to stderr or a file.
Authentication sits outside JSON-RPC
For hosted servers, authentication is handled at the HTTP layer, typically with OAuth-style tokens. The JSON-RPC messages themselves do not carry credentials.
A minimal server with the official Python SDK
You rarely need to write the JSON by hand. The official Python SDK provides a compact way to declare tools with type hints; it generates the schema and handles initialize and tools/list for you. The example below runs over stdio and exposes one tool.
The docstring becomes the description
The SDK uses the function's docstring as the tool description and its type hints for the schema. Writing a clear docstring is therefore writing the prompt the model will see.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("word-tools")
@mcp.tool()
def count_words(text: str) -> int:
"""Count the words in a piece of text."""
return len(text.split())
if __name__ == "__main__":
mcp.run()
Testing your metadata, not just your code
Unit tests can confirm a tool returns the right output. They cannot confirm that a model will choose the tool when it should. Developers who want automated checks for this write scenario tests: given a set of tools and a user prompt, does the model propose the expected tool with sensible arguments?
You can run such tests by translating your tools/list output into the function-calling format of a chat API, sending a prompt and inspecting what the model asks for. Running them against a smaller model is a good stress test: if a mid-sized model picks the right tool, larger ones almost always will.
Using a free model for scenario tests
A keyless endpoint makes these tests cheap. free-ai on this site is an independent open-weight model of about 35B parameters; it is not Claude, and the site is not affiliated with Anthropic. Its tool-calling behaviour depends on your client, so treat results as a robustness signal rather than a guarantee for any specific production model.
- Keep a list of prompts with the tool you expect each to trigger.
- Include prompts that should trigger no tool at all.
- Check argument types and required fields in the proposed call.
- Rerun the suite whenever you change a name or description.
Where to go from here
With these three methods understood, most MCP problems become readable. A session that never shows tools is usually failing at initialize or tools/list; a tool that appears but errors is failing at tools/call. The article on tools that appear in settings but not in chat applies this to real debugging, and vetting public MCP servers covers what to check before connecting someone else's server.
For complex agents with many tools, frontier models with mature tool use, Claude among them, remain the most reliable choice in production. The protocol itself is model-neutral, which is its main strength: the same server works with any client and any model that supports it.
Read the specification once
The official specification is shorter than many people expect. Skimming the sections on lifecycle, tools and transports takes an hour and pays back every time a client behaves unexpectedly, because you can tell whether the server or the client is departing from the standard.
Log raw messages during development
Write every incoming and outgoing JSON-RPC message to a file while you develop. When a session misbehaves, the log shows exactly which method failed and with which payload, which is far quicker than guessing from the client's interface.
Version your tool definitions
Treat names, descriptions and schemas as a public interface. Renaming a tool or changing a required argument can break prompts and saved workflows that depend on it, so change them deliberately and note the change in your server's release notes.

Send a test prompt to the keyless free-ai endpoint from the chat box on the home page, no sign-up or key required.
Read also
- Why Can an Agent See Your MCP Tools but Never Manage to Call Them?
- MCP Connector vs Local Export: Which Is Better for Your Notes?
- How to Write Prompts That Small and Mid-Sized Models Follow
- Who Can Read Your Prompts When You Use an Unofficial API Proxy?
- Is It Safe to Connect Your AI Client to a Public MCP Server?