Handler Template
Handler Parameters
SamplingParams
Optional system prompt the server wants to use
Server preferences for model selection (hints, cost/speed/intelligence priorities)
Sampling temperature
Maximum tokens to generate
Stop sequences for sampling
Tools the LLM can use during sampling
Tool usage behavior (
auto, required, or none)Built-in Handlers
FastMCP provides built-in handlers for OpenAI, Anthropic, and Google Gemini APIs that support the full sampling API including tool use.OpenAI Handler
Install the OpenAI handler with
pip install fastmcp[openai].Anthropic Handler
Install the Anthropic handler with
pip install fastmcp[anthropic].Google Gemini Handler
Install the Google Gemini handler with
pip install fastmcp[gemini].Sampling Capabilities
When you provide asampling_handler, FastMCP automatically advertises full sampling capabilities to the server, including tool support. To disable tool support for simpler handlers:

