MCPmcptoolsresourcespromptscapabilities

MCP Primitives: Tools, Resources, Prompts

An MCP server exposes tools (model-invoked actions), resources (application-read data) and prompts (user-selected templates); knowing which is which decides who controls the call.

Interview question
Progress
Before this, know:Tool Schemas

You have not marked these as done yet. Read on anyway if they feel familiar; come back to them if something here does not land.

Key points

  • Tools: model-controlled actions with a JSON schema; may have side effects.
  • Resources: application-controlled, URI-addressed, read-only data with MIME types.
  • Prompts: user-controlled templates that return message lists.
  • Who controls the primitive determines its risk profile and caching strategy.
  • Tool descriptions are the model's only guide; write them like Tool Schemas prescribes.
  • Use tool annotations (destructiveHint) to drive approval gates in the host.

Three primitives, three controllers

The cleanest way to remember the primitives is by who decides to use them. Tools are model-controlled: the LLM chooses to call search_repository mid-reasoning. Resources are application-controlled: the host decides to load file:///repo/README.md into context. Prompts are user-controlled: a person picks "Summarise this PR" from a menu and the server returns a filled template.

This split matters for safety and cost. Anything model-controlled can be triggered by injected text and must be permissioned. Anything application-controlled is deterministic and can be cached. Anything user-controlled is explicit intent.

  • Tool: search_repository(query, language?) on a GitHub server — has a JSON-schema inputSchema, returns text/JSON content, may have side effects.
  • Resource: file:///workspace/src/main.py or github://org/repo/issues/42 — addressed by URI, read-only, has a MIME type, may support subscriptions for change notifications.
  • Prompt: review_pull_request(pr_number) — returns a message list the host inserts into the conversation, optionally embedding resources.

Tools in detail

A tool definition is a name, a description and a JSON schema for arguments. The description is the only thing the model reads to decide whether to call it, so it carries the same weight as in Tool Schemas: say what it does, when to use it, and what it returns.

Servers can also annotate tools with hints such as readOnlyHint or destructiveHint. Hosts should use those hints to route destructive tools through Approval Gates and Risk Classes rather than trusting the model to be careful.

A minimal tool definition as returned by tools/list
1const searchRepository = {
2 name: 'search_repository',
3 description: 'Full-text search over code in one repository. Use for "where is X defined" questions. Returns up to 20 file paths with matching snippets.',
4 inputSchema: {
5 type: 'object',
6 properties: {
7 repo: { type: 'string', description: 'owner/name, e.g. acme/billing' },
8 query: { type: 'string', minLength: 2 },
9 language: { type: 'string', enum: ['ts', 'py', 'go'] },
10 },
11 required: ['repo', 'query'],
12 },
13 annotations: { readOnlyHint: true },
14}

Resources and prompts in detail

Resources are the RAG-shaped primitive: they let a host pull a document, a database row or a log excerpt into context without the model issuing a call. A file server might list file:///workspace/** and the IDE decides which open files to attach. Because the host controls it, resource loading belongs in Dynamic Context Assembly, not in the agent loop.

Prompts package a workflow the server author knows well. A database server might ship explain_slow_query(query_id) which fetches the plan as a resource and wraps it with instructions. They are reusable starting points, not something the model discovers and invokes on its own.

  • Resource templates (github://{owner}/{repo}/issues/{id}) let servers expose whole namespaces without enumerating every item.
  • Subscriptions (resources/subscribe) push change notifications so the host can refresh context instead of polling.
  • Capability negotiation at startup tells the client which of the three a server supports (MCP Lifecycle: Init, Discovery, Invocation).

When to use — and when not to

Use it when
  • Expose an action the model must decide on at runtime → tool.
  • Expose data the application should attach deterministically → resource.
  • Package a repeatable, human-initiated workflow → prompt.
Avoid it when
  • Do not model bulk data access as a tool; a 5 MB tool result wrecks the context budget — use a resource with pagination.
  • Do not expose 40 near-duplicate tools; consolidate behind fewer, well-described ones.
  • Do not rely on prompts for anything security-relevant — they are convenience, not control.

Failure modes

Reference · show
  • Vague tool descriptions ("Search things") cause misrouting between similar tools.
  • Resources without size limits push the host over its token budget (context-overflow-degradation).
  • Ignoring destructiveHint and letting the model call delete-class tools unattended.
  • Server returns tool results containing instructions that the model follows.

Check yourself

Answer out loud or on paper first, then compare. These come from the interview questions linked to this lesson.

  1. What problem does MCP solve compared with implementing every integration directly?

    Show a strong answer

    Without a protocol, every agent host has to implement every integration: M hosts × N services, each with its own tool definitions, auth handling, and result formatting. MCP splits this into a client (the host application) and servers that expose capabilities in a standard shape: tools (callable functions with JSON schemas), resources (readable data), and prompts (templates), with runtime discovery so the client learns what a server offers instead of hardcoding it. See MCP Overview and MCP Primitives: Tools, Resources, Prompts.

    The practical win is reuse and decoupling: a GitHub server written once works in any MCP-capable host; the integration lives in its own process with its own credentials, and can be updated independently. It also standardises the lifecycle: initialise, capability negotiation, tool listing, invocation, and errors. See MCP Lifecycle: Init, Discovery, Invocation.

    It does not make the model better at using tools. The model still sees tool names, descriptions, and schemas, and all the tool-design rules apply. It adds a process boundary and transport, which is latency and one more thing to operate.

    Full interview question, with follow-ups and red flags →
  2. How do you design a good tool schema for an LLM, and what makes a schema bad?

    Show a strong answer

    A tool schema is an API contract for a caller that only reads the docs. The name should be a verb phrase that describes one action (get_order_status, not orders). The description says when to use it and when not to, with an example. Parameters are typed narrowly: enum for fixed choices, format: date for dates, required set explicitly, and each parameter has a description with units and valid ranges. See Tool Schemas.

    Bad schemas are vague or overloaded: a single query: string that the model must format itself, optional parameters with hidden defaults, boolean flags that change semantics, or one tool that does five things depending on a mode field. Each of these pushes ambiguity onto the model and shows up as Argument Validation errors and wrong selections.

    The return shape matters as much: return structured, compact results with stable field names and explicit error objects ({ error: "not_found", id }) so the model can act on failure instead of guessing. And keep the tool count small; selection accuracy degrades as similar tools multiply.

    Full interview question, with follow-ups and red flags →
  3. A server exposes 60 tools. What do you do?

    Show a strong answer

    Filter to the subset the task needs before sending to the model; selection accuracy degrades with tool count.

    Full interview question, with follow-ups and red flags →