MCP · Lesson 14 of 120
Good Descriptions
Docstrings matter.
The model chooses tools by reading their descriptions. A vague description means wrong choices. And each input can have its own description too, using Pydantic's Field.

- Models read descriptions
- Vague means wrong
- Describe each input
Describing inputs
The docstring describes the whole tool. Annotated with Field adds a description to one input. We print both. Run it. The tool description, and the order ID's own description, both reach the client.
descriptions.pypython
from typing import Annotated
from pydantic import Field
from mcp.server.mcpserver import MCPServer
from tester import tools
mcp = MCPServer("shop")
OrderId = Annotated[int, Field(description="The 4-digit number on the receipt")]
@mcp.tool()
def order_status(order_id: OrderId) -> str:
"""Look up the delivery status of one Northwind order."""
return "shipped"
tool = tools(mcp)[0]
print("tool: ", tool.description)
print("input:", tool.input_schema["properties"]["order_id"]["description"])Output
tool: Look up the delivery status of one Northwind order. input: The 4-digit number on the receipt
Also uses tester.py
import asyncio
from mcp import Client
def call(server, tool, args=None, **options):
async def go():
async with Client(server, **options) as client:
return await client.call_tool(tool, args or {})
return asyncio.run(go())
def tools(server):
async def go():
async with Client(server) as client:
return (await client.list_tools()).tools
return asyncio.run(go())Vague or clear
A vague description, like get data, leaves the model guessing. A clear one says what it does, what goes in, and when to use it.
Vague
- get dataid: intNo hints
Clear
- Delivery status of one order4-digit number on the receiptWhen to use it
Summary
Write clear docstrings, and describe each input with Field. They're the model's only guide. Next, defaults and optional inputs.
Key takeaways- Docstring
- Field(description=...)
- Be specific
Next up: Defaults and Optional Inputs — sensible defaults