Getting Started with Model Context Protocol By the end of this lesson, students should be able to: 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: 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. @app.list_resources() @app.read_resource() 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: Prompts are reusable, shareable instructions – they capture best-practice prompt patterns and make them invocable by name across applications. When to use which primitive. Enroll to continue this lesson. The preview above shows the lesson objectives and opening lesson content. Enroll to view the full lesson, complete the practice work, and take the lesson quiz.
Lesson 4: Resources and Prompts – The Other Two Primitives
Lesson Objectives
Lesson Content
file:///path/to/document.md)db://customers/12345)config://app/settings)
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"
)
]
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}")
