|
| 1 | +from __future__ import annotations as _annotations |
| 2 | + |
1 | 3 | from collections.abc import Callable |
2 | 4 | from datetime import datetime |
3 | 5 | from typing import Annotated, Any, Final, Generic, Literal, TypeAlias, TypeVar |
|
6 | 8 | from pydantic.networks import AnyUrl, UrlConstraints |
7 | 9 | from typing_extensions import deprecated |
8 | 10 |
|
9 | | -""" |
10 | | -Model Context Protocol bindings for Python |
11 | | -
|
12 | | -These bindings were generated from https://github.com/modelcontextprotocol/specification, |
13 | | -using Claude, with a prompt something like the following: |
14 | | -
|
15 | | -Generate idiomatic Python bindings for this schema for MCP, or the "Model Context |
16 | | -Protocol." The schema is defined in TypeScript, but there's also a JSON Schema version |
17 | | -for reference. |
18 | | -
|
19 | | -* For the bindings, let's use Pydantic V2 models. |
20 | | -* Each model should allow extra fields everywhere, by specifying `model_config = |
21 | | - ConfigDict(extra='allow')`. Do this in every case, instead of a custom base class. |
22 | | -* Union types should be represented with a Pydantic `RootModel`. |
23 | | -* Define additional model classes instead of using dictionaries. Do this even if they're |
24 | | - not separate types in the schema. |
25 | | -""" |
26 | | - |
27 | 11 | LATEST_PROTOCOL_VERSION = "2025-11-25" |
28 | 12 |
|
29 | 13 | """ |
@@ -557,7 +541,7 @@ class Task(BaseModel): |
557 | 541 | """Current task state.""" |
558 | 542 |
|
559 | 543 | statusMessage: str | None = None |
560 | | - """ |
| 544 | + """ |
561 | 545 | Optional human-readable message describing the current task state. |
562 | 546 | This can provide context for any status, including: |
563 | 547 | - Reasons for "cancelled" status |
@@ -1121,7 +1105,7 @@ class ToolResultContent(BaseModel): |
1121 | 1105 | toolUseId: str |
1122 | 1106 | """The unique identifier that corresponds to the tool call's id field.""" |
1123 | 1107 |
|
1124 | | - content: list["ContentBlock"] = [] |
| 1108 | + content: list[ContentBlock] = [] |
1125 | 1109 | """ |
1126 | 1110 | A list of content objects representing the tool result. |
1127 | 1111 | Defaults to empty list if not provided. |
@@ -1523,7 +1507,7 @@ class CreateMessageRequestParams(RequestParams): |
1523 | 1507 | stopSequences: list[str] | None = None |
1524 | 1508 | metadata: dict[str, Any] | None = None |
1525 | 1509 | """Optional metadata to pass through to the LLM provider.""" |
1526 | | - tools: list["Tool"] | None = None |
| 1510 | + tools: list[Tool] | None = None |
1527 | 1511 | """ |
1528 | 1512 | Tool definitions for the LLM to use during sampling. |
1529 | 1513 | Requires clientCapabilities.sampling.tools to be present. |
|
0 commit comments