Sub topic 1
Why Assistants Need a Standard Way to Reach Tools
A coding assistant is useful because it can read your code and suggest changes. It becomes much more useful when it can also query your database, read a ticket, or run your test suite. This chapter explains why that reach needs a shared standard, and what problem the Model Context Protocol (MCP) was designed to solve. Later chapters cover how the protocol works.
Prerequisites
This chapter assumes you can:
- Use a command line and run a Python script.
- Read JSON and edit a JSON file.
- Read basic Python or JavaScript.
- Use an AI coding assistant, such as a terminal agent or an editor plugin, to work on a real project.
You do not need to know anything about MCP yet.
The gap: a model that only produces text
A large language model (LLM) takes text in and returns text out. It has no built-in way to open a file, call an API, or run a command. It also knows nothing about your repository, your tickets, or your production logs unless that information is placed in its input.
A coding assistant closes this gap with a program around the model. This chapter calls that program the host. The host does three things:
- It tells the model which actions are available.
- It reads the model's output and detects when the model asks for an action.
- It runs the action and feeds the result back to the model as more text.
This loop is usually called tool use or function calling. The model never executes anything. It emits a structured request such as "call get_file_size with this path", and the host decides whether and how to carry it out.
Tool use without a standard
Every assistant vendor has defined its own format for describing tools and returning results. The example below shows the pattern. It describes one tool, registers a handler, and dispatches a call that the model would produce.
import json
import os
# A tool definition in one vendor's style: a name, a description,
# and a JSON Schema for the arguments.
TOOLS = [
{
"name": "get_file_size",
"description": "Return the size of a file in bytes.",
"input_schema": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"],
},
}
]
def get_file_size(path: str) -> int:
return os.path.getsize(path)
HANDLERS = {"get_file_size": get_file_size}
def dispatch(call: dict) -> int:
handler = HANDLERS[call["name"]]
return handler(**call["arguments"])
if __name__ == "__main__":
# In a real host this dict is parsed from the model's output.
model_request = {"name": "get_file_size", "arguments": {"path": __file__}}
print(json.dumps({"result": dispatch(model_request)}))This works. The cost shows up when you scale it. The schema, the dispatch code, and the result format all belong to this one assistant. If you want the same tool in a second assistant, you rewrite the glue for that assistant's format. If the tool needs a database connection, each assistant needs its own way to store the credentials and start the process.
The N×M problem
Suppose there are N assistants and M systems you want to connect, such as GitHub, a database, a browser, and a file store. With no shared interface, each pairing needs its own integration, so the total is N × M. Each integration has its own bugs, its own configuration, and its own owner.
A shared protocol changes the arithmetic. Each assistant implements the protocol once. Each system is wrapped once. The total work becomes N + M.
The same pattern appeared earlier in developer tooling. The Language Server Protocol (LSP) lets one language server provide completion and diagnostics to many editors. MCP applies the same idea to AI assistants and the tools and data they use.
What the standard has to cover
Sharing a format for tool schemas is not enough. For a tool written once to work in any assistant, the standard has to settle several questions:
| Question | Why a shared answer matters |
|---|---|
| How does the assistant discover what a tool can do? | The model needs names, descriptions, and argument schemas at runtime, not hard-coded. |
| How is a call made and its result returned? | Both sides need one message format, including how errors are reported. |
| How is the tool process started and reached? | A local program and a remote service need defined ways to connect. |
| How do both sides agree on supported features? | Different versions and implementations must still interoperate. |
| How is configuration supplied? | Users need one familiar way to add a tool, including secrets. |
MCP answers each of these. Later chapters cover the details: a message format based on JSON-RPC 2.0, two transports (stdio and Streamable HTTP), a startup handshake, and a configuration entry that names the command to launch.
The MCP idea in one paragraph
MCP is an open protocol. A program called an MCP server exposes capabilities. These can be actions the model can call (tools), data the assistant can read (resources), and reusable prompt templates (prompts). The assistant, called the host, contains a client for each server it connects to. The client asks the server what it offers, and the host passes that to the model. When the model asks for a tool, the client forwards the request to the server and returns the result.
A server author writes this once. A user adds the server to any MCP-capable assistant with a short configuration entry. The next chapter covers the roles of host, client, and server in more detail.
What a standard does and does not give you
It helps to be exact about what you gain, because some expectations are wrong.
What you gain:
- Reuse. A server written for one host works with others that support MCP.
- Separation of concerns. The server author knows the system being wrapped. The host author knows how to manage a model. Neither has to understand the other's internals.
- Process isolation. A server usually runs as its own process. A crash or a dependency conflict in the server does not take down the assistant.
- A common debugging surface. Because all servers speak the same protocol, one inspection tool can test any of them. The Debugging chapter covers this.
What you do not gain:
- A guarantee that the model uses the tool well. The model chooses tools from their names and descriptions. A poorly described tool is called at the wrong times or not at all, even if the protocol works perfectly.
- Safety. A standard connection is not a trusted connection. A server can read files, send network requests, or return text that tries to steer the model. The Security chapter covers this.
- Zero cost. Every tool description a host loads takes space in the model's context window. A host with many servers can spend a large share of its context on tool definitions before you type anything.
When you may not need MCP
MCP is not always the right choice. Consider simpler options first:
- The assistant can already run shell commands. If the task is "run
git logand summarize it", a shell tool may be enough. You gain little by wrappinggitin a server. - The assistant has a built-in integration. Use that one if it covers your case, because it is maintained with the host.
- You control one host and one tool. The N×M problem barely exists, so a direct integration may be simpler.
- The capability needs strict, audited behavior. A thin wrapper you write and review yourself may be easier to trust than a third-party server.
MCP pays off when you want the same capability in several assistants, when a maintained server already exists, or when the capability needs its own process, dependencies, or credentials.
Common misconceptions
- "MCP is a way to make the model smarter." It changes what the model can reach, not how it reasons. The model still decides from text.
- "The server calls the model." In the basic flow, the host calls the model, and the server only responds to requests. Servers can request model help through an optional feature, but that is not how a normal tool call works.
- "MCP replaces function calling." The model still emits a function-call style request. MCP standardizes how the host learns about tools and forwards calls to the programs that implement them.
- "A server is always a web service." Many servers are local programs that the host starts as child processes. Remote servers exist too, and the Transports chapter compares them.
Where this chapter fits
The rest of the tutorial builds on this motivation. You will learn the architecture and message format, the three primitives, and the two transports. Then you will configure an existing server, follow a tool call end to end, write your own server, debug it, and judge which servers deserve your trust and context budget.
Exercise
Your team uses four different AI coding assistants and wants each of them to query the same internal issue tracker. Without a shared protocol, how many integrations are needed, and how many with one? Name one reason the protocol-based approach might still not be worth it.
Show answer
Without a protocol, each assistant needs its own integration with the tracker, so four integrations. With a protocol, you write one server for the tracker, and each assistant needs only generic client support, so one server plus four existing client implementations (N + M instead of N × M). The approach might not be worth it if only one assistant is actually used, or if its built-in integration already covers the tracker, because then the extra process and configuration add cost without any reuse benefit.
Exercise
A colleague says, "Since we use MCP, the model can safely call any server we add." Identify two things wrong with this claim.
Show answer
First, MCP standardizes the connection, not trust. A server is code that runs on your machine and can access files, networks, and secrets, and its output can contain text that tries to manipulate the model. Second, protocol compatibility does not mean the model uses a tool correctly. The model picks tools from their descriptions, and every added server also consumes context window space. Servers need review and selective enabling.