Sub topic 3
Tools, resources and prompts
This chapter assumes you can read Python, know the basics of JSON Schema, and have used LLM tool calling. An MCP server can offer three kinds of capability, called primitives. Each primitive has a different owner, meaning the party that decides when it gets used. Choosing the wrong primitive is a common design error.
The three primitives
- A tool is a function the model can ask to run. The server describes it with a name, a description, and a JSON Schema for its input. The model decides when to call it, so tools are model-controlled.
- A resource is read-only data identified by a URI, such as
file:///notes/todo.md. The application decides which resources to fetch and show to the model, so resources are application-controlled. - A prompt is a reusable message template with named arguments. The user picks it, often from a menu or a slash command, so prompts are user-controlled.
| Primitive | Who decides to use it | Typical use | List method | Use method |
|---|---|---|---|---|
| Tool | The model | Take an action or compute something | `tools/list` | `tools/call` |
| Resource | The application | Supply documents or data as context | `resources/list` | `resources/read` |
| Prompt | The user | Start a task from a template | `prompts/list` | `prompts/get` |
A tool in practice
The add function from the minimal server is a tool. The SDK builds its input schema from the type hints.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("calc")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two integers."""
return a + b
if __name__ == "__main__":
mcp.run(transport="stdio")The docstring becomes the tool description. The model reads it to decide whether to call the tool, so write it for the model.
Choosing the right primitive
Ask who should trigger the capability.
- If the model should choose it during a conversation, make it a tool.
- If your application should load it as background context, make it a resource.
- If the user should start it explicitly, make it a prompt.
A common mistake is exposing every document as a tool. The model then burns steps and tokens calling a function to fetch data your application could have supplied directly.
What the control model implies
Control affects safety. Tools can have side effects, so a host should usually ask the user to approve them. Resources are reads, but their content still reaches the model and can contain untrusted text. Prompts expand into messages the user chose to run. The security chapter returns to these points.
Servers do not have to offer all three. During initialization, each server declares which primitives it supports. Your host should check that declaration instead of assuming tools exist.
Exercise
Your server holds a company style guide, and you want the application to include it as context at the start of every session without the model deciding. Which primitive fits, and why?
Show answer
A resource. The application decides when to read it, which matches the application-controlled model. A tool would leave the choice to the model, which might skip it or call it repeatedly.
Exercise
A user types "/summarize-report" in your chat interface to start a fixed workflow. Which primitive is this, and who controls it?
Show answer
A prompt, controlled by the user. The user picks it explicitly, and the server returns a message template filled with the arguments.