Sub topic 1
Why Assistants Need a Standard Way to Reach Tools
Prerequisites
This chapter assumes basic command-line use, JSON, and either Python or JavaScript. You should also know how to use an AI coding assistant.
Why a Standard Matters
A coding assistant can generate text, but useful work often requires outside capabilities: reading project files, querying an issue tracker, or calling a deployment API. Without a standard, every assistant and integration needs a separate adapter. Each adapter defines its own tool names, argument formats, authentication, and error handling.
The Model Context Protocol (MCP) defines a common interface. An MCP server publishes capabilities in a format that many MCP clients can understand. This reduces repeated integration work and lets you replace one compatible server with another.
Host, Client and Server: Who Does What
The host is the application containing the assistant, such as an AI coding environment. The host manages the conversation and decides when the model may use an external capability.
An MCP client is the host's connection to one server. It handles protocol messages, discovers capabilities, and sends requests.
An MCP server is a separate program that exposes capabilities. It might read files, search a database, or create tickets. The server performs the operation; the model does not receive unrestricted access to the underlying system.
Tools, Resources and Prompts
MCP servers expose three main primitives:
- Tools are callable operations, such as
search_issuesoradd. - Resources are readable data identified by a URI, such as a file or database record.
- Prompts are reusable message templates that help structure a task.
Use a tool when the assistant must cause an action or compute a result. Use a resource when it needs to read contextual data. Use a prompt when you want to package a repeatable instruction.
The Message Format Underneath: JSON-RPC 2.0
MCP messages use JSON-RPC 2.0. A request has a method, parameters, and an identifier so the client can match the response to the request.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "add",
"arguments": { "a": 2, "b": 3 }
}
}The server returns a response with the same id, usually containing a result or an error. Capability discovery commonly uses tools/list before a client invokes a tool.
Exercise
Which MCP primitive should represent a read-only project file?
Show answer
A resource, because the assistant needs to read data rather than request an operation.