In the tool use lessons you described every tool by hand, in a dictionary, and only your own program could use it. An MCP server packages tools once. Then any AI app that speaks MCP (Claude Desktop, Claude Code, an IDE) can connect to it, ask which tools it has, and call them.
On an MCP server, a tool is a plain Python function under the decorator @mcp.tool(). You write no schema: the function's name becomes the tool's name, its type hints become the input schema, and its docstring (a string alone on the first line of the function) becomes the description. Here is a small calculator server:
mcp = MCPServer("calculator")
@mcp.tool()
def add(a: int, b: int) -> int:
"Add two whole numbers."
return a + b
mcp.run()
The hints do real work. Because of a: int, the schema says that a must be an integer, and the server refuses a call that sends text there, before your function runs. The last line, mcp.run(), starts the server: the program then waits for a client to connect and answers its requests.
The check connects to your server as a client, lists its tools and calls lookup_order three times. It must print:
Server: corner-shop
Tools: 1
- lookup_order: Look up one order of the Corner Shop by its id: its date and status.
input: order_id (integer, required)
call lookup_order {"order_id": 4} -> ok: {"id": 4, "ordered": "2026-04-18", "status": "shipped"}
call lookup_order {"order_id": 40} -> ok: {"error": "Order not found"}
call lookup_order {"order_id": "four"} -> error: the server refused the input (it doesn't fit the tool's schema)
mcp.run() called: yes
Your task: the shop's function get_order is already written. Create an MCP server named "corner-shop", offer lookup_order as a tool that takes an order_id (a whole number) and returns what get_order finds, and start the server with mcp.run().
Assignment
Follow the Coding Tutorial to turn the shop's order lookup into a tool on an MCP server.
Hint
The decorator needs its parentheses: @mcp.tool(). The docstring is the first line inside the function, and mcp.run() goes at the very end of the file, with no spaces in front.
Free plan: 30 tutor messages. PRO is unlimited.
