MCP server project · Chapter 4 of 12

Resources

By the end of this chapter your server offers data as well as actions: today's menu for any zone at dabbadrop://menu/{zone}, DabbaDrop's eight help pages at dabbadrop://help and dabbadrop://help/{page}, and the member's own orders at dabbadrop://me/orders. The assistant's app reads them, a name that is not there gets a clear error, and no name can reach a file outside the help folder. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.

  • Part: What the server offers
  • 3 tasks
  • Python
  • In the all labs plan

The first 2 chapters of MCP server project are free. This one comes with the all labs plan.

Why you need this

In October Bhavna's team answered 41 complaints about things an assistant had said wrongly about DabbaDrop itself. One told Tara that delivery costs ₹40 (last year's charge; the help page has said ₹30 since 1 October). One offered a Jain Thali from Dadar Kitchen, which cooks no Jain dish. Each of the 4 integrations kept its own copy of the menu and the help text, pasted into its prompt, and nobody updated them.

Farah wants one copy, read live: the menu from the kitchens' own dishes, the help pages from the files the support team edits.

Your server cannot offer that yet. It has four tools, and a tool is an action the model decides to call in the middle of a conversation. A help page is not an action. Tara's app may want to put the Thane menu in front of the model before it says a word, or show it to Tara herself. MCP has a second kind of thing a server offers for exactly that: a resource.

What you build: 3 tasks

Each task has tests. You write the code in the lab's editor and press Check.

  1. Task 1

    resources.py: the menu

    Write menu_markdown(zone) in mcp_server/resources.py and register the template dabbadrop://menu/{zone} in add_resources (name menu, title Today's menu, mime type text/markdown) returning it. zone is a slug like andheri-west; the Markdown is "# Menu for <zone> (<kitchen>)", then for each diet in HEADINGS that has dishes, an empty line, "## <heading>", an empty line and "- <name>: ₹<price> (dish <id>)" per dish, every line ended by a newline. An unknown slug raises ResourceNotFoundError "No zone <zone>. Zones: <the six slugs>".

    The Check lists the resource templates through an MCP client, reads Thane's and Goregaon's menus, compares them with the kitchens' dishes in the database, and reads dabbadrop://menu/powai (error -32602 with your message).

  2. Task 2

    resources.py: the help pages

    Register dabbadrop://help (name help, title Help pages, text/markdown) and dabbadrop://help/{page} (name help_page, title A help page, text/markdown) in add_resources. The first is "# DabbaDrop help", an empty line, and "- <title>: dabbadrop://help/<stem>" per page of HELP, sorted, each line ended by a newline. The second is the page's text; a page that does not match PAGE, or has no file, raises ResourceNotFoundError "No help page <page>. dabbadrop://help lists them."

    The Check lists the resources through an MCP client, reads the index and every page it lists, and reads a page that does not exist and one with dots and slashes in its name.

  3. Task 3 · interview question

    Interview: resources.py, the member's orders

    Register dabbadrop://me/orders (name my_orders, title My orders, mime type application/json) in add_resources: GET /orders/me as the member, order_of each, as json.dumps of their model_dump(), indent 2, ensure_ascii False.

    The Check places an order as Tara, then reads dabbadrop://me/orders as Tara (order 2) and as Advait (order 1, his alone).

    Kunal will ask: list_my_orders is a tool and dabbadrop://me/orders is a resource, with the same data. Who asks for each one, and why have both?

What you will learn

  • Tools, resources and who decides: the model calls a tool; the app reads a resource.
  • resources/list, resources/templates/list and resources/read on the wire, and what a reply's contents hold.
  • A URI per resource, and a template ({zone} in braces) for a family of them.
  • Mime types: text/markdown, application/json, and what they tell the app.
  • ResourceNotFoundError: error -32602 with your sentence, not a bare internal error.
  • A template value is input: why it is checked before it becomes a file path.

More in What the server offers

Build "Resources" yourself

DabbaDrop wants AI assistants like Claude Desktop to order for its members, safely. You build the MCP server that lets them, and only as the member who allowed it. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.

The first 2 chapters of MCP server project are free. This one comes with the all labs plan.