Skip to content

pydantic_ai.models.mcp_sampling

MCPSamplingModelSettings

Bases: ModelSettings

Settings used for an MCP Sampling model request.

Attributes

mcp_model_preferences

Model preferences to use for MCP Sampling.

Type: ModelPreferences

MCPSamplingModel

Bases: Model

A model that uses MCP Sampling.

MCP Sampling allows an MCP server to make requests to a model by calling back to the MCP client that connected to it.

Attributes

session

The MCP server session to use for sampling.

Type: ServerSession

default_max_tokens

Default max tokens to use if not set in ModelSettings.

Max tokens is a required parameter for MCP Sampling, but optional on ModelSettings, so this value is used as fallback.

Type: int Default: 16384

model_name

The model name.

Since the model name isn’t known until the request is made, this property always returns 'mcp-sampling'.

Type: str

system

The system / model provider, returns 'MCP'.

Type: str