daBongo LMS AI Training Courses

Getting Started with Model Context Protocol

Lesson 4: Resources and Prompts – The Other Two Primitives

Lesson Objectives

By the end of this lesson, students should be able to:

  • Explain what MCP resources are and when to expose data as a resource vs. a tool
  • Explain what MCP prompts are and how they differ from tool definitions
  • Implement a resource handler in an MCP server
  • Implement a prompt definition in an MCP server

Lesson Content

Resources – data, not functions.

Resources expose data for reading. A resource is identified by a URI and returns content when requested. Unlike tools (which execute a function), resources provide data that Claude or the user can read.

Examples of data appropriate for resources:

  • A file or document (e.g., file:///path/to/document.md)
  • A database record (e.g., db://customers/12345)
  • A configuration object (e.g., config://app/settings)

When to use a resource vs. a tool: if the primary operation is reading static or semi-static data – use a resource. If the operation executes a function, makes a decision, or modifies state – use a tool.

Resource implementation pattern.

“`python @app.list_resources() async def list_resources() -> list[types.Resource]: return [ types.Resource( uri="docs://api-reference", name="API Reference", description="The full API reference documentation", mimeType="text/markdown" ) ]

@app.read_resource() async def read_resource(uri: str) -> str: if uri == "docs://api-reference": return Path("api_reference.md").read_text() raise ValueError(f"Unknown resource: {uri}") “`

Prompts – reusable instruction templates.

Prompts are pre-defined instruction templates that users or AI clients can invoke by name. They produce a configured message ready to send to Claude – with or without dynamic parameters.

Examples:

  • A code review prompt template with customizable language parameter
  • A summarization prompt with configurable length and format parameters
  • A debugging prompt template parameterized for error type

Prompts are reusable, shareable instructions – they capture best-practice prompt patterns and make them invocable by name across applications.

When to use which primitive.

| Primitive | Primary Use | Returns | |———–|————-|———| | Tool | Execute functions, take actions, retrieve dynamic data | Result of execution | | Resource | Expose static or semi-static data for reading | Document content | | Prompt | Provide reusable instruction templates | Configured message |

Practical Example

A developer builds an MCP server for a documentation system.

She implements: a search_docs tool (executes a search query – function invocation), a docs://getting-started resource (the static getting-started guide – data reading), and a explain_error prompt template (takes an error code parameter and produces an explanation request – reusable instruction).

One server, three primitives, each appropriate for its use case.

Safety Notes

Resources expose data from your systems to Claude. For resources that contain sensitive information (personal data, proprietary content, credentials), implement access control in the resource handler – verify that the requesting client/user has permission to read the resource before returning its content. The MCP protocol does not include built-in access control; it must be implemented in the server.

Log in and enroll to access lesson quizzes.

Scroll to Top