Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 2 of 6 · Concept · 15 min · revision 3

Primitives: Tools, Resources and Prompts

The three things an MCP server can offer, who decides when each is used, what their definitions and results look like in revision 2026-07-28, and how to choose the right one for a capability.

Contentsand lesson path

What you will learn

  • Describe MCP's host-client-server architecture and its server primitives (tools, resources, prompts), and choose the right primitive for a capability.

Prerequisites: Tool Calling

01. Why it matters

An MCP server offers its capabilities as three kinds of primitive: tools, resources and prompts. They differ less in what data they carry than in who decides when they are used:

  • Tools are model-controlled. The model sees their descriptions and decides to call one while working on a task.
  • Resources are application-driven. The host decides which data to put in front of the model, often because the user picked it from a list.
  • Prompts are user-controlled. The user chooses a template, often from a slash-command menu, and the host fills it in.

Picking the wrong primitive makes a capability awkward or unsafe. A large reference document exposed only as a tool is fetched only when the model thinks of it, and every fetch costs a round trip. An action exposed as a resource never runs, because reading a resource is not supposed to change anything. A workflow hidden in a tool description cannot be offered to the user as a menu item. This lesson shows each primitive as it appears on the wire in revision 2026-07-28, then gives you a short decision guide.

02. Tools: actions the model can take

A client finds tools with tools/list. Each tool definition has:

  • name, unique within the server, plus an optional human-readable title;
  • a description that the model reads to decide when to use the tool;
  • an inputSchema, a JSON Schema object for the arguments. When the schema has no $schema keyword, it is read as JSON Schema 2020-12;
  • an optional outputSchema for structured results;
  • optional annotations such as readOnlyHint. These are hints from the server, so hosts treat them as untrusted unless they trust the server.

The client runs a tool with tools/call, passing name and arguments. The result holds a content array for the model, which can contain text, image, audio, resource links and embedded resources. If the tool declares an outputSchema, the result must also carry structuredContent that conforms to it. In 2026-07-28 that can be any JSON value, such as an array, where earlier revisions required an object; for older clients the server should repeat that JSON as text in content. A tool that ran but failed returns isError: true with a message the model can act on. Like every 2026-07-28 result, it also carries resultType, normally "complete".

Here is the one tool of the server you will build in lesson 3, exactly as its tools/list result describes it.

JSON · one tool definition from the lab server's tools/list result
{
  "name": "celsius_to_fahrenheit",
  "title": "Celsius to Fahrenheit",
  "description": "Convert a temperature in degrees Celsius to Fahrenheit.",
  "inputSchema": {
    "type": "object",
    "properties": {"celsius": {"type": "number", "minimum": -273.15}},
    "required": ["celsius"],
    "additionalProperties": false
  },
  "outputSchema": {
    "type": "object",
    "properties": {"fahrenheit": {"type": "number"}},
    "required": ["fahrenheit"]
  },
  "annotations": {"readOnlyHint": true}
}

03. Resources and prompts

Resources are data identified by a URI, such as file:///project/README.md or a custom scheme like docs://units/scales. A client lists them with resources/list and reads one with resources/read, which returns contents as text or base64 blob data with a MIME type. Parameterised families, such as one resource per database table, are published as resource templates with URI templates like db://tables/{name}. List and read results in 2026-07-28 also carry caching hints, ttlMs and cacheScope, which tell the client how long it may reuse a result.

Resources can change. In 2026-07-28 a client that wants updates opens one long-lived subscriptions/listen request and lists the URIs it cares about under resourceSubscriptions; the server then sends notifications/resources/updated on that stream. Revisions up to 2025-11-25 used per-URI resources/subscribe and resources/unsubscribe requests instead, so you will still see those names in older code.

A caution about read-only data: exposing a file as a resource does not stop a tool on the same server, or on another server, from writing that file. When you audit a server, check which tools can change state, not only which data is offered as resources.

Prompts are reusable message templates. prompts/list returns each prompt's name, title, description and arguments (prompt arguments are strings). prompts/get with argument values returns messages, each with a role and content, which the host hands to the model. Hosts typically show prompts as slash commands, so a prompt suits a workflow the user starts deliberately, such as "summarise this incident for the status page".

04. One server, three primitives, with an official SDK

In practice you rarely write these JSON definitions by hand. The official Python SDK (package mcp, version 2.x) derives them from decorated functions: type hints become the inputSchema, a Field(ge=...) constraint becomes minimum, a return type such as a Pydantic model becomes the outputSchema, and the docstring becomes the description. The file below offers the same tool, resource and prompt as the lab server in lesson 3, and it was run with mcp 2.3.0 on Python 3.13.

Python · sdk_server.py · official SDK mcp 2.x
"""The atlas-units server written with the official Python SDK (mcp 2.x)."""
from typing import Annotated

from pydantic import BaseModel, Field

from mcp.server import MCPServer
from mcp.types import ToolAnnotations

mcp = MCPServer("atlas-units")


class Fahrenheit(BaseModel):
    fahrenheit: float


@mcp.tool(title="Celsius to Fahrenheit",
          annotations=ToolAnnotations(readOnlyHint=True))
def celsius_to_fahrenheit(celsius: Annotated[float, Field(ge=-273.15)]) -> Fahrenheit:
    """Convert a temperature in degrees Celsius to Fahrenheit."""
    return Fahrenheit(fahrenheit=round(celsius * 9 / 5 + 32, 2))


@mcp.resource("docs://units/scales")
def scales() -> str:
    """Freezing and boiling points of water on both scales."""
    return "Water freezes at 0 C (32 F) and boils at 100 C (212 F)."


@mcp.prompt(title="Explain a conversion")
def explain_conversion(celsius: str) -> str:
    """Ask the model to explain one Celsius to Fahrenheit conversion."""
    return f"Convert {celsius} degrees Celsius to Fahrenheit and show each step."


if __name__ == "__main__":
    mcp.run()  # stdio; mcp.run(transport="streamable-http", port=8931) for HTTP

To see what the SDK derived, sdk_check.py connects a Client to the server in memory (no subprocess, no port), prints the tool definition from tools/list, and calls the tool once with a valid and once with an invalid temperature.

Python · sdk_check.py
"""Connect in memory to sdk_server.py and show what the SDK derived."""
import json
import textwrap

import anyio

from mcp import Client
from sdk_server import mcp


async def main() -> None:
    async with Client(mcp) as client:
        tool = (await client.list_tools()).tools[0]
        print(json.dumps(tool.model_dump(by_alias=True, exclude_none=True), indent=1))
        name = "celsius_to_fahrenheit"
        ok = await client.call_tool(name, {"celsius": 37})
        print("ok:", ok.structured_content, "| is_error:", ok.is_error)
        bad = await client.call_tool(name, {"celsius": -300})
        print("bad | is_error:", bad.is_error)
        first_line = bad.content[0].text.splitlines()[0]  # pydantic adds more lines
        print("\n".join(textwrap.wrap(first_line, 80)))


anyio.run(main)
Terminal (with mcp 2.x installed)
python sdk_check.py 2>/dev/null
Expected output (mcp 2.3.0, Python 3.13)
{
 "name": "celsius_to_fahrenheit",
 "title": "Celsius to Fahrenheit",
 "description": "Convert a temperature in degrees Celsius to Fahrenheit.",
 "inputSchema": {
  "type": "object",
  "properties": {
   "celsius": {
    "minimum": -273.15,
    "title": "Celsius",
    "type": "number"
   }
  },
  "required": [
   "celsius"
  ],
  "title": "celsius_to_fahrenheitArguments"
 },
 "outputSchema": {
  "properties": {
   "fahrenheit": {
    "title": "Fahrenheit",
    "type": "number"
   }
  },
  "required": [
   "fahrenheit"
  ],
  "title": "Fahrenheit",
  "type": "object"
 },
 "annotations": {
  "readOnlyHint": true
 }
}
ok: {'fahrenheit': 98.6} | is_error: False
bad | is_error: True
Error executing tool celsius_to_fahrenheit: 1 validation error for
celsius_to_fahrenheitArguments

The derived definition matches the lab server's contract: the same minimum, output schema and readOnlyHint. The SDK adds title keys and does not set additionalProperties: false. The invalid call did not crash the client: the SDK validated the arguments against the schema and returned a result with isError: true, a tool execution error the model can act on. A handler can do the same for its own checks by raising ToolError (from mcp.server.mcpserver.exceptions). The TypeScript SDK (@modelcontextprotocol/server, version 2.x) follows the same idea with server.registerTool(name, { description, inputSchema }, handler).

Servers are not the only side with features. Clients can offer elicitation: the server asks the user for missing input during a call. In 2026-07-28 that happens through multi round-trip requests: the server answers with resultType: "input_required" and a list of input requests, and the client retries the original call with the answers. The client features Sampling (the server borrows the host's model) and Roots (the client tells the server which folders it may use), and the server Logging feature, are deprecated in 2026-07-28. They still work during the deprecation window, but new servers should not adopt them.

05. Choosing a primitive

Ask who should decide that the capability is used, and whether using it changes anything.

  1. The model should decide mid-task, or the operation has side effects or needs arguments: make it a tool. Examples: create an issue, run a search, look up a stock level by item ID.
  2. The data is identified by a stable name and the user or host decides to include it: make it a resource. Examples: a project README, a table schema, the current configuration file.
  3. The user starts a known workflow and the server should supply the wording: make it a prompt. Examples: "review this pull request", "draft a release note".

Many servers expose the same data twice, as a resource for people to attach and as a read-only tool for the model to fetch on demand. That is fine, as long as each one's description says what it is for.

06. Check your understanding

Practice check · 3 questions

Practice check

Pick the best answer for each scenario.

Q1. An inventory server should let the model check the stock level of any item ID whenever it needs to during a task. Which primitive fits?
Q2. A tool's `outputSchema` describes an array of user records. Under revision 2026-07-28, what may its `structuredContent` be?
Q3. In revision 2026-07-28, how does a client learn that a resource it shows the user has changed?
Practice only: not graded, not saved, not evidence.

07. Apply it

For the practice task, read the README of the filesystem server and the fetch server you plan to connect. For each capability they offer, write down which primitive it uses and who decides when it runs. Mark every tool that can change state or reach the network, and note whether its annotations claim it is read-only. After lesson 3 you will check your notes against the real tools/list, resources/list and prompts/list results in the MCP Inspector.

08. Review prompt

From memory: name the three primitives and who controls each; list the fields of a tool definition and of a tool result in 2026-07-28; explain how a client hears about resource changes now and how it did before; and give one capability you would expose as both a resource and a tool, with the reason.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

6 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check