npm / @ai-sdk/mcp
@ai-sdk/mcp
What changed in @ai-sdk/mcp 0.0 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
48 breaking14 security9 deprecations26 new APIs and options11 behavior and defaults1 tooling27 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/mcp 747 changes
Breaking changes 33
OpenTelemetry span collection is no longer built into ai; install this package and register its OpenTelemetry instance to continue receiving traces.
Renames the tool callback option experimental_context to context and scopes it to tool-specific data declared by contextSchema and supplied through toolsContext.
Declare a tool's typed, tool-specific context fields; callbacks receive only the fields declared in this schema.
The deprecated export was removed; replace it with customProvider. Its options and behavior are unchanged.
The deprecated export was removed; replace it with generateImage.
The deprecated type export was removed; replace it with GenerateImageResult.
The generation start callback was renamed to onStart.
The per-step start callback was renamed to onStepStart.
The deprecated generation option and generateText result property were removed; use output for both.
The deprecated option was removed; replace remaining usages with prepareStep.
Removes the tracer property; pass a custom OpenTelemetry Tracer to the OpenTelemetry constructor instead.
Request bodies are no longer included in generateText and streamText step results by default; opt in with include.requestBody.
generateText no longer includes response bodies by default; opt in with include.responseBody.
Removes the deprecated top-level cachedInputTokens field; use inputTokenDetails.cacheReadTokens instead.
Removes the deprecated top-level reasoningTokens field; use outputTokenDetails.reasoningTokens instead.
The redirect option now defaults to 'error' instead of 'follow', rejecting HTTP redirects by default to help prevent SSRF attacks. Set redirect: 'follow' if your MCP server relies on redirects.
The minimum supported Node.js version is raised to 22; supported versions are 22, 24, and 26.
streamText now invokes onChunk for every TextStreamPart, including lifecycle, boundary, and terminal parts; handlers may need to guard chunk types.
Renames the telemetry integration callback and tracing-channel event type from onEmbedFinish to onEmbedEnd.
Renames the per-call callback for completed embed and embedMany operations from experimental_onFinish to onEnd.
Renames the per-call callback for completed rerank operations from experimental_onFinish to onEnd.
Renames the telemetry integration callback and tracing-channel event type from onRerankFinish to onRerankEnd.
Renames the per-step lifecycle callback from onStepFinish to onStepEnd across generation, streaming, agents, and UI message stream helpers. Telemetry integrations should implement onStepEnd.
Instructions returned from prepareStep now carry forward to future steps until another instructions or system override is returned.
Messages returned from prepareStep now become the base for subsequent steps, combined with the previous step's response messages.
Register a telemetry integration globally at application startup to enable telemetry collection.
All AI SDK packages are ESM-only, so CommonJS require() is no longer supported; use ESM imports.
Use runtimeContext for shared generation or agent state visible to prepareStep, events, and step results; shared top-level context usage moves to runtimeContext.
Rename the tool-loop stop-condition helper and its imports to isStepCount.
Each step's response.messages now contains only messages produced by that step, rather than accumulated messages from previous steps; use result.responseMessages for the full history.
System messages in prompt or messages are rejected by default; move instructions to the top-level instructions option or opt in with allowSystemInMessages.
Once a telemetry integration is registered, AI SDK calls emit telemetry events by default; set isEnabled to false per call to opt out.
Pass tool-specific context values keyed by tool name, separating them from shared generation or agent runtime data.
Deprecations 7
CallSettings is split into LanguageModelCallOptions and RequestOptions; replace usages with LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>. The old type remains available as deprecated.
Moves streamText's raw chunk inclusion option from top-level includeRawChunks to include.rawChunks; the old option remains supported as deprecated.
Renames the final lifecycle callback from onFinish to onEnd for text generation, streaming, and agents. onFinish remains a deprecated alias, and onEnd takes precedence when both are provided.
Renames experimental_onToolCallFinish for generateText and streamText; the old name remains a deprecated alias.
Renames experimental_onToolCallStart for generateText and streamText; the old name remains a deprecated alias.
Renames the full event stream property from fullStream to stream; fullStream remains available as a deprecated alias.
Use instructions instead of the top-level system prompt option, including in prepareStep results, repair callbacks, and lifecycle events; system remains a deprecated fallback, and instructions takes precedence when both are provided.
Behavior and default changes 6
The speech generation function graduated from experimental status and is now named generateSpeech; the old export remains a deprecated alias.
Renames experimental_include to include for generateText, streamText, and ToolLoopAgent. The old name remains supported as a deprecated alias.
The result type is now named SpeechResult; the old type remains a deprecated alias.
Renames experimental_telemetry to telemetry. The old option remains a deprecated alias during the migration window.
The transcription API graduated from experimental status and is now named transcribe; the old name remains a deprecated alias.
The result type is now named TranscriptionResult; the old name remains a deprecated alias.
Tooling 1
Run the v7 codemod suite from the project root to automate many v6-to-v7 code transformations.
@ai-sdk/mcp 271 changes
Breaking changes 9
Untrusted MCP OAuth discovery and metadata-derived token or registration URLs require a DNS-pinned fetch on server runtimes without a protected default transport; browser workers without a DOM require an explicitly supplied custom fetch.
Newly registered OAuth clients can no longer bind existing unbound refresh tokens; tokens are cleared before saving registration information, and authorization stops if they remain in storage.
Managed event subscription creation now requires ttlMs as a millisecond duration or null instead of accepting expiresAt; responses still include the backend-calculated expiresAt deadline.
Rejects invalid or missing adapter operations, nullish results, and Promise or thenable results with MCPClientError before the transport starts.
Pass an integration implementing createAdapter instead of passing subscription operations directly; existing operations can be wrapped with { createAdapter: () => operations }.
The configured integration type is now Experimental_MCPEventAdapter and requires implementing createAdapter.
The former subscription operations interface is renamed to Experimental_MCPEventOperations; update imports and operation type annotations.
CommonJS exports are removed; consumers using require() must switch to ESM import syntax.
Only explicitly defined tools pass the schemas allowlist; inherited prototype properties no longer expose tools to the model or make them executable.
Security 12
On Node.js, MCP OAuth discovery for untrusted authorization-server, redirect, token, and registration URLs requires an explicit custom fetch with connection-time DNS validation, such as createGuardedFetch().
OAuth authorization, code exchange, and refresh requests now include the canonical MCP resource when protected resource metadata is unavailable or custom resource validation returns undefined, preventing unbound authorization grants.
Binds OAuth client credentials to their authorization server, including when the selected server is approved by validateAuthorizationServerURL.
Prevents authorization server paths beginning with repeated slashes from bypassing validation.
Failed OAuth tokens are identified for conditional invalidation.
Pre-registered OAuth clients are preserved after client authentication errors, and dynamically registered credentials are replaced only with explicit provider provenance.
DNS validation and connection pinning remain in place when frameworks or instrumentation wrap global fetch before or after the SDK loads.
Prevents SSRF in OAuth metadata discovery.
OAuth client registration is hardened according to the latest protocol.
OAuth credentials are protected from exfiltration during rediscovery.
The OAuth metadata issuer is validated during discovery.
Secure JSON parsing prevents prototype pollution.
Deprecations 2
Use clientName in place of the deprecated MCPClient name property.
The name property is deprecated in favor of clientName.
New APIs and options 19
MCP App CSP metadata now supports baseUriDomains.
The stdio transport now supports the shell option.
Experimental event adapters implement synchronous createAdapter({ transport }) to receive the configured transport description and return bound subscription operations, so applications no longer configure the endpoint twice.
Adds experimental adapters for backend-owned subscription lifecycles without a local event store.
Adds an exclusive configuration union that distinguishes managed and direct event APIs from a single MCPClientConfig.
Adds compatibility for webhook-based MCP events.
Exports MCPClientError for typed MCP failure handling.
Adds an error for OAuth authorization server pin mismatches.
Adds the foundation for the latest 2026 protocol discovery.
Adds support for MCP 2026 streamable HTTP.
An optional hook lets developers validate authorization servers.
HTTP and SSE transports can use a custom fetch implementation.
MCP Apps are supported.
HTTP transport failures expose an optional response body.
HTTP transport failures expose an optional response status code so consumers can branch without parsing the error message.
HTTP transport failures expose an optional response URL.
The redirect option controls HTTP redirect behavior.
Server instructions are accessible through the client.
The serverInfo exposed by the MCP server is surfaced to clients.
Behavior and default changes 3
Graduated to a stable API; its experimental name remains available as a compatible alias.
Renames the unreleased client event configuration to experimental_events.
Server-provided tool annotations are now surfaced in tool metadata.
Fixes and other changes 26
Pending HTTP MCP requests are rejected when their SSE response stream closes or disconnects before the matching JSON-RPC response, preventing tool calls from hanging indefinitely.
When server/discover fails over Streamable HTTP, the client now rejects with the network error instead of falling back to initialize against the same unreachable server.
Input-required results are handled through the registered elicitation handler, then the original tool, prompt, or resource request is retried with its answers and request state.
The browser fetch receiver is preserved to prevent illegal-invocation errors.
Unsupported-version discovery errors now include the requested and advertised versions and explain how to select legacy initialization, while preserving original error details and avoiding automatic legacy fallback.
Fixes conversion failures for primitive or nullish results from output schemas or execute wrappers; strings become text and undefined outputs become JSON null while preserving MCP content conversion.
Over Streamable HTTP, the client waits for the discovery response instead of falling back to initialize after 1 s, preventing slow modern-only servers from being rejected.
Response bodies are now extracted in SSE transport errors.
MCP tools can now execute without options.
Preserves OAuth credentials when callback codes are rejected.
Rejects startup when the connection closes before an endpoint is received.
Preserves prototype-named tools, providers, and provider metadata as own properties without changing lookup object prototypes, preventing inherited names from resolving as registered providers or breaking image metadata aggregation.
Explicit environment values for the stdio transport are now preserved.
Avoids duplicate OAuth refreshes for stale 401 responses in legacy SSE.
OAuth callbacks use the stored authorization server when protected resource metadata rediscovery fails.
MCP tool results can return structuredContent without content; the serialized structured result is added as text.
Origin-only OAuth issuers now accept trailing slashes.
Creating an MCP tool set now fetches all paginated tool definitions.
Command shims such as npx can now be spawned on Windows.
Rejects SSE requests when POST responses are unsuccessful.
Transport request headers use the negotiated protocol version, with support for official SDK negotiation and protocol version 2025-11-25.
The MCP server name is propagated through dynamic tool parts.
Trailing slashes are stripped from the OAuth resource parameter.
Output schema validation is bypassed when a tool returns isError.
CallToolResultSchema and PromptMessageSchema accept resource_link content parts, avoiding hard rejection with zod ≥ 4.4.x.
The server name is propagated through dynamic tool parts.
@ai-sdk/mcp 114 changes
Breaking changes 3
Untrusted MCP OAuth discovery and metadata-derived token or registration URLs require a DNS-pinned fetch on server runtimes without a protected default transport; explicitly supplied fetch implementations must provide equivalent connect-time validation.
MCP client imports move from ai to the new @ai-sdk/mcp package, with the stdio transport imported from @ai-sdk/mcp/mcp-stdio.
ToolCallOptions is renamed to ToolExecutionOptions.
Security 1
Private OAuth endpoints are rejected before credentials are sent, preventing credential disclosure.
New APIs and options 7
OAuthClientProvider.invalidateCredentials accepts optional token context so providers sharing storage can atomically delete only the rejected token generation and preserve tokens saved by a concurrent refresh.
The MCP client gains elicitation support.
The MCP client definition can specify a client version.
The MCP client gains support for resources.
The MCP client supports prompts exposed by MCP servers.
The
_metafield from MCP tool definitions is exposed.MCP clients gain OAuth support.
Behavior and default changes 2
MCP scope selection now applies to dynamic client registration as well as authorization.
MCPClient is made stable.
Fixes and other changes 1
A JSON header is now passed for refreshAuth.
@ai-sdk/mcp 0.04 changes
Breaking changes 3
Untrusted MCP OAuth discovery and metadata-derived URLs require a DNS-pinned fetch on server runtimes without a protected default transport; browser workers without a DOM require an explicitly supplied custom fetch.
HTTP transport requests now reject redirects by default; trusted destinations can still be followed with redirect: 'follow'.
OAuth credentials and pending authorization flows are bound to the authorization-server issuer and token endpoint. Mismatched callbacks and issuer or endpoint changes are rejected before credential exchange.
Security 1
Providers must explicitly identify dynamically registered client information and support invalidation to recover automatically from unbound legacy registrations or expired client credentials.