Commit Graph

519 Commits

Author SHA1 Message Date
Max Isbey 053ffdac34 Derive the output validator on FuncMetadata construction; review fixes
FuncMetadata now derives its structured-output validator (and the schema, when
none is given) from `output_model` when it is constructed, keeping it in a
private attribute instead of a public cached property guarded by an assert. The
fields are still read live and the validator is rebuilt if `output_model` is
reassigned, so code that clears or sets `output_schema`/`output_model` on a
registered tool keeps working. `func_metadata()` simply constructs the metadata
inside the existing "not serializable" fallback.

Results are validated with `by_name=True` as well as by alias, so a TypedDict or
model that declares `Field(alias=...)` accepts the Python-side keys a tool
returns while structured content still carries the aliases the schema advertises.

The `typing.TypedDict` rebuild for Python < 3.12 now runs inside that validator
build, so `output_model` stays the declared class and rebuild failures take the
same fallback as pydantic's own; it also carries over `__module__`,
`__qualname__`, `__pydantic_config__` and `ReadOnly`, and an unresolvable key
annotation (`NameError`) degrades like it does on 3.12+.
2026-08-19 16:08:20 +00:00
Max Isbey 1e90f40a0b Hand TypedDict tool results to pydantic natively
MCPServer used to mirror a TypedDict return type into a synthesized BaseModel by
hand. That mirror gave optional keys a `None` default and dumped them as `null`,
so a tool omitting a `NotRequired`/`total=False` key produced structuredContent
that violated its own outputSchema and was rejected by the client (#3224); it fed
un-stripped `NotRequired`/`Required` (3.10) and `ReadOnly` (3.10-3.12) qualifiers
to `create_model`, which raised at registration (#3227); and it dropped the
TypedDict's docstring and `Annotated[..., Field(...)]` metadata from the schema.

TypedDict returns are now validated and serialized through a `TypeAdapter` over
the TypedDict itself, so pydantic's own handling of qualifiers, totality,
docstrings and field metadata applies and omitted keys stay absent. Below Python
3.12 pydantic refuses `typing.TypedDict`, so those are rebuilt as an equivalent
`typing_extensions.TypedDict` first. The validator is built once at registration,
inside the existing "not serializable" fallback, and cached on `FuncMetadata` as
`output_adapter`; `output_model` is now the TypedDict class for such tools.

Observable schema change for TypedDict tools: optional keys no longer carry
`"default": null`, and docstring/Field descriptions and constraints now appear.

Fixes #3224
Fixes #3227
2026-08-18 12:50:54 +00:00
Max b2025ab815 Acknowledge notification POSTs with 202 on the 2026-07-28 HTTP entry (#3326) 2026-08-17 21:15:35 +01:00
Max e473cca6a1 Let Client take StdioServerParameters directly (#3321) 2026-08-17 14:31:21 +01:00
Max fb443cc4b2 MCPServer: content-block returns are unstructured, prompt messages take Image/Audio (#3320) 2026-08-17 14:12:31 +01:00
Max 31b76cbeed Drop later-revision cache-hint fields on pre-2026 sessions (#3223) 2026-08-16 15:25:22 +01:00
Max fc41dd56c8 docs: lead the README client example with a URL, not the server object (#3315) 2026-08-16 14:27:01 +01:00
Max 5285e936a9 Pin text I/O to UTF-8 and fail CI on locale-dependent reads/writes (#3296)
Co-authored-by: ShuQingDollarVoyager <57471784+ShuQingDollarVoyager@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-16 12:41:53 +01:00
Max b31ddf37ed Retire wording tied to pre-2.0 milestones (#3211) 2026-07-29 14:54:23 +01:00
Max 78e6fbb7e4 Serve v2 docs at the site root, with permanent per-major paths (#3176) 2026-07-28 13:57:21 +01:00
Max af06330a31 Remove unused StreamableHTTPTransport.get_session_id() (#3205) 2026-07-28 13:55:02 +01:00
Max c9c431b71a Expose the middleware chain on MCPServer and stop sending unrequested change notifications (#3201) 2026-07-28 12:24:23 +01:00
Max 528e366558 Fail fast on server-to-client requests in JSON-response mode instead of hanging (#3195) 2026-07-28 11:04:51 +01:00
Max 27f5cc7a46 Remove unused mcpserver.exceptions.ValidationError (#3199) 2026-07-28 10:25:51 +01:00
Max 89c5e700f2 Gate log notifications on the per-request log-level opt-in at 2026-07-28 (#3198) 2026-07-28 02:20:33 +01:00
Max b7c9a916d6 Add mcp.types as a permanent alias for mcp_types (#3190) 2026-07-27 23:47:04 +01:00
Max 923341c98a Stop answering cancelled requests (#3188) 2026-07-27 23:26:00 +01:00
Max d3ffe87960 Split the registration request model from the registered-client record (#3181) 2026-07-27 23:11:01 +01:00
Max b9422f1c9b Make the per-version wire packages private (mcp_types._v*) (#3191) 2026-07-27 22:16:48 +01:00
Jeremiah Lowin f599cdfcf9 Cache compiled output-schema validators on ClientSession (#3134)
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
2026-07-26 11:29:10 +01:00
Max 11934c90ae Replace FileResource.is_binary with an encoding field (#3171) 2026-07-26 00:58:06 +01:00
Max 814072c94d Narrow message_handler's parameter to notifications and exceptions (#3168) 2026-07-26 00:24:48 +01:00
Max 47bfa85e83 Remove the unused timeout parameter from OAuthClientProvider (#3165) 2026-07-26 00:22:15 +01:00
Max 3212591946 Stop advertising MCP_* env vars for MCPServer settings; drop pydantic-settings (#3170) 2026-07-25 23:22:27 +01:00
Max 7163d8263f Remove the deprecated RFC7523OAuthClientProvider (#3169) 2026-07-25 22:50:57 +01:00
Max e90a66b554 Rename scopes= to scope= on the client-credentials OAuth providers (#3166) 2026-07-25 20:23:36 +01:00
Max 5dd062d077 Remove Context.client_id (#3167) 2026-07-25 19:11:51 +01:00
Max 0cb920f126 Make CacheConfig() the Client cache default and None the off switch (#3164) 2026-07-25 17:50:53 +01:00
Max 629ca297d2 Isolate the stdio server's stdin and stdout from handler subprocesses (#3117) 2026-07-25 13:05:51 +01:00
Max 00a70148bc Serve the 2026-07-28 protocol over stdio: decide the era from the opening request (#3152)
CI / checks (push) Failing after 1s
Deploy Docs / deploy-docs (push) Has been cancelled
Conformance Tests / server-conformance (push) Has been cancelled
Conformance Tests / client-conformance (push) Has been cancelled
GitHub Actions Security Analysis / zizmor (push) Has been cancelled
CI / all-green (push) Has been cancelled
2026-07-24 13:46:37 +01:00
Max 837ef904f8 Align with spec #3002: optional clientInfo, serverInfo in result _meta (#3143)
Deploy Docs / deploy-docs (push) Has been cancelled
CI / checks (push) Failing after 24m23s
CI / all-green (push) Has been cancelled
Conformance Tests / server-conformance (push) Has been cancelled
Conformance Tests / client-conformance (push) Has been cancelled
GitHub Actions Security Analysis / zizmor (push) Has been cancelled
2026-07-23 12:00:36 +01:00
Marcelo Trylesinski 03aaebd3aa Add Streamable HTTP request body limits (#3095) 2026-07-16 08:33:32 +02:00
Marcelo Trylesinski 2713b53b12 Replace httpx and httpx-sse with httpx2 (#2972)
CI / checks (push) Failing after 1s
CI / all-green (push) Has been cancelled
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
2026-07-14 17:05:08 +01:00
Otis Cui 1216c53693 fix: reject trailing newline in tool-name and URI-template varname validation (#3076)
Python's $ with re.match also matches just before a single trailing newline, so tool-name validation accepted "name\n" and UriTemplate.parse accepted varnames like "foo\n". Switch both checks to re.fullmatch.

Closes #3084
2026-07-10 12:56:54 +00:00
Max 9bdc03d54e Add the client-side subscriptions/listen driver (#3047) 2026-07-07 14:26:09 +01:00
Max d287c9868f Extend resolver DI to sampling and roots requests (#3049) 2026-07-06 18:25:57 +01:00
Max 53117cb3a9 Make client-side cancellation work over the 2026 transports (#3046) 2026-07-02 19:21:04 +01:00
Max 080f2a869d Harden the dual-era stream loop's era-lock and rejection semantics (#3040) 2026-07-01 17:07:12 +01:00
Max e50fb5be19 Serve the 2026-07-28 era over stdio and other stream-pair transports (#3038) 2026-07-01 00:11:56 +01:00
Max dcf8a6a0b5 Document pydantic.ValidationError in client Raises sections (#3036) 2026-07-01 00:03:17 +01:00
Max ca10dade2c Serve subscriptions/listen with a pluggable event bus (SEP-2575) (#3035) 2026-06-30 23:01:04 +01:00
Max 48ef569f7e Validate Mcp-Param-* headers server-side on the 2026-07-28 HTTP path (SEP-2243) (#3033) 2026-06-30 21:39:32 +01:00
Max 4df609119f Add a client extension API (#3034) 2026-06-30 21:31:02 +01:00
Max 7322ca56f4 Require integrity protection for MRTR requestState (#3032) 2026-06-30 21:30:32 +01:00
Max b15b1d5f07 Add a client-side response cache honoring SEP-2549 caching hints (#3023) 2026-06-30 11:31:06 +01:00
Max 8d0f928e40 Pass InputRequiredResult through the MCPServer prompt and resource pipelines (#3020) 2026-06-29 16:50:58 +01:00
Max 8f2c97b769 Consult request_state only for the question a resolver is asking (#3019) 2026-06-29 16:44:05 +01:00
Max 533c6a8226 Add cache_hints constructor map for SEP-2549 caching hints (#3015) 2026-06-29 14:11:15 +00:00
Marcelo Trylesinski c85836a081 Drive resolver elicitation over the 2026-07-28 input_required flow (#2986)
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
2026-06-29 14:39:43 +01:00
Marcelo Trylesinski f664db8952 Add resolver dependency injection for MCPServer tools (#2969)
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
2026-06-29 11:51:46 +01:00