Index
This module defines the types for the MCP protocol.
Check the latest schema at: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-11-25/schema.json
DEFAULT_NEGOTIATED_VERSION
module-attribute
DEFAULT_NEGOTIATED_VERSION = '2025-03-26'
The default negotiated version of the Model Context Protocol when no version is specified.
We need this to satisfy the MCP specification, which requires the server to assume a specific version if none is provided by the client.
See the "Protocol Version Header" at https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#protocol-version-header.
LATEST_PROTOCOL_VERSION
module-attribute
LATEST_PROTOCOL_VERSION = '2025-11-25'
The latest version of the Model Context Protocol.
You can find the latest specification at https://modelcontextprotocol.io/specification/latest.
AudioContent
Bases: MCPModel
Audio content for a message.
Source code in src/mcp/types/_types.py
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |
mime_type
instance-attribute
mime_type: str
The MIME type of the audio. Different providers may support different audio types.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
BaseMetadata
Bases: MCPModel
Base class for entities with name and optional title fields.
Source code in src/mcp/types/_types.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
title
class-attribute
instance-attribute
title: str | None = None
Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.
If not provided, the name should be used for display (except for Tool,
where annotations.title should be given precedence over using name,
if present).
BlobResourceContents
Bases: ResourceContents
Binary contents of a resource.
Source code in src/mcp/types/_types.py
507 508 509 510 511 | |
CallToolRequest
Bases: Request[CallToolRequestParams, Literal['tools/call']]
Used by the client to invoke a tool provided by the server.
Source code in src/mcp/types/_types.py
931 932 933 934 935 | |
CallToolRequestParams
Bases: RequestParams
Parameters for calling a tool.
Source code in src/mcp/types/_types.py
924 925 926 927 928 | |
CallToolResult
Bases: Result
The server's response to a tool call.
Source code in src/mcp/types/_types.py
938 939 940 941 942 943 944 | |
CancelledNotification
Bases: Notification[CancelledNotificationParams, Literal['notifications/cancelled']]
This notification can be sent by either side to indicate that it is canceling a previously-issued request.
Source code in src/mcp/types/_types.py
1302 1303 1304 1305 1306 1307 1308 | |
CancelledNotificationParams
Bases: NotificationParams
Parameters for cancellation notifications.
Source code in src/mcp/types/_types.py
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | |
request_id
class-attribute
instance-attribute
request_id: RequestId | None = None
The ID of the request to cancel.
This MUST correspond to the ID of a request previously issued in the same direction.
reason
class-attribute
instance-attribute
reason: str | None = None
An optional string describing the reason for the cancellation.
ClientCapabilities
Bases: MCPModel
Capabilities a client may support.
Source code in src/mcp/types/_types.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
experimental
class-attribute
instance-attribute
Experimental, non-standard capabilities that the client supports.
sampling
class-attribute
instance-attribute
sampling: SamplingCapability | None = None
Present if the client supports sampling from an LLM. Can contain fine-grained capabilities like context and tools support.
elicitation
class-attribute
instance-attribute
elicitation: ElicitationCapability | None = None
Present if the client supports elicitation from the user.
roots
class-attribute
instance-attribute
roots: RootsCapability | None = None
Present if the client supports listing roots.
CompleteRequest
Bases: Request[CompleteRequestParams, Literal['completion/complete']]
A request from the client to the server, to ask for completion options.
Source code in src/mcp/types/_types.py
1198 1199 1200 1201 1202 | |
CompleteRequestParams
Bases: RequestParams
Parameters for completion requests.
Source code in src/mcp/types/_types.py
1189 1190 1191 1192 1193 1194 1195 | |
context
class-attribute
instance-attribute
context: CompletionContext | None = None
Additional, optional context for completions.
CompleteResult
Bases: Result
The server's response to a completion/complete request.
Source code in src/mcp/types/_types.py
1222 1223 1224 1225 | |
Completion
Bases: MCPModel
Completion information.
Source code in src/mcp/types/_types.py
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 | |
values
instance-attribute
An array of completion values. Must not exceed 100 items.
total
class-attribute
instance-attribute
total: int | None = None
The total number of completion options available. This can exceed the number of values actually sent in the response.
has_more
class-attribute
instance-attribute
has_more: bool | None = None
Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
CompletionArgument
Bases: MCPModel
The argument's information for completion requests.
Source code in src/mcp/types/_types.py
1173 1174 1175 1176 1177 1178 1179 | |
CompletionContext
Bases: MCPModel
Additional, optional context for completions.
Source code in src/mcp/types/_types.py
1182 1183 1184 1185 1186 | |
CompletionsCapability
Bases: MCPModel
Capability for completions operations.
Source code in src/mcp/types/_types.py
278 279 | |
ContentBlock
module-attribute
ContentBlock = (
TextContent
| ImageContent
| AudioContent
| ResourceLink
| EmbeddedResource
)
A content block that can be used in prompts and tool results.
CreateMessageRequest
Bases: Request[CreateMessageRequestParams, Literal['sampling/createMessage']]
A request from the server to sample an LLM via the client.
Source code in src/mcp/types/_types.py
1102 1103 1104 1105 1106 | |
CreateMessageRequestParams
Bases: RequestParams
Parameters for creating a message.
Source code in src/mcp/types/_types.py
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | |
model_preferences
class-attribute
instance-attribute
model_preferences: ModelPreferences | None = None
The server's preferences for which model to select. The client MAY ignore these preferences.
system_prompt
class-attribute
instance-attribute
system_prompt: str | None = None
An optional system prompt the server wants to use for sampling.
include_context
class-attribute
instance-attribute
include_context: IncludeContext | None = None
A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
max_tokens
instance-attribute
max_tokens: int
The maximum number of tokens to sample, as requested by the server.
metadata
class-attribute
instance-attribute
Optional metadata to pass through to the LLM provider.
tools
class-attribute
instance-attribute
Tool definitions for the LLM to use during sampling. Requires clientCapabilities.sampling.tools to be present.
tool_choice
class-attribute
instance-attribute
tool_choice: ToolChoice | None = None
Controls tool usage behavior. Requires clientCapabilities.sampling.tools and the tools parameter to be present.
CreateMessageResult
Bases: Result
The client's response to a sampling/createMessage request from the server.
This is the backwards-compatible version that returns single content (no arrays). Used when the request does not include tools.
Source code in src/mcp/types/_types.py
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | |
role
instance-attribute
role: Role
The role of the message sender (typically 'assistant' for LLM responses).
content
instance-attribute
content: SamplingContent
Response content. Single content block (text, image, or audio).
stop_reason
class-attribute
instance-attribute
stop_reason: StopReason | None = None
The reason why sampling stopped, if known.
CreateMessageResultWithTools
Bases: Result
The client's response to a sampling/createMessage request when tools were provided.
This version supports array content for tool use flows.
Source code in src/mcp/types/_types.py
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
role
instance-attribute
role: Role
The role of the message sender (typically 'assistant' for LLM responses).
content
instance-attribute
content: (
SamplingMessageContentBlock
| list[SamplingMessageContentBlock]
)
Response content. May be a single content block or an array. May include ToolUseContent if stop_reason is 'toolUse'.
stop_reason
class-attribute
instance-attribute
stop_reason: StopReason | None = None
The reason why sampling stopped, if known. 'toolUse' indicates the model wants to use a tool.
content_as_list
property
content_as_list: list[SamplingMessageContentBlock]
Returns the content as a list of content blocks, regardless of whether it was originally a single block or a list.
ElicitationCapability
Bases: MCPModel
Capability for elicitation operations.
Clients must support at least one mode (form or url).
Source code in src/mcp/types/_types.py
207 208 209 210 211 212 213 214 215 216 217 | |
form
class-attribute
instance-attribute
form: FormElicitationCapability | None = None
Present if the client supports form mode elicitation.
url
class-attribute
instance-attribute
url: UrlElicitationCapability | None = None
Present if the client supports URL mode elicitation.
ElicitationRequiredErrorData
Bases: MCPModel
Error data for URLElicitationRequiredError.
Servers return this when a request cannot be processed until one or more URL mode elicitations are completed.
Source code in src/mcp/types/_types.py
1438 1439 1440 1441 1442 1443 1444 1445 1446 | |
elicitations
instance-attribute
elicitations: list[ElicitRequestURLParams]
List of URL mode elicitations that must be completed.
ElicitCompleteNotification
Bases: Notification[ElicitCompleteNotificationParams, Literal['notifications/elicitation/complete']]
A notification from the server to the client, informing it that a URL mode elicitation has been completed.
Clients MAY use the notification to automatically retry requests that received a URLElicitationRequiredError, update the user interface, or otherwise continue an interaction. However, because delivery of the notification is not guaranteed, clients must not wait indefinitely for a notification from the server.
Source code in src/mcp/types/_types.py
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 | |
ElicitCompleteNotificationParams
Bases: NotificationParams
Parameters for elicitation completion notifications.
Source code in src/mcp/types/_types.py
1311 1312 1313 1314 1315 | |
elicitation_id
instance-attribute
elicitation_id: str
The unique identifier of the elicitation that was completed.
ElicitRequest
Bases: Request[ElicitRequestParams, Literal['elicitation/create']]
A request from the server to elicit information from the client.
Source code in src/mcp/types/_types.py
1411 1412 1413 1414 1415 | |
ElicitRequestedSchema
module-attribute
Schema for elicitation requests.
ElicitRequestFormParams
Bases: RequestParams
Parameters for form mode elicitation requests.
Form mode collects non-sensitive information from the user via an in-band form rendered by the client.
Source code in src/mcp/types/_types.py
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 | |
mode
class-attribute
instance-attribute
mode: Literal['form'] = 'form'
The elicitation mode (always "form" for this type).
message
instance-attribute
message: str
The message to present to the user describing what information is being requested.
requested_schema
instance-attribute
requested_schema: ElicitRequestedSchema
A restricted subset of JSON Schema defining the structure of the expected response. Only top-level properties are allowed, without nesting.
ElicitRequestParams
module-attribute
ElicitRequestParams: TypeAlias = (
ElicitRequestURLParams | ElicitRequestFormParams
)
Parameters for elicitation requests - either form or URL mode.
ElicitRequestURLParams
Bases: RequestParams
Parameters for URL mode elicitation requests.
URL mode directs users to external URLs for sensitive out-of-band interactions like OAuth flows, credential collection, or payment processing.
Source code in src/mcp/types/_types.py
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 | |
mode
class-attribute
instance-attribute
mode: Literal['url'] = 'url'
The elicitation mode (always "url" for this type).
message
instance-attribute
message: str
The message to present to the user explaining why the interaction is needed.
elicitation_id
instance-attribute
elicitation_id: str
The ID of the elicitation, which must be unique within the context of the server.
The client MUST treat this ID as an opaque value.
ElicitResult
Bases: Result
The client's response to an elicitation request.
Source code in src/mcp/types/_types.py
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | |
action
instance-attribute
action: Literal['accept', 'decline', 'cancel']
The user action in response to the elicitation. - "accept": User submitted the form/confirmed the action (or consented to URL navigation) - "decline": User explicitly declined the action - "cancel": User dismissed without making an explicit choice
content
class-attribute
instance-attribute
The submitted form data, only present when action is "accept" in form mode. Contains values matching the requested schema. Values can be strings, integers, floats, booleans, arrays of strings, or null. For URL mode, this field is omitted.
EmbeddedResource
Bases: MCPModel
The contents of a resource, embedded into a prompt or tool call result.
It is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.
Source code in src/mcp/types/_types.py
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | |
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
EmptyResult
Bases: Result
A response that indicates success but carries no data.
Source code in src/mcp/types/_types.py
115 116 | |
FormElicitationCapability
Bases: MCPModel
Capability for form mode elicitation.
Source code in src/mcp/types/_types.py
199 200 | |
GetPromptRequest
Bases: Request[GetPromptRequestParams, Literal['prompts/get']]
Used by the client to get a prompt provided by the server.
Source code in src/mcp/types/_types.py
635 636 637 638 639 | |
GetPromptRequestParams
Bases: RequestParams
Parameters for getting a prompt.
Source code in src/mcp/types/_types.py
626 627 628 629 630 631 632 | |
GetPromptResult
Bases: Result
The server's response to a prompts/get request from the client.
Source code in src/mcp/types/_types.py
824 825 826 827 828 829 | |
description
class-attribute
instance-attribute
description: str | None = None
An optional description for the prompt.
Icon
Bases: MCPModel
An icon for display in user interfaces.
Source code in src/mcp/types/_types.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
mime_type
class-attribute
instance-attribute
mime_type: str | None = None
Optional MIME type for the icon.
sizes
class-attribute
instance-attribute
Optional list of strings specifying icon dimensions (e.g., ["48x48", "96x96"]).
theme
class-attribute
instance-attribute
theme: IconTheme | None = None
Optional theme specifier.
"light" indicates the icon is designed for a light background, "dark" indicates the icon
is designed for a dark background.
See https://modelcontextprotocol.io/specification/2025-11-25/schema#icon for more details.
ImageContent
Bases: MCPModel
Image content for a message.
Source code in src/mcp/types/_types.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
mime_type
instance-attribute
mime_type: str
The MIME type of the image. Different providers may support different image types.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
Implementation
Bases: BaseMetadata
Describes the name and version of an MCP implementation.
Source code in src/mcp/types/_types.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
title
class-attribute
instance-attribute
title: str | None = None
An optional human-readable title for this implementation.
description
class-attribute
instance-attribute
description: str | None = None
An optional human-readable description of what this implementation does.
website_url
class-attribute
instance-attribute
website_url: str | None = None
An optional URL of the website for this implementation.
InitializedNotification
Bases: Notification[NotificationParams | None, Literal['notifications/initialized']]
This notification is sent from the client to the server after initialization has finished.
Source code in src/mcp/types/_types.py
333 334 335 336 337 338 339 | |
InitializeRequest
Bases: Request[InitializeRequestParams, Literal['initialize']]
This request is sent from the client to the server when it first connects, asking it to begin initialization.
Source code in src/mcp/types/_types.py
313 314 315 316 317 318 319 | |
InitializeRequestParams
Bases: RequestParams
Parameters for the initialize request.
Source code in src/mcp/types/_types.py
304 305 306 307 308 309 310 | |
protocol_version
instance-attribute
protocol_version: str
The latest version of the Model Context Protocol that the client supports.
InitializeResult
Bases: Result
After receiving an initialize request from the client, the server sends this.
Source code in src/mcp/types/_types.py
322 323 324 325 326 327 328 329 330 | |
ListPromptsRequest
Bases: PaginatedRequest[Literal['prompts/list']]
Sent from the client to request a list of prompts and prompt templates.
Source code in src/mcp/types/_types.py
587 588 589 590 | |
ListPromptsResult
Bases: PaginatedResult
The server's response to a prompts/list request from the client.
Source code in src/mcp/types/_types.py
620 621 622 623 | |
ListResourcesRequest
Bases: PaginatedRequest[Literal['resources/list']]
Sent from the client to request a list of resources the server has.
Source code in src/mcp/types/_types.py
380 381 382 383 | |
ListResourcesResult
Bases: PaginatedResult
The server's response to a resources/list request from the client.
Source code in src/mcp/types/_types.py
448 449 450 451 | |
ListResourceTemplatesRequest
Bases: PaginatedRequest[Literal['resources/templates/list']]
Sent from the client to request a list of resource templates the server has.
Source code in src/mcp/types/_types.py
454 455 456 457 | |
ListResourceTemplatesResult
Bases: PaginatedResult
The server's response to a resources/templates/list request from the client.
Source code in src/mcp/types/_types.py
460 461 462 463 | |
ListRootsRequest
Bases: Request[RequestParams | None, Literal['roots/list']]
Sent from the server to request a list of root URIs from the client. Roots allow servers to ask for specific directories or files to operate on. A common example for roots is providing a set of repositories or directories a server should operate on.
This request is typically used when the server needs to understand the file system structure or access specific locations that the client has permission to read from.
Source code in src/mcp/types/_types.py
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | |
ListRootsResult
Bases: Result
The client's response to a roots/list request from the server.
This result contains an array of Root objects, each representing a root directory or file that the server can operate on.
Source code in src/mcp/types/_types.py
1264 1265 1266 1267 1268 1269 1270 1271 | |
ListToolsRequest
Bases: PaginatedRequest[Literal['tools/list']]
Sent from the client to request a list of tools the server has.
Source code in src/mcp/types/_types.py
843 844 845 846 | |
ListToolsResult
Bases: PaginatedResult
The server's response to a tools/list request from the client.
Source code in src/mcp/types/_types.py
918 919 920 921 | |
LoggingCapability
Bases: MCPModel
Capability for logging operations.
Source code in src/mcp/types/_types.py
274 275 | |
LoggingMessageNotification
Bases: Notification[LoggingMessageNotificationParams, Literal['notifications/message']]
Notification of a log message passed from server to client.
Source code in src/mcp/types/_types.py
987 988 989 990 991 | |
LoggingMessageNotificationParams
Bases: NotificationParams
Parameters for logging message notifications.
Source code in src/mcp/types/_types.py
973 974 975 976 977 978 979 980 981 982 983 984 | |
level
instance-attribute
level: LoggingLevel
The severity of this log message.
logger
class-attribute
instance-attribute
logger: str | None = None
An optional name of the logger issuing this message.
data
instance-attribute
data: Any
The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
ModelHint
Bases: MCPModel
Hints to use for model selection.
Source code in src/mcp/types/_types.py
997 998 999 1000 1001 | |
ModelPreferences
Bases: MCPModel
The server's preferences for model selection, requested by the client during sampling.
Because LLMs can vary along multiple dimensions, choosing the "best" model is rarely straightforward. Different models excel in different areas—some are faster but less capable, others are more capable but more expensive, and so on. This interface allows servers to express their priorities across multiple dimensions to help clients make an appropriate selection for their use case.
These preferences are always advisory. The client MAY ignore them. It is also up to the client to decide how to interpret these preferences and how to balance them against other considerations.
Source code in src/mcp/types/_types.py
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | |
hints
class-attribute
instance-attribute
Optional hints to use for model selection.
If multiple hints are specified, the client MUST evaluate them in order (such that the first match is taken).
The client SHOULD prioritize these hints over the numeric priorities, but MAY still use the priorities to select from ambiguous matches.
cost_priority
class-attribute
instance-attribute
cost_priority: float | None = None
How much to prioritize cost when selecting a model. A value of 0 means cost is not important, while a value of 1 means cost is the most important factor.
speed_priority
class-attribute
instance-attribute
speed_priority: float | None = None
How much to prioritize sampling speed (latency) when selecting a model. A value of 0 means speed is not important, while a value of 1 means speed is the most important factor.
intelligence_priority
class-attribute
instance-attribute
intelligence_priority: float | None = None
How much to prioritize intelligence and capabilities when selecting a model. A value of 0 means intelligence is not important, while a value of 1 means intelligence is the most important factor.
Notification
Bases: MCPModel, Generic[NotificationParamsT, MethodT]
Base class for JSON-RPC notifications.
Source code in src/mcp/types/_types.py
90 91 92 93 94 | |
NotificationParams
Bases: MCPModel
Source code in src/mcp/types/_types.py
64 65 66 67 68 69 | |
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
PaginatedRequest
Bases: Request[PaginatedRequestParams | None, MethodT], Generic[MethodT]
Base class for paginated requests, matching the schema's PaginatedRequest interface.
Source code in src/mcp/types/_types.py
84 85 86 87 | |
PaginatedRequestParams
Bases: RequestParams
Source code in src/mcp/types/_types.py
56 57 58 59 60 61 | |
cursor
class-attribute
instance-attribute
cursor: str | None = None
An opaque token representing the current pagination position.
If provided, the server should return results starting after this cursor.
PaginatedResult
Bases: Result
Source code in src/mcp/types/_types.py
107 108 109 110 111 112 | |
next_cursor
class-attribute
instance-attribute
next_cursor: str | None = None
An opaque token representing the pagination position after the last returned result. If present, there may be more results available.
PingRequest
Bases: Request[RequestParams | None, Literal['ping']]
A ping, issued by either the server or the client, to check that the other party is still alive.
Source code in src/mcp/types/_types.py
342 343 344 345 346 347 348 | |
ProgressNotification
Bases: Notification[ProgressNotificationParams, Literal['notifications/progress']]
An out-of-band notification used to inform the receiver of a progress update for a long-running request.
Source code in src/mcp/types/_types.py
373 374 375 376 377 | |
ProgressNotificationParams
Bases: NotificationParams
Parameters for progress notifications.
Source code in src/mcp/types/_types.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
progress_token
instance-attribute
progress_token: ProgressToken
The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
progress
instance-attribute
progress: float
The progress thus far. This should increase every time progress is made, even if the total is unknown.
total
class-attribute
instance-attribute
total: float | None = None
Total number of items to process (or total progress required), if known.
message
class-attribute
instance-attribute
message: str | None = None
Message related to progress.
This should provide relevant human-readable progress information.
Prompt
Bases: BaseMetadata
A prompt or prompt template that the server offers.
Source code in src/mcp/types/_types.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
description
class-attribute
instance-attribute
description: str | None = None
An optional description of what this prompt provides.
arguments
class-attribute
instance-attribute
arguments: list[PromptArgument] | None = None
A list of arguments to use for templating the prompt.
icons
class-attribute
instance-attribute
An optional list of icons for this prompt.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
PromptArgument
Bases: MCPModel
An argument for a prompt template.
Source code in src/mcp/types/_types.py
593 594 595 596 597 598 599 600 601 | |
PromptListChangedNotification
Bases: Notification[NotificationParams | None, Literal['notifications/prompts/list_changed']]
An optional notification from the server to the client, informing it that the list of prompts it offers has changed.
Source code in src/mcp/types/_types.py
832 833 834 835 836 837 838 839 840 | |
PromptMessage
Bases: MCPModel
Describes a message returned as part of a prompt.
Source code in src/mcp/types/_types.py
817 818 819 820 821 | |
PromptReference
Bases: MCPModel
Identifies a prompt.
Source code in src/mcp/types/_types.py
1165 1166 1167 1168 1169 1170 | |
PromptsCapability
Bases: MCPModel
Capability for prompts operations.
Source code in src/mcp/types/_types.py
251 252 253 254 255 | |
list_changed
class-attribute
instance-attribute
list_changed: bool | None = None
Whether this server supports notifications for changes to the prompt list.
ReadResourceRequest
Bases: Request[ReadResourceRequestParams, Literal['resources/read']]
Sent from the client to the server, to read a specific resource URI.
Source code in src/mcp/types/_types.py
476 477 478 479 480 | |
ReadResourceRequestParams
Bases: RequestParams
Parameters for reading a resource.
Source code in src/mcp/types/_types.py
466 467 468 469 470 471 472 473 | |
uri
instance-attribute
uri: str
The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
ReadResourceResult
Bases: Result
The server's response to a resources/read request from the client.
Source code in src/mcp/types/_types.py
514 515 516 517 | |
Request
Bases: MCPModel, Generic[RequestParamsT, MethodT]
Base class for JSON-RPC requests.
Source code in src/mcp/types/_types.py
77 78 79 80 81 | |
RequestParamsMeta
Bases: TypedDict
Source code in src/mcp/types/_types.py
42 43 44 45 46 47 48 49 | |
progress_token
instance-attribute
progress_token: NotRequired[ProgressToken]
If specified, the caller requests out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
Resource
Bases: BaseMetadata
A known resource that the server is capable of reading.
Source code in src/mcp/types/_types.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
description
class-attribute
instance-attribute
description: str | None = None
A description of what this resource represents.
mime_type
class-attribute
instance-attribute
mime_type: str | None = None
The MIME type of this resource, if known.
size
class-attribute
instance-attribute
size: int | None = None
The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
This can be used by Hosts to display file sizes and estimate context window usage.
icons
class-attribute
instance-attribute
An optional list of icons for this resource.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
ResourceContents
Bases: MCPModel
The contents of a specific resource or sub-resource.
Source code in src/mcp/types/_types.py
483 484 485 486 487 488 489 490 491 492 493 494 | |
mime_type
class-attribute
instance-attribute
mime_type: str | None = None
The MIME type of this resource, if known.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
ResourceLink
Bases: Resource
A resource that the server is capable of reading, included in a prompt or tool call result.
Note: resource links returned by tools are not guaranteed to appear in the results of resources/list requests.
Source code in src/mcp/types/_types.py
804 805 806 807 808 809 810 | |
ResourceListChangedNotification
Bases: Notification[NotificationParams | None, Literal['notifications/resources/list_changed']]
An optional notification from the server to the client, informing it that the list of resources it can read from has changed.
Source code in src/mcp/types/_types.py
520 521 522 523 524 525 526 527 528 | |
ResourcesCapability
Bases: MCPModel
Capability for resources operations.
Source code in src/mcp/types/_types.py
258 259 260 261 262 263 264 | |
ResourceTemplate
Bases: BaseMetadata
A template description for resources available on the server.
Source code in src/mcp/types/_types.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
uri_template
instance-attribute
uri_template: str
A URI template (according to RFC 6570) that can be used to construct resource URIs.
description
class-attribute
instance-attribute
description: str | None = None
A human-readable description of what this template is for.
mime_type
class-attribute
instance-attribute
mime_type: str | None = None
The MIME type for all resources that match this template.
This should only be included if all resources matching this template have the same type.
icons
class-attribute
instance-attribute
An optional list of icons for this resource template.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
ResourceTemplateReference
Bases: MCPModel
A reference to a resource or resource template definition.
Source code in src/mcp/types/_types.py
1157 1158 1159 1160 1161 1162 | |
ResourceUpdatedNotification
Bases: Notification[ResourceUpdatedNotificationParams, Literal['notifications/resources/updated']]
A notification from the server to the client, informing it that a resource has changed and may need to be read again.
Source code in src/mcp/types/_types.py
576 577 578 579 580 581 582 583 584 | |
ResourceUpdatedNotificationParams
Bases: NotificationParams
Parameters for resource update notifications.
Source code in src/mcp/types/_types.py
566 567 568 569 570 571 572 573 | |
uri
instance-attribute
uri: str
The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
Result
Bases: MCPModel
Base class for JSON-RPC results.
Source code in src/mcp/types/_types.py
97 98 99 100 101 102 103 104 | |
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
Root
Bases: MCPModel
Represents a root directory or file that the server can operate on.
Source code in src/mcp/types/_types.py
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | |
uri
instance-attribute
uri: FileUrl
The URI identifying the root. This must start with file:// for now. This restriction may be relaxed in future versions of the protocol to allow other URI schemes.
name
class-attribute
instance-attribute
name: str | None = None
An optional name for the root. This can be used to provide a human-readable identifier for the root, which may be useful for display purposes or for referencing the root in other parts of the application.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
RootsCapability
Bases: MCPModel
Capability for root operations.
Source code in src/mcp/types/_types.py
176 177 178 179 180 | |
list_changed
class-attribute
instance-attribute
list_changed: bool | None = None
Whether the client supports notifications for changes to the roots list.
RootsListChangedNotification
Bases: Notification[NotificationParams | None, Literal['notifications/roots/list_changed']]
A notification from the client to the server, informing it that the list of roots has changed.
This notification should be sent whenever the client adds, removes, or modifies any root. The server should then request an updated list of roots using the ListRootsRequest.
Source code in src/mcp/types/_types.py
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 | |
SamplingCapability
Bases: MCPModel
Sampling capability structure, allowing fine-grained capability advertisement.
Source code in src/mcp/types/_types.py
220 221 222 223 224 225 226 227 228 229 230 231 232 | |
context
class-attribute
instance-attribute
context: SamplingContextCapability | None = None
Present if the client supports non-'none' values for includeContext parameter. SOFT-DEPRECATED: New implementations should use tools parameter instead.
tools
class-attribute
instance-attribute
tools: SamplingToolsCapability | None = None
Present if the client supports tools and toolChoice parameters in sampling requests. Presence indicates full tool calling support during sampling.
SamplingContent
module-attribute
SamplingContent: TypeAlias = (
TextContent | ImageContent | AudioContent
)
Basic content types for sampling responses (without tool use).
Used for backwards-compatible CreateMessageResult when tools are not used.
SamplingContextCapability
Bases: MCPModel
Capability for context inclusion during sampling.
Indicates support for non-'none' values in the includeContext parameter. SOFT-DEPRECATED: New implementations should use tools parameter instead.
Source code in src/mcp/types/_types.py
183 184 185 186 187 188 | |
SamplingMessage
Bases: MCPModel
Describes a message issued to or received from an LLM API.
Source code in src/mcp/types/_types.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | |
content
instance-attribute
content: (
SamplingMessageContentBlock
| list[SamplingMessageContentBlock]
)
Message content. Can be a single content block or an array of content blocks for multi-modal messages and tool interactions.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
content_as_list
property
content_as_list: list[SamplingMessageContentBlock]
Returns the content as a list of content blocks, regardless of whether it was originally a single block or a list.
SamplingMessageContentBlock
module-attribute
SamplingMessageContentBlock: TypeAlias = (
TextContent
| ImageContent
| AudioContent
| ToolUseContent
| ToolResultContent
)
Content block types allowed in sampling messages.
SamplingToolsCapability
Bases: MCPModel
Capability indicating support for tool calling during sampling.
When present in ClientCapabilities.sampling, indicates that the client supports the tools and toolChoice parameters in sampling requests.
Source code in src/mcp/types/_types.py
191 192 193 194 195 196 | |
ServerCapabilities
Bases: MCPModel
Capabilities that a server may support.
Source code in src/mcp/types/_types.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
experimental
class-attribute
instance-attribute
Experimental, non-standard capabilities that the server supports.
logging
class-attribute
instance-attribute
logging: LoggingCapability | None = None
Present if the server supports sending log messages to the client.
prompts
class-attribute
instance-attribute
prompts: PromptsCapability | None = None
Present if the server offers any prompt templates.
resources
class-attribute
instance-attribute
resources: ResourcesCapability | None = None
Present if the server offers any resources to read.
tools
class-attribute
instance-attribute
tools: ToolsCapability | None = None
Present if the server offers any tools to call.
completions
class-attribute
instance-attribute
completions: CompletionsCapability | None = None
Present if the server offers autocompletion suggestions for prompts and resources.
SetLevelRequest
Bases: Request[SetLevelRequestParams, Literal['logging/setLevel']]
A request from the client to the server, to enable or adjust logging.
Source code in src/mcp/types/_types.py
966 967 968 969 970 | |
SetLevelRequestParams
Bases: RequestParams
Parameters for setting the logging level.
Source code in src/mcp/types/_types.py
959 960 961 962 963 | |
level
instance-attribute
level: LoggingLevel
The level of logging that the client wants to receive from the server.
SubscribeRequest
Bases: Request[SubscribeRequestParams, Literal['resources/subscribe']]
Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
Source code in src/mcp/types/_types.py
541 542 543 544 545 546 547 | |
SubscribeRequestParams
Bases: RequestParams
Parameters for subscribing to a resource.
Source code in src/mcp/types/_types.py
531 532 533 534 535 536 537 538 | |
uri
instance-attribute
uri: str
The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
TextContent
Bases: MCPModel
Text content for a message.
Source code in src/mcp/types/_types.py
642 643 644 645 646 647 648 649 650 651 652 653 | |
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
TextResourceContents
Bases: ResourceContents
Text contents of a resource.
Source code in src/mcp/types/_types.py
497 498 499 500 501 502 503 504 | |
text
instance-attribute
text: str
The text of the item. This must only be set if the item can actually be represented as text (not binary data).
Tool
Bases: BaseMetadata
Definition for a tool the client can call.
Source code in src/mcp/types/_types.py
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
description
class-attribute
instance-attribute
description: str | None = None
A human-readable description of the tool.
input_schema
instance-attribute
A JSON Schema object defining the expected parameters for the tool.
output_schema
class-attribute
instance-attribute
An optional JSON Schema object defining the structure of the tool's output returned in the structured_content field of a CallToolResult.
icons
class-attribute
instance-attribute
An optional list of icons for this tool.
annotations
class-attribute
instance-attribute
annotations: ToolAnnotations | None = None
Optional additional tool information.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
ToolAnnotations
Bases: MCPModel
Additional properties describing a Tool to clients.
NOTE: all properties in ToolAnnotations are hints.
They are not guaranteed to provide a faithful description of
tool behavior (including descriptive properties like title).
Clients should never make tool use decisions based on ToolAnnotations received from untrusted servers.
Source code in src/mcp/types/_types.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | |
title
class-attribute
instance-attribute
title: str | None = None
A human-readable title for the tool.
read_only_hint
class-attribute
instance-attribute
read_only_hint: bool | None = None
If true, the tool does not modify its environment. Default: false
destructive_hint
class-attribute
instance-attribute
destructive_hint: bool | None = None
If true, the tool may perform destructive updates to its environment.
If false, the tool performs only additive updates.
(This property is meaningful only when read_only_hint == false)
Default: true
idempotent_hint
class-attribute
instance-attribute
idempotent_hint: bool | None = None
If true, calling the tool repeatedly with the same arguments
will have no additional effect on its environment.
(This property is meaningful only when read_only_hint == false)
Default: false
open_world_hint
class-attribute
instance-attribute
open_world_hint: bool | None = None
If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not. Default: true
ToolChoice
Bases: MCPModel
Controls tool usage behavior during sampling.
Allows the server to specify whether and how the LLM should use tools in its response.
Source code in src/mcp/types/_types.py
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 | |
mode
class-attribute
instance-attribute
mode: Literal['auto', 'required', 'none'] | None = None
Controls when tools are used: - "auto": Model decides whether to use tools (default) - "required": Model MUST use at least one tool before completing - "none": Model should not use tools
ToolListChangedNotification
Bases: Notification[NotificationParams | None, Literal['notifications/tools/list_changed']]
An optional notification from the server to the client, informing it that the list of tools it offers has changed.
Source code in src/mcp/types/_types.py
947 948 949 950 951 952 953 | |
ToolResultContent
Bases: MCPModel
Content representing the result of a tool execution.
This content type appears in user messages as a response to a ToolUseContent from the assistant. It contains the output of executing the requested tool.
Source code in src/mcp/types/_types.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
type
class-attribute
instance-attribute
type: Literal['tool_result'] = 'tool_result'
Discriminator for tool result content.
tool_use_id
instance-attribute
tool_use_id: str
The unique identifier that corresponds to the tool call's id field.
content
class-attribute
instance-attribute
content: list[ContentBlock] = []
A list of content objects representing the tool result. Defaults to empty list if not provided.
structured_content
class-attribute
instance-attribute
Optional structured tool output that matches the tool's outputSchema (if defined).
is_error
class-attribute
instance-attribute
is_error: bool | None = None
Whether the tool execution resulted in an error.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
ToolsCapability
Bases: MCPModel
Capability for tools operations.
Source code in src/mcp/types/_types.py
267 268 269 270 271 | |
list_changed
class-attribute
instance-attribute
list_changed: bool | None = None
Whether this server supports notifications for changes to the tool list.
ToolUseContent
Bases: MCPModel
Content representing an assistant's request to invoke a tool.
This content type appears in assistant messages when the LLM wants to call a tool during sampling. The server should execute the tool and return a ToolResultContent in the next user message.
Source code in src/mcp/types/_types.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | |
type
class-attribute
instance-attribute
type: Literal['tool_use'] = 'tool_use'
Discriminator for tool use content.
name
instance-attribute
name: str
The name of the tool to invoke. Must match a tool name from the request's tools array.
id
instance-attribute
id: str
Unique identifier for this tool call, used to correlate with ToolResultContent.
input
instance-attribute
Arguments to pass to the tool. Must conform to the tool's inputSchema.
meta
class-attribute
instance-attribute
meta: Meta | None = Field(alias='_meta', default=None)
See MCP specification for notes on _meta usage.
UnsubscribeRequest
Bases: Request[UnsubscribeRequestParams, Literal['resources/unsubscribe']]
Sent from the client to request cancellation of resources/updated notifications from the server.
Source code in src/mcp/types/_types.py
557 558 559 560 561 562 563 | |
UnsubscribeRequestParams
Bases: RequestParams
Parameters for unsubscribing from a resource.
Source code in src/mcp/types/_types.py
550 551 552 553 554 | |
UrlElicitationCapability
Bases: MCPModel
Capability for URL mode elicitation.
Source code in src/mcp/types/_types.py
203 204 | |
URL_ELICITATION_REQUIRED
module-attribute
URL_ELICITATION_REQUIRED = -32042
Error code indicating that a URL mode elicitation is required before the request can be processed.
ErrorData
Bases: BaseModel
Error information for JSON-RPC error responses.
Source code in src/mcp/types/jsonrpc.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
message
instance-attribute
message: str
A short description of the error.
The message SHOULD be limited to a concise single sentence.
data
class-attribute
instance-attribute
data: Any = None
Additional information about the error.
The value of this member is defined by the sender (e.g. detailed error information, nested errors, etc.).
JSONRPCError
Bases: BaseModel
A response to a request that indicates an error occurred.
Source code in src/mcp/types/jsonrpc.py
74 75 76 77 78 79 | |
JSONRPCNotification
Bases: BaseModel
A JSON-RPC notification which does not expect a response.
Source code in src/mcp/types/jsonrpc.py
22 23 24 25 26 27 | |
JSONRPCRequest
Bases: BaseModel
A JSON-RPC request that expects a response.
Source code in src/mcp/types/jsonrpc.py
13 14 15 16 17 18 19 | |
JSONRPCResponse
Bases: BaseModel
A successful (non-error) response to a request.
Source code in src/mcp/types/jsonrpc.py
31 32 33 34 35 36 | |