How do MCP decorators turn Python functions into tools?
Defining MCP Tools with the Python SDK
Audio flashcard · 0:31Nortren·
How do MCP decorators turn Python functions into tools?
0:31
The SDK uses decorators to register tools. Instead of writing JSON schemas manually, you apply a decorator named mcp dot tool to a regular Python function. The decorator marks that function as an MCP tool. The function name becomes the tool's name. The function's docstring becomes the tool's description that Claude reads when deciding whether to use it. The function's parameters, with their Python type hints, become the tool's input schema. And if you add Pydantic Field annotations to those parameters, the descriptions you provide become argument descriptions that help Claude understand exactly what each parameter expects.
github.com