Tools: define one
A tool is a function the model can ask to run. MCP has official SDKs for TypeScript, Python, Go, Java, C# and more; these slides use the Python SDK.
1 Install
# with uv (recommended)uv add "mcp[cli]" # or with pippip install "mcp[cli]"mcpis the official SDK.[cli]adds themcpcommand used in step 3.2 Define a tool
server.pypythonfrom mcp.server import MCPServerfrom mcp.types import ToolAnnotations mcp = MCPServer( "calculator", instructions="Use these tools for exact arithmetic.",) @mcp.tool( title="Add numbers", annotations=ToolAnnotations(read_only_hint=True),)def add(a: int, b: int) -> int: """Add two numbers.""" return a + b if __name__ == "__main__": mcp.run() # stdio by default3 Run and test
mcp dev server.pyOpens the MCP Inspector, where you can try
addwith your own numbers and see the result.
Function nameModel sees it
The tool name: add.
DocstringModel sees it
The description the model reads.
Type hintsModel sees it
The input schema: a and b are integers.
titleHost only
A friendly name for app UIs.
annotationsHost only
Hints for the host, e.g. safe to run without asking.
instructionsHost decides
Server-wide guidance, sent once in the initialize result.