Sub topic 3
Tools, resources and prompts
This chapter assumes you know what an MCP server is and how host, client and server relate. It also assumes you can read JSON and a short Python function. A server offers its capabilities through three primitives: tools, resources and prompts. They differ in who decides when each one is used.
Three primitives, three controllers
A primitive is a kind of capability a server can expose. Each kind has a different controller, meaning the party that triggers it.
| Primitive | What it is | Who controls it | Typical example |
|---|---|---|---|
| Tool | A function the model can call to do something | The model, usually with user approval | Run a query, create an issue |
| Resource | Read-only data identified by a URI | The application or the user | A file, a database schema |
| Prompt | A reusable message template with arguments | The user | A "review this diff" slash command |
The controller matters more than the data format. A tool runs because the model decided it was useful. A resource is attached because the application or the user chose it. A prompt starts because the user picked it from a menu.
Tools
A tool has a name, a description and an input schema written in JSON Schema. The client finds tools with tools/list. It runs one with tools/call.
The model chooses a tool by reading its name and description, so these act as instructions. A vague description such as "does stuff" leads to wrong or missed calls. A tool may change the outside world, so most assistants ask you to approve calls before they run.
With the Python SDK, the function signature and docstring produce the schema and description:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("notes")
@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()The client sees a tool named count_words with one required string argument, text. The docstring becomes its description.
Resources
A resource is data the server can read out, named by a URI such as file:///project/README.md or db://orders/schema. Clients find them with resources/list and read one with resources/read. Resources do not perform actions. The model does not call them on its own. The application decides how to use them. It might show a picker, or attach the content to the conversation.
A server can also publish resource templates, which are URIs with parameters such as logs://{date}. These suit data that comes in many similar pieces.
Prompts
A prompt is a template the server provides, with named arguments. A client lists prompts with prompts/list and fetches one with prompts/get. The server returns ready-made messages, which the client puts into the conversation. Many assistants show prompts as slash commands. They suit repeated workflows that you want written once and shared across a team.
Choosing the right primitive
Ask who should trigger the capability and whether it has side effects.
- The model should decide, or the capability changes something: use a tool.
- The capability is data to read, and a person or the app picks it: use a resource.
- The capability is a workflow the user starts by name: use a prompt.
A common mistake is to make everything a tool. Reading a schema as a tool works, but it spends the model's attention and adds context cost. It also gives the model a decision that a person could make. Another common mistake is to expect the model to browse resources by itself. Support for this varies, and many assistants do not do it. If the model must reach the data unaided, expose it as a tool as well.
Exercise
A server exposes a company style guide as text. You want a developer to type /review-style, then have the assistant check the open file against the guide. Which primitives fit, and why?
Show answer
A prompt fits the /review-style command, because the user starts it by name and the server returns a ready-made message. The style guide itself fits a resource, since it is read-only data that the prompt can include. A tool is not needed, because nothing is executed and no side effect is involved.
Exercise
Why is a precise tool description important?
Show answer
The model decides whether and how to call a tool by reading its name, description and input schema. A vague description leads to missed or wrong calls.