Tool Inputs
Type hints become schemas.
A tool's inputs are just function parameters. The SDK reads their type hints, and turns them into a JSON schema. The model then knows exactly what to send.

- Parameters
- Type hints
- JSON schema
A small test helper
To keep our examples short, we'll use a tiny helper file, called tester. Call connects a client to a server, calls one tool, and returns the result. Tools returns the server's list of tools. It's the same client code we've already seen, wrapped up.
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())From hints to schema
Search has a string, an integer, and a category that can only be bikes or parts. We print each input's schema. Run it. String, integer, and an enum with the two allowed values.
from typing import Literal
from mcp.server.mcpserver import MCPServer
from tester import tools
mcp = MCPServer("shop")
@mcp.tool()
def search(query: str, limit: int, category: Literal["bikes", "parts"]) -> list[str]:
"""Search Northwind's products."""
return [f"{category}: {query} {i}" for i in range(limit)]
for name, schema in tools(mcp)[0].input_schema["properties"].items():
print(name, "->", schema)query -> {'title': 'Query', 'type': 'string'}
limit -> {'title': 'Limit', 'type': 'integer'}
category -> {'enum': ['bikes', 'parts'], 'title': 'Category', 'type': 'string'}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())Python to JSON schema
Common Python types map to JSON schema types. String to string. Int to integer. Float to number. Bool to boolean. Lists become arrays, and Literal becomes an enum.
| Python | JSON schema |
|---|---|
| str | string |
| int / float | integer / number |
| bool | boolean |
| list[str] | array of strings |
| Literal['a','b'] | enum |
Summary
Type hints become the tool's input schema. Precise types, like Literal, stop the model sending bad values. Next, descriptions.
Key takeaways- Type hints
- JSON schema
- Literal = enum