Lesson 1 - Step 3 of 5

Core Concepts

Learn about Tools, Resources, and Prompts — the three primitives of MCP.

The Three MCP Primitives

MCP servers can expose three types of capabilities to clients. Each serves a different purpose and is controlled differently:

diagram
┌─────────────────────────────────────────────────────────────┐
│                     MCP Server                              │
│                                                             │
│  ┌───────────────┐  ┌───────────────┐  ┌───────────────┐   │
│  │    TOOLS      │  │   RESOURCES   │  │    PROMPTS    │   │
│  │               │  │               │  │               │   │
│  │  Functions    │  │  Data/Files   │  │  Templates    │   │
│  │  AI can call  │  │  AI can read  │  │  Users choose │   │
│  └───────────────┘  └───────────────┘  └───────────────┘   │
│                                                             │
│  Model-controlled  App-controlled   User-controlled        │
└─────────────────────────────────────────────────────────────┘

1. Tools

Tools are functions that the AI model can execute. They're the most dynamic primitive — the AI decides when and how to use them.

Who Controls Tools?

Model-controlled. The LLM decides when to call a tool based on the conversation context. You provide the tools; the AI chooses to use them.

Example tool definition:

json
{
    "name": "get_weather",
    "description": "Get current weather for a city",
    "inputSchema": {
        "type": "object",
        "properties": {
            "city": {
                "type": "string",
                "description": "City name"
            }
        },
        "required": ["city"]
    }
}

When called, the server executes the function and returns a result:

json
{
    "content": [
        {
            "type": "text",
            "text": "San Francisco: 68°F, Sunny"
        }
    ]
}

Good for: Actions, computations, API calls, file operations.

2. Resources

Resources are data sources that provide context to the AI. Unlike tools (which are called), resources are attached to the conversation.

Who Controls Resources?

Application-controlled. The client application decides when to attach a resource to the context. For example, when you open a file in an IDE, it might attach that file as a resource.

Example resource definition:

json
{
    "uri": "file:///project/config.json",
    "name": "config.json",
    "description": "Application configuration",
    "mimeType": "application/json"
}

When read, the server returns the content:

json
{
    "contents": [
        {
            "uri": "file:///project/config.json",
            "mimeType": "application/json",
            "text": "{\"debug\": true, \"port\": 8080}"
        }
    ]
}

Good for: Files, database records, API responses, configuration.

3. Prompts

Prompts are pre-written templates that users can select. They're like slash commands — the user explicitly chooses them.

Who Controls Prompts?

User-controlled. The user selects a prompt from a menu or types a command. The AI doesn't autonomously decide to use prompts.

Example prompt definition:

json
{
    "name": "review_code",
    "description": "Review code for quality and suggest improvements",
    "arguments": [
        {
            "name": "code",
            "description": "The code to review",
            "required": true
        },
        {
            "name": "focus",
            "description": "What to focus on (security, performance, style)",
            "required": false
        }
    ]
}

When retrieved, it returns messages to send to the AI:

json
{
    "messages": [
        {
            "role": "user",
            "content": {
                "type": "text",
                "text": "Please review this code for quality:\n\ndef hello():\n    print('world')\n\nFocus on: style"
            }
        }
    ]
}

Good for: Workflows, templates, complex instructions.

Comparison Table

Aspect Tools Resources Prompts
Control Model Application User
Purpose Do things Provide data Guide interaction
Activation AI calls them App attaches them User selects them
Example Search files File contents Code review template
Which Should You Use?
  • Need to do something? Use a Tool.
  • Need to provide data? Use a Resource.
  • Need to guide behavior? Use a Prompt.