pydantic_ai.models.mcp_sampling
MCPSamplingModelSettings
Bases: ModelSettings
Settings used for an MCP Sampling model request.
ALL FIELDS MUST BE mcp_
PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Source code in pydantic_ai_slim/pydantic_ai/models/mcp_sampling.py
18 19 20 21 22 23 24 25 |
|
mcp_model_preferences
instance-attribute
mcp_model_preferences: ModelPreferences
Model preferences to use for MCP Sampling.
MCPSamplingModel
dataclass
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.
Source code in pydantic_ai_slim/pydantic_ai/models/mcp_sampling.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
session
instance-attribute
session: ServerSession
The MCP server session to use for sampling.
default_max_tokens
class-attribute
instance-attribute
default_max_tokens: int = 16384
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.
model_name
property
model_name: str
The model name.
Since the model name isn't known until the request is made, this property always returns 'mcp-sampling'
.