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. “`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: 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 | 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. 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.
Lesson 4: Resources and Prompts – The Other Two Primitives
Lesson Objectives
Lesson Content
file:///path/to/document.md)db://customers/12345)config://app/settings)Practical Example
Safety Notes