DS DevShelfHub Projects · AI tools
Tutorials / MCP / Resources & Prompts
MCP Intermediate · 7 min read Page 8 of 23

MCP Resources and Prompts

By DevShelfHub

Go beyond tools. Learn how to expose data with Resources and standardise workflows with Prompts.

Series progress8 / 23
MCP resources and prompts tutorial — MCP Resources and Prompts

📚 Resources: Exposing data

Resources let you provide data to Claude without requiring a function call. The Host automatically includes resources in the model's context.

Types of resources

Static resources

Fixed data that doesn't change. Example: company documentation, a knowledge base entry, or API reference.

Dynamic resources

Data that changes. Example: current file contents, database records, or recent Git commits. Fetched on-demand.

URI-templated resources

Parameterised resources. Example: file://{path} — Claude can request any file by path.

Implementing resources

python
from mcp.types import Resource, TextContent

@server.read_resource()
def read_resource(uri: str):
    if uri == "docs://readme":
        return TextContent(
            type="text",
            text="# My Project\nThis is the README..."
        )
    return None

# Register the resource
server.resources = [
    Resource(
        uri="docs://readme",
        name="README",
        description="Project documentation"
    )
]

💬 Prompts: Reusable instructions

Prompts are parameterised instruction templates. Think of them as "use cases" that Claude can invoke to run standardised workflows.

python
from mcp.types import Prompt

@server.get_prompt()
def get_prompt(name: str, arguments: dict):
    if name == "code_review":
        code = arguments.get("code", "")
        return (
            "Review this code for best practices:\n"
            f"```\n{code}\n```\n\n"
            "Provide constructive feedback."
        )
    return None

server.prompts = [
    Prompt(
        name="code_review",
        description="Review code for best practices",
        arguments=[
            {
                "name": "code",
                "description": "The code to review"
            }
        ]
    )
]

When to use Resources vs Prompts

Resources Prompts
Purpose Provide data to reference Standardise workflows
When Claude uses it Automatically, to provide context When explicitly invoked
Example Company knowledge base, file contents Code review template, customer support classifier

Quick summary

  • Resources provide data Claude can reference (static or dynamic)
  • Prompts are reusable instruction templates with parameters
  • Combine Tools, Resources, and Prompts to build powerful, flexible servers
  • Next: real-world examples where all three work together

MCP Resources & Prompts FAQ

What is an MCP Resource?

An MCP Resource is a named piece of data a server exposes via a URI — files, database rows, API results, live feeds. The application (not the model) decides when to include resource content in context.

What is an MCP Resource Template?

An MCP Resource Template is a URI pattern (using RFC 6570 template syntax) that generates multiple resources from a single declaration. For example, file:///{path} lets clients request any file by filling in the path variable.

Can MCP Resources be subscribed to for live updates?

Yes, if the server declares the subscribe capability. Clients can subscribe to a resource URI and receive notifications/resources/updated events whenever the content changes.

What is an MCP Prompt?

An MCP Prompt is a reusable conversation template that a user or application can invoke. It accepts named arguments and returns a pre-filled message list, making it easy to standardise common workflows like code review or bug report generation.

How do Resources differ from Tools in MCP?

Tools are model-controlled — the AI decides when to call them. Resources are application-controlled — the host or client decides when to include resource content in the AI's context. Resources are for reading data; tools are for performing actions.

Quick jump: API Reference