pypi / mcp-types
mcp-types
What changed in mcp-types 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
171 breaking1 security16 deprecations19 new APIs and options10 behavior and defaults8 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmcp-types 2225 changes
Breaking changes 171
initialize leaves out experimental when none is configured; client code reading capabilities.experimental on a legacy connection should handle None.
The required version is now httpx2>=2.10.0, up from >=2.5.0; the new max_sse_event_size option needs it.
Empty _meta is omitted from outbound requests; on receiving connections, ctx.meta is None rather than {}.
Requests without params omit the params member, and middleware sees ctx.params as None.
Invalid tool header annotations now raise InvalidSignature at registration, naming the tool and the problem.
MCP HTTP clients and OAuth providers follow redirects only within the endpoint's origin, with an http-to-https upgrade on the same host allowed. Other redirects fail instead of being followed.
A 403 without an
insufficient_scopechallenge is returned to the caller rather than retried.On the legacy discovery path, authorization server metadata is rejected when its issuer differs from the server's origin.
Tool schema
$refs resolve only within that schema; an unresolvable reference raisesRuntimeError: Invalid schema for tool ....If fetching protected resource metadata fails with a 5xx or 429, the OAuth flow stops instead of falling back to legacy endpoints.
Idle stateful Streamable HTTP sessions using the legacy spec now expire after 30 minutes; set
session_idle_timeout=Noneto disable expiration.Requests for unrecognized methods or methods without a registered handler now return -32601, with the method name in data, instead of -32602.
OAuth discovery now rejects authorization-server metadata whose issuer is not an exact string match for the URL advertised in protected resource metadata, or the expected server origin.
A path-less issuer_url passed as a string preserves its empty path, so advertised issuer metadata retains the supplied URL form.
BaseSession and its receive loop were removed without a shim; ClientSession now runs on JSONRPCDispatcher.
Lowlevel call_tool handlers no longer automatically validate inputs or wrap dict and list return values; handlers must validate inputs themselves and construct CallToolResult.
The callback must return AuthorizationCodeResult rather than a code/state tuple and forward the redirect's iss value for authorization-response issuer validation.
Cancelled requests generally receive no response, including if the handler later completes or fails; the 2025-era streamable HTTP transport instead terminates with a valid -32800 error.
Client adds mode to control version negotiation; auto is the default and legacy reproduces v1's initialize-only handshake.
Union message types are no longer RootModel subclasses; validate values with the exported TypeAdapter instances instead of model_validate(), and use member instances directly without .root.
Secret-based client records with no stored secret are rejected before grant processing; /token returns invalid_client and /revoke returns unauthorized_client.
The requested scope keyword is now scope instead of scopes, matching the single space-separated string value.
A client-specific request context replaces the shared generic context for client-side sampling, elicitation, and roots callbacks.
The suffixed message type alias is removed; use the bare ClientRequest union name.
Inbound deliveries start in arrival order but run as separate tasks, so callbacks and notifications may interleave; callbacks needing strict sequencing must coordinate themselves.
The method was removed; read negotiated metadata from the corresponding ClientSession properties.
The cursor parameter was removed; pass params=PaginatedRequestParams(cursor=...) to request a page.
The cursor parameter was removed; pass params=PaginatedRequestParams(cursor=...) to request a page.
The cursor parameter was removed; pass params=PaginatedRequestParams(cursor=...) to request a page.
The cursor parameter was removed; pass params=PaginatedRequestParams(cursor=...) to request a page.
Inbound server requests, notifications, and results are validated against the negotiated protocol schema before parsing; spec-invalid output may raise pydantic.ValidationError.
The deprecated args parameter was removed; pass arguments instead.
The protocol type alias is removed; use ContentBlock instead.
Removed because it only echoed a non-standard request metadata key and did not provide an authenticated client identity.
Rendered elicitation schemas are checked against PrimitiveSchemaDefinition at the call site; unsupported schemas raise TypeError, and accepted answers that mismatch raise ValueError.
Context logging methods take data: Any instead of message: str; Context.log accepts all eight RFC 5424 levels. The extra parameter is removed.
The context type is imported from mcp.server.mcpserver, and its fastmcp property is now named mcp_server.
The high-level Context type no longer takes a ServerSessionT type parameter; its remaining parameters have defaults.
The yielded streams are now context-propagating wrappers; they no longer support send_nowait, receive_nowait, or statistics().
The in-memory testing helper was removed; use mcp.client.Client, which accepts a Server or MCPServer and handles in-memory transport and session setup.
The protocol type alias is removed; use str directly.
Now a TypeAliasType usable as an annotation, but runtime isinstance checks against the alias raise TypeError; check its member classes instead.
The SDK no longer implements the Tasks runtime or experimental modules and properties; the reintroduced official extension is not implemented yet.
MCP types now silently drop unknown constructor arguments and wire-data keys instead of preserving them; use _meta for custom data.
FastMCP is renamed to MCPServer.
Replaces is_binary with encoding: a string decodes and serves text, while None serves bytes. Defaults use a declared charset, UTF-8 with BOM tolerance for textual MIME types, and bytes otherwise.
The type alias is gone; importing it from mcp.client.streamable_http now raises ImportError.
Private _handle_message, _handle_request, and _handle_notification dispatch methods are removed; use middleware to intercept requests.
The SDK replaces httpx and httpx-sse with httpx2, which becomes a required dependency.
Client-authentication failures at /token now return invalid_client instead of unauthorized_client; unauthorized_client is reserved for authenticated clients not permitted the requested grant.
Invalid template syntax, duplicate variables, unsupported syntax, and adjacent variables without a delimiter now fail when the decorator runs.
The required id field now accepts None, allowing null-id JSON-RPC error responses to validate; callers must handle None.
Message unions are plain unions rather than RootModel instances.
Removed with RFC7523OAuthClientProvider. Use SignedJWTParameters to build an assertion or static_assertion_provider to wrap a prebuilt JWT.
Its value and meaning changed to the newest revision spoken in any era, which the initialize handshake cannot negotiate; use LATEST_HANDSHAKE_VERSION for handshake offers or comparisons.
The lowlevel list_tools, list_resources, and list_prompts handlers no longer accept bare lists; return the corresponding full result type.
The deprecated logging capability is removed; log delivery is instead opted into per request.
Automatic wrapping of bare list or dict returns is removed; such returns fail result validation.
Tool handler exceptions no longer become isError: true results; clients receive a JSON-RPC error.
Streamable HTTP POST bodies now have a 4 MiB default limit; oversized requests receive HTTP 413 before JSON parsing or session creation. Set a larger positive byte limit when needed.
The SDK no longer reads MCP_* environment variables or .env files for Settings. Read environment values in application code and pass them to the constructor.
The command pins the spawned environment to the installed SDK version, except for source builds and other unpublished versions.
The command pins the spawned environment to the installed SDK version, except for source builds and other unpublished versions.
The header-name constant is now imported from mcp.shared.inbound instead of mcp.client.streamable_http.
The SDK adds mcp-types as a required dependency, pinned exactly to the SDK version; do not pin it independently.
The ws optional dependency extra no longer exists.
The WebSocket client transport is removed; use the streamable HTTP transport instead.
The WebSocket server transport is removed; use streamable HTTP instead.
The ProgressContext, Progress, and progress() context manager are removed; use Context.report_progress() or session.report_progress() instead.
The mcp.shared.session module and its generic typing helpers were removed.
The module is removed; import the version registry from mcp.types.version instead.
McpError is renamed to MCPError.
MCPError now exposes a convenience code property for checking protocol error codes.
The exception is renamed from McpError, exported from mcp, and constructed with code, message, and optional data directly; existing ErrorData can be passed to from_error_data().
An MCPError raised in an @mcp.tool() handler now becomes a top-level JSON-RPC error, preserving code, message, and data; client call_tool methods raise it.
The high-level server class is renamed from FastMCP and moved to mcp.server.mcpserver; its submodules move there too, and the old import path raises ModuleNotFoundError.
A server constructed without a name now reports mcp-server as serverInfo.name instead of FastMCP. Pass a name explicitly to preserve the old identity.
The constructor's positional order now includes title and description before instructions, and version after icons. Pass all arguments except name by keyword to avoid silently assigning instructions to title.
Transport-specific parameters move from the MCPServer constructor to runapp methods.
Transport configuration moved from the constructor to run(), sse_app(), and streamable_http_app(). Configure each transport when starting or building the server.
call_tool() now returns CallToolResult or InputRequiredResult rather than exposing internal conversion shapes. Read content and structured_content from the result.
get_context() was removed; tool, resource, and prompt handlers should receive Context through parameter injection instead of reading ambient context.
get_prompt() may now return InputRequiredResult as well as GetPromptResult; callers should narrow the union when handling direct calls.
read_resource() may now return InputRequiredResult as well as resource contents; callers should narrow the union when handling direct calls.
run() is overloaded per transport so type checkers validate accepted keywords; stdio accepts none, and HTTP transports raise TypeError for unrecognized keywords when starting.
The server exception is renamed from FastMCPError and is imported from mcp.server.mcpserver.exceptions.
The handler no longer receives server-initiated requests; its parameter is IncomingMessage, and delivered notifications are concrete instances rather than RootModel wrappers.
Client now defaults to mode='auto'.
Serialization now emits snake_case keys by default; pass by_alias=True to produce the camelCase wire format.
The mount_path parameter was removed from MCPServer methods and Settings; SSE sub-path mounting uses ASGI root_path instead.
Server-initiated requests without a channel now fail with NoBackChannelError instead of stalling or being silently dropped.
The nested metadata class is gone; notification _meta is now a plain dict[str, Any], accessed with dictionary operations.
Cancelling an awaiting request or timing out now sends notifications/cancelled so the server interrupts the handler.
The server-record model is now separate from the strict registration-request model and accepts server-substituted metadata, including nullable or unsupported values and empty or absent redirect_uris.
client_id is required on the server record because a registered-client record without it is not meaningful.
Registered client credentials record their issuing authorization server; credentials bound to a different server are discarded and re-registered, while URL-based client IDs are unaffected.
validate_scope moved from OAuthClientMetadata to OAuthClientInformationFull, along with validate_redirect_uri.
Path-less redirect URIs passed as strings serialize and are sent without a trailing slash; re-register clients if stored redirect URIs use the previous form.
Dynamic registration now rejects credentials the authorization-code flow cannot use before storing them or beginning authorization.
The timeout argument is removed because it was stored but never read; bound waiting in the redirect_handler or callback_handler instead.
The v2 constructor adds a new optional validate_resource_url callback.
Path-less URLs parsed from strings or JSON preserve their empty path instead of gaining a trailing slash, supporting exact issuer comparisons.
Import OAuthTokenError from mcp.client.auth; the client-credentials extension no longer happens to re-export it.
When supported by the authorization server and refresh_token is an allowed grant, the client adds offline_access to requested scopes and sends prompt=consent.
Lowlevel decorator-based handlers are replaced with on_* constructor parameters.
Generic handler exceptions now propagate as top-level JSON-RPC errors instead of becoming CallToolResult errors; catch exceptions and construct an error result when that behavior is desired.
The requested scope keyword is now scope instead of scopes, matching the single space-separated string value.
Protocol model attributes now use snake_case instead of camelCase; constructor kwargs still accept both spellings, but attribute access must use snake_case.
raise_exceptions=True now governs handler exceptions only; transport errors are debug-logged and dropped rather than re-raised from run().
Lowlevel read_resource handlers must return ReadResourceResult and construct text or blob contents themselves, including base64 encoding binary content.
Timeout parameters that accepted datetime.timedelta now accept plain seconds as float; convert existing timedeltas with .total_seconds().
The module-level context variable was removed; handlers receive request context as their first argument.
The public request_handlers and notification_handlers dictionaries are removed; register handlers through constructor arguments or add_* methods, and look them up by method string.
On 2026-07-28 connections, servers deliver log messages only on the requesting stream when that request opts in with _meta io.modelcontextprotocol/logLevel; otherwise messages are dropped.
Client request timeouts now use JSON-RPC code -32001 instead of HTTP status 408; compare the error code with REQUEST_TIMEOUT.
The shared generic RequestContext was removed; use ClientRequestContext or ServerRequestContext instead.
The generic mcp.shared.context.RequestContext type was deleted; use ClientRequestContext for client callbacks.
The nested RequestParams.Meta Pydantic model is replaced by a top-level TypedDict; access metadata with dictionary keys such as progress_token.
RequestResponder and its response and cancellation-tracking APIs were removed; inbound cancellation is handled by JSONRPCDispatcher.
Resolve markers now require the client to declare the matching elicitation, sampling, or roots capability, including sampling.tools when applicable; otherwise the call fails with MISSING_REQUIRED_CLIENT_CAPABILITY.
Resource classes now reject unrecognized keyword arguments with ValidationError instead of silently dropping them; subclasses can explicitly allow extras with model_config.
Template matching now supports RFC 6570, matches literals and structural delimiters exactly, and allows simple variables to match empty values.
Resource URIs use str instead of AnyUrl.
ResourceManager.get_resource() and missing-resource handlers use typed exceptions; missing resource reads return JSON-RPC code -32602 with the requested URI in error.data.
The protocol type is removed; use ResourceTemplateReference instead.
Resource template parameters are checked by default for traversal components, null bytes, and absolute paths; exempt_params can exempt legitimate parameters.
Raises ResourceError when the template function fails instead of ValueError.
Removed the deprecated provider. Use the provider for the actual flow: client credentials, private_key_jwt client authentication, or identity assertion.
Notifications sent after connection close are dropped with a debug log instead of raising a transport exception.
The client-side send_notification method no longer accepts related_request_id.
Calling send_request before entering the context manager now raises RuntimeError immediately; after connection close it raises MCPError with CONNECTION_CLOSED.
The client-side send_request method no longer accepts ServerMessageMetadata.
Lowlevel handlers are now supplied as on_* constructor keyword arguments and receive ServerRequestContext plus typed params, returning full result types instead of using decorator registration.
Handler results are validated against the negotiated protocol schema before transmission. Invalid results raise server-side and produce an INTERNAL_ERROR response for the client.
The lowlevel Server supports registering arbitrary request handlers directly; MCPServer users can access it through the private _lowlevel_server workaround.
Middleware can observe and wrap request handling, including unknown methods; its API is provisional, so the notes recommend using it for observation rather than as a foundation.
The server property was removed; handlers receive request context as their first argument.
The low-level Server.run() method no longer accepts a stateless flag; stateless serving is determined by how the connection is constructed.
All constructor parameters after name are keyword-only, so positional arguments such as version must be passed by keyword.
The Server type now has one type parameter; the RequestT parameter has been removed.
A server without an explicit version now reports an empty string rather than the installed mcp package version. Set version to identify your server.
A server-specific context replaces the shared generic context and includes server fields plus protocol_version, method, raw params, and an optional request_id.
ServerSession is now a per-inbound-message proxy over a connection rather than a connection-wide BaseSession; identity-based per-client state can break, while captured proxies remain usable after handlers return.
ServerSession is no longer an async context manager; its async context-manager methods were removed.
The schema keyword was renamed from requestedSchema to requested_schema; keyword callers using the old name now raise TypeError.
The public inbound-message stream was removed; register handlers or use Server.middleware to observe inbound requests and notifications.
Settings now contains only constructor-owned fields. Removed transport fields can no longer be assigned, and lifespan is read once during construction.
Fields previously named in camelCase are renamed to snake_case.
On POSIX, children left behind by a server that exits gracefully are deliberately left alive; a server that misses the grace period is still terminated with its process group.
The client now closes its pipe ends deterministically at shutdown, and failed writes to a running server surface as CONNECTION_CLOSED on the read side.
The transport moves protocol streams to private descriptors and diverts fd 0 to the null device and fd 1 to stderr while serving.
A second concurrent stdio_server on the process's default streams now raises RuntimeError instead of contending for stdin.
The function now yields a 2-tuple, (read_stream, write_stream), rather than a 3-tuple containing a session-ID callback.
The server lifespan context is now entered once when the session manager starts, with state shared across sessions and requests. Move per-connection resource acquisition into handlers.
Non-2xx message POST responses now surface as JSON-RPC errors on the failing request; the connection remains usable instead of raising HTTPStatusError from the transport context.
The client alias is removed.
The deprecated function is removed; use streamable_http_client and configure headers, timeouts, and auth on an httpx2.AsyncClient.
The timeout and sse_read_timeout fields now take float seconds instead of timedelta values.
The transport-level auth parameter is removed; configure auth on the httpx2.AsyncClient instead.
The transport-level headers parameter is removed; configure headers on the httpx2.AsyncClient instead.
The transport-level SSE read timeout parameter is removed; configure timeouts on the httpx2.AsyncClient instead.
The transport-level timeout parameter is removed; configure it on the httpx2.AsyncClient instead.
The transport no longer exposes per-connection protocol state; read the negotiated version from session.protocol_version or client.protocol_version.
On 2026-07-28 connections, change notifications reach clients only through a subscriptions/listen stream that requested them; standalone notifications sent by v1-style session helpers are dropped.
Synchronous handlers now run on a worker thread.
Synchronous tool, resource, prompt, and resolver functions now run in worker threads rather than inline on the event loop. Thread-affine state and asyncio.get_running_loop() assumptions may need adjustment.
The helper now requires the process to lead its own process group, spawned with start_new_session=True; the lookup and per-process fallback are gone.
The deprecated function is removed; process termination is handled internally by the stdio_client context manager.
The timeout_seconds argument is removed because the value was never used; Job Object termination is immediate.
Use the plain required, optional, or forbidden literal for task_support; TASK_REQUIRED, TASK_OPTIONAL, and TASK_FORBIDDEN constants were removed.
Resource-related URI fields and corresponding client method parameters now use str rather than AnyUrl; relative paths are accepted and values are preserved as given.
Security 1
Controls whether only tokens that the
TokenVerifierreports as issued for this server are accepted.
Deprecations 16
When
resource_server_urlis set, leavingvalidate_token_resourceunset emits anMCPDeprecationWarning; set it toTrueorFalsebecause 3.0 defaults it toTrue.Constructing this provider without
issuer=emits anMCPDeprecationWarning; pass the authorization server's issuer URL because 3.0 will require it.Imports of mcp.server.fastmcp point to the migration guide, helping developers address the import warning.
Using the cert parameter is deprecated in httpx2; configure an ssl.SSLContext instead.
Client.send_ping() is deprecated and emits MCPDeprecationWarning when called; ping is removed in the 2026-07-28 protocol.
The method is deprecated and emits MCPDeprecationWarning because the 2026-07-28 spec restricts progress notifications to the server-to-client direction; it continues working with older servers.
The method is deprecated and emits MCPDeprecationWarning. It continues to work with 2025-era servers; use Client.listen() for 2026-07-28 connections.
The method is deprecated and emits MCPDeprecationWarning; the deprecation is advisory and there are no wire-level changes.
The method is deprecated and emits MCPDeprecationWarning; the deprecation is advisory and there are no wire-level changes.
The method is deprecated and emits MCPDeprecationWarning. It continues to work with 2025-era servers; resource subscriptions for 2026-07-28 connections use the listen stream.
Roots, Sampling, and Logging methods are deprecated under SEP-2577.
The method is deprecated and emits MCPDeprecationWarning; it continues working for sessions negotiating 2025-11-25 and earlier.
The method is deprecated and emits MCPDeprecationWarning; it continues working for sessions negotiating 2025-11-25 and earlier.
The method is deprecated and emits MCPDeprecationWarning; the deprecation is advisory and there are no wire-level changes.
This constant now combines handshake and modern protocol versions and is deprecated; use HANDSHAKE_PROTOCOL_VERSIONS when referring to versions accepted by the initialize handshake.
Passing a CA bundle path as verify is deprecated in httpx2; configure an ssl.SSLContext instead.
New APIs and options 19
Server accepts get_tool_input_schema so a low-level server can supply a tool schema for header validation without running its tools/list handler.
Added to streamable_http_client and StreamableHttpParameters; the default remains 1 MiB per SSE event, and None or a larger value permits larger tool results.
MCPServer(subscriptions=False) stops serving subscriptions/listen and advertises listChanged and subscribe as false.
Adds
issuer=for specifying the authorization server's issuer URL.Streamable HTTP servers now hold at most 10,000 sessions; set
max_sessions=Noneto disable the cap.Adds a client-wide log level that is stamped into the reserved _meta key on every modern request, allowing logging_callback to receive messages when the client opts in.
Provides a listen stream for resource subscriptions on 2026-07-28 connections, replacing deprecated per-resource subscribe and unsubscribe calls.
A keyword-only dispatcher argument lets callers supply a pre-built dispatcher, such as DirectDispatcher for in-process embedding.
Negotiated server instructions are available as a property populated by initialize() or discover().
The negotiated protocol version is available as a property populated by initialize() or discover().
Negotiated server capabilities are available as an era-neutral property populated by initialize() or discover().
Negotiated server identity is available as a property and may be None when a 2026-era server does not report it.
The helper gains an optional client_grant_types parameter.
Protocol wire types are available in the standalone mcp-types distribution, allowing projects to use them without installing the full SDK.
call_tool(), read_resource(), and get_prompt() accept an optional context parameter. Direct calls without one receive a Context with no active request.
Dynamic Client Registration now sends application_type, defaulting to native; browser clients on non-local hosts should set it to web.
An optional callback is added to override the RFC 8707 resource check.
Adds dispatcher-agnostic progress reporting, which handles the no-op case when the caller did not request progress and works across dispatchers.
A new helper is added to mcp.client.auth.utils.
Behavior and default changes 10
Context[AppState] now works on prompts and resource templates, as well as tools.
Validation looks up the registered tool schema by name instead of running tools/list for each tools/call; list middleware no longer affects validation.
Request timeouts pause while OAuthClientProvider waits on redirect_handler and callback_handler, so an interactive login no longer counts against them.
Client spans now record JSON-RPC error responses; with mode="auto", probing a server without server/discover shows one ERROR span.
A client DELETE now frees its session immediately.
Client now defaults to mode='auto', probing server/discover and falling back to initialize; use mode='legacy' to force the legacy handshake.
Tracing is enabled by default: servers install tracing middleware and clients open spans per outbound request. When a global tracer provider is configured, outbound _meta receives a W3C traceparent field.
httpx2 honors this environment variable to select a CA bundle before falling back to the system trust store.
httpx2 honors this environment variable to select a CA bundle before falling back to the system trust store.
On a 403 insufficient_scope challenge, re-authorization requests the union of previously requested and newly challenged scopes so earlier permissions are retained.
Fixes and other changes 8
After a HeaderMismatch (-32020) rejection, the client re-lists tools and retries the call once.
A raising progress_callback no longer fails a call on an in-process Client(server).
On Windows, stdio_client resolves the executable off the event loop.
An explicit structuredContent null is now checked against the output schema instead of being treated as missing.
A refused opening request no longer leaves a session behind.
With client_secret_post, client-credentials token requests now include both client_id and client_secret, allowing servers requiring both to accept the exchange.
The SDK registration endpoint now echoes all registered metadata, including application_type, and returns client_secret_expires_at as 0 when an issued secret never expires.
Resource capabilities now report subscribe as true when an on_subscribe_resource handler is provided.