Add a resource and a prompt to your MCP server

Day 4, 25 minutes · beginner

Goal of this lessonAdd an opening hours resource and a customer reply prompt to Romy's MCP server and read both with the MCP Inspector.

Why it matters

Tools are only one of the three building blocks of MCP. The other two are easy to skip, and that is a pity. A resource lets an app put fixed information in front of the model without a tool call, such as Romy's opening hours. A prompt gives the person a ready-made instruction, so every customer reply starts from the same good template instead of whatever someone types that day.

Today you add one resource and one prompt to Romy's server and read both with the Inspector. You also see the difference in who is in control: the model calls tools, the app reads resources, and the user picks prompts. At the end Romy's server offers all three building blocks, and you have checked each one.

The words you need today

  • Resource: read-only data a server offers, such as a file, a list or a set of facts. Each resource has a unique address.
  • URI: that address, written like a web address with its own scheme. Romy's opening hours live at quillfeather://opening-hours. The part before :// is just a name the server picks.
  • MIME type: a label for the kind of content, such as text/plain for plain text or application/json for JSON.
  • Prompt (in MCP): a named template with arguments. The user picks it, fills in the arguments, and the server returns the finished messages.
  • Argument: a value the user fills in for a prompt. Prompt arguments have no types: every value is sent as a string.

Who is in control

This is the most important table of the course, so here it is again, from the server concepts page:

Building block Controlled by In Romy's server
Tool The model check_stock, add_to_wishlist
Resource The application quillfeather://opening-hours
Prompt The user customer_reply

Model controlled means the model decides on its own when to call the tool. Application controlled means the app decides which resources to read and how: show them in a list, let the person pick one, or attach them on its own. User controlled means nothing happens until a person picks the prompt, for example from a slash command menu.

So the opening hours are a resource and not a tool. They do not change during a chat, and the app can attach them as context without asking the model to call anything.

How the SDK does it

The Python SDK uses two more decorators, next to @mcp.tool():

  • @mcp.resource("quillfeather://opening-hours", mime_type="text/plain") registers a function as a resource at that URI. Whatever the function returns is the content.
  • @mcp.prompt() registers a function as a prompt. The function name is the prompt name, the parameters become the arguments, and a parameter without a default is required. The SDK docs say a returned string becomes one user message.

Romy's prompt takes two arguments, customer and topic, and returns an instruction that tells the model to use the stock tool and the opening hours. Keep the topic to one word or a few words joined with hyphens, such as opening-hours or little-women. You will see why in lesson 6.

What the client asks for

The Inspector uses the same methods a host uses. resources/list shows which resources exist, resources/read with a --uri returns the content, prompts/list shows the prompts with their arguments, and prompts/get with arguments returns the finished messages. A host does not show you these calls, so the Inspector is the place to check that the text is what you meant.

The steps

  1. Add the resource with Romy's opening hours.
  2. Add the prompt for a customer reply.
  3. List and read the resource with the Inspector.
  4. List and get the prompt with real arguments.
  5. Write down which building block each part is and who controls it.

Follow the steps below.

Today's actions

Ticks are not saved without an account

Do it in Claude API

Claude API

  1. Paste this above the last two lines of quillfeather.py. It adds Romy's opening hours as a resource.
    OPENING_HOURS = """Quillfeather Books opening hours
    Monday: closed
    Tuesday to Friday: 10:00 to 17:30
    Saturday: 10:00 to 16:00
    Sunday: closed"""
    
    
    @mcp.resource("quillfeather://opening-hours", mime_type="text/plain")
    def opening_hours() -> str:
        """The shop's opening hours, for the AI application to read as context."""
        return OPENING_HOURS
  2. Paste this below it, still above the last two lines. It adds the customer reply prompt.
    @mcp.prompt()
    def customer_reply(customer: str, topic: str) -> str:
        """Draft a short, friendly reply to a customer, in Romy's style."""
        return (
            "You help Romy, who runs Quillfeather Books, a small second-hand book shop. "
            f"Write a short, friendly reply to {customer}, who asked about: {topic}. "
            "Use the check_stock tool for any book title, and the opening hours resource "
            "for questions about when the shop is open. If a book is sold out, offer to "
            "put it on the wish list. Sign the reply as Romy."
        )
  3. List the resources. You should see opening_hours with the uri quillfeather://opening-hours and the mimeType text/plain.
    npx @modelcontextprotocol/inspector --cli uv run quillfeather.py --method resources/list
  4. Read the resource. The result has a contents list with the opening hours as text.
    npx @modelcontextprotocol/inspector --cli uv run quillfeather.py --method resources/read --uri quillfeather://opening-hours
  5. List the prompts. You should see customer_reply with two required arguments, customer and topic.
    npx @modelcontextprotocol/inspector --cli uv run quillfeather.py --method prompts/list
  6. Get the prompt with arguments. The result is one message with the role user and the finished text, with Hugo and little-women filled in. Copy that text into mcp-notes.txt.
    npx @modelcontextprotocol/inspector --cli uv run quillfeather.py --method prompts/get --prompt-name customer_reply --prompt-args customer=Hugo topic=little-women
  7. In mcp-notes.txt, write next to check_stock, add_to_wishlist, the opening hours and customer_reply whether the model, the application or the user controls it.

Note: Your full quillfeather.py now ends with the prompt and then the two lines with mcp.run. In the web client from lesson 3, the same parts show up in the Resources and Prompts tabs.

Checked on 4 December 2026 · Source: MCP docs: Inspector CLI client (opens in a new tab)

Create a free account to save your progress. Sign in or sign up