learning-it by example

#332 AI agents and MCP 6.8 min

Inside an MCP Server: Tools, stdio and Errors

One toy, two dates: the same MCP tool said 3.16, then 3.17, because the date picked the schedule.

1. In the fees-demo MCP server (Python, made-up fees), where does the calculation live?
2. In the made-up fees-demo MCP server, calc_fees priced a 40 pound Toys and Games sale on 2026-10-20 and on 2026-11-13. What did it return for the fulfilment fee and the total?
3. In the fees-demo MCP server, what happened when a client called calc_fees with the misspelt category 'Toyz'?
4. Why does the fees-demo stdio MCP server have no print anywhere?
5. Why does the fees-demo engine use Decimal for money?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Call the engine on its own

    Copy the code folder first. The engine needs no MCP package. In the folder run python -c "from datetime import date; import engine; print(engine.fees(40, 'Kitchen', date(2026, 11, 13)))". Then change the date to 2026, 10, 20 and run it again. Say which values changed, which stayed the same, and why.

    A hint

    The date picks the schedule in force. I saw schedule 2026-11-02 with a total of 9.17, and then the July schedule.

  2. Add a third schedule

    In schedule.py add a third entry to SCHEDULES: {"version": "2027-01-01", "start": date(2027, 1, 1), "fuel": D("0.03")}. Predict the fulfilment fee for a 40 pound Toys and Games sale on 2026-12-31 and on 2027-01-01. Check with python -c using engine.fees and those dates.

    A hint

    The fee is 3.11 times one plus the fuel rate, rounded to pence. I saw 3.17 and 3.20.

  3. Add a category and see the error list

    Put the file back as it was or keep the new schedule. In schedule.py add "Books": D("0.1") to REFERRAL. Predict the fees for a 20 pound Books sale on 2026-11-13, and predict how the error message for the misspelt category 'Toyz' will change. Check both with python -c using engine.fees.

    A hint

    The referral is the price times the rate. I saw a total of 5.17 for Books, and the known list in the error became Books, Kitchen, Toys and Games.

  4. Read the schedule error

    In the folder run python -c "from datetime import date; import engine; engine.fees(40, 'Kitchen', date(2026, 6, 30))". Predict the last line of the error. Then read the pick function in schedule.py and explain why the date has no schedule. This mirrors the plain message the server would send to a client.

    A hint

    The earliest schedule starts on 2026-07-01. I saw the message 'No fee schedule covers 2026-06-30.'

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

Made-up, simplified fees and dates; a two-tool demo, not the owner's private eight-tool server; one client and one hand-written message on one machine; the by-hand message used an older protocol version string; no other clients or protocol versions were tried.

Up next in AI agents and MCP

More in AI agents and MCP

All AI agents and MCP videos

Related videos