MCP server project · Chapter 5 of 12
Prompts
By the end of this chapter your server offers two ready-made requests a member picks in their assistant: plan_my_week, which writes a week of lunch plans with the zone's real menu in it, and repeat_order, which books an earlier order again. Both refuse bad arguments with a sentence the member can act on, never a bare internal error. 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
Every Sunday evening in October, members asked their assistants to plan the week's lunches, each in their own words. Bhavna counted 23 such plans, and 9 went wrong: a dish that Thane Kitchen does not cook, a Jain day with an onion dish, a plan booked before the member had seen it, and two assistants that tried to pay at once. The words were different every time, and each assistant guessed the menu.
Farah wants one request, written once by DabbaDrop: "plan my week", with today's menu inside it and the rules spelled out (show the plan first, book only after a yes, never pay). Tara should pick it from a list, fill in her zone and her diet, and send it.
Tools and resources cannot do that. A tool is chosen by the model and a resource by the app. Nobody asks the member. MCP's third kind of thing, the prompt, is the one the member chooses.
What you build: 3 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
prompts.py: plan_my_week
Register the prompt plan_my_week(zone, diet="veg", days="5") in add_prompts (title Plan my week of dabbas, with a docstring). It returns one UserMessage: the line "Plan my lunch dabbas for <n> weekdays, <first> to <last>, delivered to <zone>. I eat <diet> food: choose only <diet> dishes, a different one each day.", an empty line, the zone's menu from menu_markdown, then the line that tells the assistant to show the plan first, book with find_slots and place_order once the member says yes, and never pay. The days are the next weekdays after mcp_settings.today, written like Mon 02 Nov.
The Check lists the prompts through an MCP client (plan_my_week with zone required, diet and days optional) and gets plan_my_week for Thane, Jain, 3 days (Mon 02 Nov to Wed 04 Nov, with Thane's menu), and with only a zone (5 days of veg).
- Task 2
prompts.py: repeat_order
Register the prompt repeat_order(order_id) in add_prompts (title Order this again). From the member's orders (GET /orders/me), it returns a UserMessage "Book my order <id> again: <items>. Ask me which day and time I want." and an AssistantMessage "Happy to. Order <id> was <items>. Which day, and which time: 12:00, 12:30 or 13:00?", where items is "<quantity> x <name> (dish <dish_id>)" per item, joined with ", ".
The Check gets repeat_order for Advait's order 1 as Advait (Dal Tadka and four Roti) through an MCP client.
- Task 3 · interview question
Interview: prompts.py, arguments are text
In both prompts, refuse bad arguments first with raise bad_argument(sentence): plan_my_week's zone not in ZONES ("zone must be one of: ..."), diet not in DIETS ("diet must be one of: ..."), days not a whole number from 1 to 5 ("days must be a whole number from 1 to 5"); repeat_order's order_id not digits ("order_id must be a number, like 2") or not the member's ("You have no order <order_id>").
The Check gets the prompts with a zone of Powai, a diet of vegan, days of "five", "9" and "0", an order_id of "two", and Advait's order 1 asked for as Tara: each must be error -32602 with your sentence.
Kunal will ask: who picks a prompt, the model, the app or the member? And why does days arrive as "5", not 5?
What you will learn
- Prompts and who picks them: the member, from a list (often a slash command).
- prompts/list and prompts/get on the wire: arguments, required or not, and the messages that come back.
- User and assistant messages, and why a prompt may return both.
- Arguments are always text: what the protocol allows, and what happens to a typed int.
- bad_argument: error -32602 with your sentence, against a bare internal error.
More in What the server offers
Build "Prompts" 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.