MCP: From Motivation to DeploymentLesson 06

MCP Beyond Tools: Add Resources and Prompts to Our Shopping Assistant

Extend a shopping MCP server with product resources and a reusable prompt, and see when the host passes each to Claude.

Product resource selected by the shopping host1 · Shopperchooses ID2 · Pythonhost3 · Productresource4 · Displayonly5 · Claudegets context

Stackfable · MCP series, Part 5
Following our previous articles on direct tool calling, creating an MCP server, connecting Claude through an MCP client, and working with multiple MCP servers.

The core idea

So far, we've treated MCP as a standardized way to discover and call tools. That covers product searches and stock checks, but not the user who just wants to browse the catalog or start the same recommendation workflow again. Tools are only one of three primary capabilities a server can expose.

TEXT
Tools      → Operations the model can ask the host to execute
Resources  → Data the application can select and read
Prompts    → Reusable message templates the user or application can select

Here's the difference in the smallest possible pseudocode:

PYTHON
# Tool: Claude can request execution in its tool_use response.
result = await mcp_client.call_tool("search_products", args)

# Resource: the host explicitly chooses which URI to read.
resource = await mcp_client.read_resource("shop://catalog")

# Prompt: the host explicitly chooses a template and fills its arguments.
prompt = await mcp_client.get_prompt(
    "recommend_keyboard", {"max_price": "100", "preference": "wireless"}
)

MCP exposes all three. It does not automatically inject resources or prompts into Claude. Our host decides whether to display a resource, include it in the model's context, or send a rendered prompt through the Claude Messages API.

We will extend the same fictional shopping assistant, not replace it. The existing search_products() and check_inventory() tools remain unchanged.

1. What are we adding to the shopping server?

Our current scenario is familiar:

Find a wireless mechanical keyboard under $100 and check whether the best match is in stock.

Previously, Claude discovered two tools and selected them as needed. Now imagine two additional interactions:

  • The user wants to browse the catalog without asking Claude to search for products.
  • The user wants to launch a reusable recommendation workflow without typing the entire set of instructions each time.

We'll add these MCP capabilities:

CapabilityMCP addressWhat it returns
Toolsearch_productsMatching products
Toolcheck_inventoryStock for one product
Static resourceshop://catalogSnapshot of catalog products
Resource templateshop://products/{product_id}Details for a selected product
Promptrecommend_keyboardA reusable shopping request with arguments

The catalog and product resource intentionally omit stock quantities. Inventory still comes from the inventory tool. This keeps the teaching example consistent and demonstrates that a resource is not a substitute for every tool.

2. First connection: a read-only resource

The course chapter introduced resources using a static URI and a URI template. We can use those two forms with our store.

A static resource

PYTHON
@mcp.resource("shop://catalog", mime_type="application/json")
def get_catalog() -> str:
    """Return a public snapshot of products (without stock)."""
    return json.dumps([...])

This isn't a tool schema. It exposes data at a URI. The host can address it by its URI instead of asking Claude to decide which function to run.

For example:

PYTHON
result = await mcp_client.read_resource("shop://catalog")

At the MCP protocol layer, this sends resources/read with the URI shop://catalog. The server executes the resource handler and returns its content. No Anthropic API call is involved.

A parameterized resource

PYTHON
@mcp.resource("shop://products/{product_id}", mime_type="application/json")
def get_product(product_id: str) -> str:
    """Return details for one product ID."""
    ...

The {product_id} placeholder means this is a resource template. It represents a family of addresses, for example:

TEXT
shop://products/kb-101
shop://products/kb-102

The client supplies a concrete URI when it reads one:

PYTHON
result = await mcp_client.read_resource("shop://products/kb-101")

The SDK extracts the product_id from the URI and invokes the resource function with that argument.

Static resources and templates are discovered separately

This detail matters in the modern Python SDK:

PYTHON
static = await mcp_client.list_resources()
templates = await mcp_client.list_resource_templates()

print([str(r.uri) for r in static.resources])
# ['shop://catalog']

print([t.uri_template for t in templates.resource_templates])
# ['shop://products/{product_id}']

Why two calls? shop://catalog is already a readable address. shop://products/{product_id} is only a pattern; it must be filled with an ID before reading.

Important: This result returns to our Python host. It is not sent to Claude automatically. We can print it as a direct lookup, or explicitly include it in a later Claude request.

3. Second connection: reusable prompts

The MCP server can also publish a prompt template. For our store, let's provide a workflow with a maximum price and a preference:

PYTHON
@mcp.prompt()
def recommend_keyboard(max_price: str = "100", preference: str = "wireless") -> str:
    """Prepare a shopping request with a budget and connection preference."""
    return (
        f"Find a {preference} mechanical keyboard for at most ${max_price} in our store. "
        "Use search_products to find matches, then check_inventory for your best match. "
        "Explain the recommendation briefly. Do not invent prices or inventory."
    )

The server registers this as a prompt named recommend_keyboard. It infers its argument definitions from the Python signature. Note the arguments are strings: MCP prompt arguments are string-valued, even for values like "100" that represent a number. When Claude later requests search_products, it supplies the tool's own numeric max_price argument.

The host first discovers prompts:

PYTHON
listed = await mcp_client.list_prompts()
print([p.name for p in listed.prompts])
# ['recommend_keyboard']

Then it requests the rendered prompt:

PYTHON
rendered = await mcp_client.get_prompt(
    "recommend_keyboard",
    {"max_price": "100", "preference": "wireless"},
)

This sends prompts/get to the MCP server. The server returns prompt messages, not the result of an LLM inference.

To make Claude act on the prompt, our host must explicitly send those messages using the Claude Messages API:

PYTHON
# Conceptual bridge: MCP prompt messages → Claude message history
messages = adapt_prompt_messages(rendered.messages)
response = await claude.messages.create(
    model=MODEL,
    max_tokens=1024,
    tools=available_tools,
    messages=messages,
)

Now Claude sees the rendered request, can decide to use search_products(), and our existing tool loop takes over.

Why a prompt isn't a tool

get_prompt(...) is a host-initiated MCP request, not a Claude tool_use request. Claude didn't choose to retrieve the prompt; the user or our application did. Only after we send the rendered prompt to Claude does its tool-selection behavior begin.

4. Putting the capabilities into our CLI

The course uses / commands for prompts and @ shortcuts for resources. Those are application UI conventions, not reserved MCP protocol syntax. We'll keep them because they make the distinction visible.

User inputWhat Python doesDoes Claude run?
@catalogread_resource("shop://catalog"), display contentNo
@product/kb-101Read shop://products/kb-101, display contentNo
/promptsList prompt names and argumentsNo
/prompt recommend_keyboard max_price=100 preference=wirelessget_prompt, then send returned messages to ClaudeYes
/askproduct kb-101 Is this under $100?Read resource, then explicitly add its content to Claude's inputYes
Ordinary user questionClaude decides whether to request toolsYes

Here's the important dispatch structure, as pseudocode:

PYTHON
if user_input == "@catalog":
    resource = await mcp_client.read_resource("shop://catalog")
    print(resource_content(resource))

elif user_input.startswith("/prompt "):
    rendered = await mcp_client.get_prompt(name, arguments)
    messages = adapt_prompt_messages(rendered.messages)
    print(await run_claude(messages))

else:
    print(await run_claude([{"role": "user", "content": user_input}]))

Note that @product/... does not magically put product information into Claude's context. The added /askproduct command demonstrates the extra application step required to do that.

Tracing @product/kb-101 versus /askproduct kb-101 ...

This is the central distinction: MCP gives our host access to data, but the host controls when that data is actually supplied to the model.

5. What's different from our previous MCP client?

We aren't rewriting the Claude tool-calling loop. Its structure remains:

PYTHON
response = await claude.messages.create(...)

while response.stop_reason == "tool_use":
    for block in response.content:
        if block.type == "tool_use":
            result = await mcp_client.call_tool(block.name, block.input)
            # Append matching tool_result to conversation
    response = await claude.messages.create(...updated_messages...)

The new logic lives before or alongside that loop:

PYTHON
resources = await client.list_resources()
templates = await client.list_resource_templates()
prompts = await client.list_prompts()

# User-selected content:
resource = await client.read_resource("shop://catalog")
rendered_prompt = await client.get_prompt("recommend_keyboard", args)

Our original tool schemas, dispatcher through call_tool(), messages.append(), and loop-exit logic do not fundamentally change.

For continuity with Part 4: we can extend the same multi-server host so each resource URI and prompt name maps to the client that owns it. Here we use the shopping server alone to isolate and understand the new two primitives before adding multi-server routing for resources and prompts. The official filesystem server from Part 4 is not needed to teach this chapter.

6. Companion project layout

TEXT
stackfable_mcp_l7/
├── shopping_server.py  # Same two tools + 2 resources + 1 prompt
├── mcp_client.py       # CLI commands + Claude loop
├── inspect_features.py # MCP-only check, no Claude API key needed
├── products.json
└── requirements.txt

Install the current Python SDK v2 and Anthropic SDK using Python 3.11+:

BASH
python -m pip install -r requirements.txt

# First inspect resources and prompts without a Claude API call
python inspect_features.py

# Then run the full chatbot
export ANTHROPIC_API_KEY="your_api_key_here"
python mcp_client.py

The companion project files are not linked yet. Here is the complete server, including both our preexisting tools and the new capabilities; the client methods below are excerpts rather than a complete runnable client.

shopping_server.py

PYTHON
"""Stackfable shopping MCP server: tools, resources and prompts (SDK v2)."""
import json
from pathlib import Path
from mcp.server import MCPServer

mcp = MCPServer("stackfable-shop")
CATALOG = Path(__file__).with_name("products.json")


def load_products() -> list[dict]:
    return json.loads(CATALOG.read_text(encoding="utf-8"))


# TOOLS: Claude can request these. The host executes tool calls over MCP.
@mcp.tool()
def search_products(query: str, max_price: float) -> list[dict]:
    """Search products by keyword and USD maximum price; omit stock."""
    words = query.lower().split()
    matches = []
    for p in load_products():
        searchable = f"{p['name']} {p['category']} " + ("wireless" if p["wireless"] else "wired")
        if p["price"] <= max_price and all(w in searchable.lower() for w in words):
            matches.append({key: p[key] for key in ("id", "name", "price", "wireless")})
    return matches


@mcp.tool()
def check_inventory(product_id: str) -> dict:
    """Look up stock for an exact catalog product ID."""
    for p in load_products():
        if p["id"] == product_id:
            return {"product_id": product_id, "in_stock": p["stock"] > 0, "quantity": p["stock"]}
    return {"product_id": product_id, "error": "Product not found"}


# RESOURCES: the host chooses when to read these; they are not tool calls.
@mcp.resource("shop://catalog", mime_type="application/json")
def get_catalog() -> str:
    """Read a current public snapshot of the fictional product catalog."""
    return json.dumps([{
        "id": p["id"], "name": p["name"], "price": p["price"], "wireless": p["wireless"]
    } for p in load_products()], indent=2)


@mcp.resource("shop://products/{product_id}", mime_type="application/json")
def get_product(product_id: str) -> str:
    """Read one product's public details by product ID (resource template)."""
    for p in load_products():
        if p["id"] == product_id:
            return json.dumps({k: p[k] for k in ("id", "name", "category", "price", "wireless")}, indent=2)
    return json.dumps({"error": "Unknown product ID", "product_id": product_id})


# PROMPTS: selected by a user or host; they render reusable model messages.
@mcp.prompt()
def recommend_keyboard(max_price: str = "100", preference: str = "wireless") -> str:
    """Prepare a shopping request with an explicit budget and connection preference."""
    return (
        f"Find a {preference} mechanical keyboard for at most ${max_price} in our store. "
        "Use search_products to find matching products, then check_inventory for your best match. "
        "Explain the recommendation briefly. Do not invent prices or inventory."
    )


if __name__ == "__main__":
    mcp.run(transport="stdio")

Client methods to focus on

When the companion project is available, these are the mcp_client.py methods worth reading first:

PYTHON
# Discovery at startup
await client.list_tools()
await client.list_resources()
await client.list_resource_templates()
await client.list_prompts()

# User-selected resource retrieval
await client.read_resource("shop://catalog")
await client.read_resource("shop://products/kb-101")

# User-selected prompt rendering
await client.get_prompt(
    "recommend_keyboard", {"max_price": "100", "preference": "wireless"}
)

# Model-selected tool execution — unchanged from the previous article
await client.call_tool(block.name, block.input)

The client uses TextResourceContents and TextContent checks rather than assuming every MCP content block contains .text. In a richer application you would handle binary and mixed content blocks appropriately.

7. End-to-end example

Run the chatbot, then try:

TEXT
> @catalog
# Python displays catalog resource; Claude not called.

> @product/kb-101
# Python displays the selected product's data.

> /prompts
# Python displays recommend_keyboard and its arguments.

> /prompt recommend_keyboard max_price=100 preference=wireless
# MCP server renders the prompt; Python passes it to Claude.
# Claude can then request search_products and check_inventory.

> /askproduct kb-101 Is this keyboard below $100?
# Python reads the product resource, injects it into the question,
# and calls Claude explicitly.

This is a planned interaction, not a captured execution log. The exact tool calls chosen by Claude are not guaranteed. The MCP SDK and model API dependencies must be installed to run the project.

8. What the latest MCP SDK changes—and what it doesn't

The Lesson 7 notebook uses FastMCP from SDK v1 and explicitly pins mcp>=1.2,<2. For this article we target the current Python SDK v2 and MCP 2026-07-28 specification.

The teaching concepts remain intact: @mcp.resource("uri"), resource templates, @mcp.prompt(), resources/read, and prompts/get. The modern high-level server is MCPServer rather than FastMCP; the modern client exposes methods directly through Client rather than requiring us to write a manual ClientSession initialization sequence. The latest protocol removes the old mandatory initialization handshake, but resources and prompts are still application-selected data and message templates. Those facts don't change with the transport or protocol revision.

One implementation detail to retain: the 2026-07-28 SDK exposes static resources via list_resources() and templates via list_resource_templates(). For prompts, get_prompt() returns messages that the host can choose to pass to Claude; it doesn't itself initiate LLM inference.

9. Tradeoffs and next steps

Tools, resources, and prompts are easy to conflate because all three are exposed by an MCP server. Use this decision rule:

  • If the model should decide whether to execute an operation, expose a tool.
  • If the host should select contextual data by URI, expose a resource.
  • If a user or host should select reusable instructions, expose a prompt.

Resources are intended as data retrieval, not as unrestricted execution endpoints. In production, apply authorization even to read-only resources, validate URI parameters, avoid leaking sensitive records, and treat returned resource text as untrusted data rather than instructions. Likewise, treat prompt templates from an untrusted third-party server as untrusted instructions; a host should review and control which templates it presents or executes.

Mental model: A tool returns a result of work Claude requested. A resource returns data the application requested. A prompt returns messages the application can choose to send to Claude.

This completes the three basic MCP primitives on a familiar running example. A natural follow-up is combining prompts and resources from multiple MCP servers, reusing the multi-server routing hub from Part 4 without changing these primitives.

Knowledge check

A user enters @product/kb-101, then asks Claude whether that keyboard costs less than $100. What must the host do for Claude to answer using the product resource?
The user starts /prompt recommend_keyboard with a $100 budget. Which sequence lets Claude decide whether to search and check inventory?
The host has discovered shop://products/{product_id} and needs details for kb-101. What should it request?

References

Course reference: DeepLearning.AI, Lesson 7, “Adding Prompt & Resource Features” (supplied notebook). The approach to commands and the progression from tools to resources and prompts is informed by that lesson; the fictional shopping example and code are independently authored for Stackfable.

Related Posts

Shopping inventory call through a remote MCP server1 · Shoppinghost2 · MCPclient3 · Remoteserver4 · ProductcatalogHTTPS /mcp

Deploy a Remote MCP Server: Streamable HTTP, Cloudflare, AWS, and Capacity Planning

  • Stackfable
  • 08 Nov 2026

Move a shopping MCP server from local stdio to remote HTTP, compare deployment options, and estimate the capacity it needs.

Read More: Deploy a Remote MCP Server: Streamable HTTP, Cloudflare, AWS, and Capacity Planning
A shopping request routed to two MCP servers1 · Keyboardrequest2 · Pythonhost3 · Shopsearch + stock4 · Notessave file

Connecting One MCP Client to Multiple Servers: Build a Shopping Assistant That Can Save Notes

  • Stackfable
  • 08 Nov 2026

Connect a shopping assistant to separate shopping and filesystem MCP servers, then discover and route their tools through one Python host.

Read More: Connecting One MCP Client to Multiple Servers: Build a Shopping Assistant That Can Save Notes
Shopping tool request through an MCP client1 · Clauderequest2 · Pythonhost3 · MCPclient4 · Shopserver5 · result to Claude

From MCP Server to MCP Client: Connect Our Shopping Assistant to Claude

  • Stackfable
  • 08 Nov 2026

Connect a shopping MCP server to Claude by discovering tools, routing tool calls, and returning results through a Python host.

Read More: From MCP Server to MCP Client: Connect Our Shopping Assistant to Claude