mcp_dart 2.1.0
mcp_dart: ^2.1.0 copied to clipboard
Dart Implementation of Model Context Protocol (MCP) SDK.
2.1.0 #
Compatibility Notes (Potentially Breaking) #
- Streamable HTTP defaults are stricter:
- DNS rebinding protection is enabled by default for Streamable HTTP server entry points.
- Unsupported
MCP-Protocol-Versionrequest headers are rejected by default. - JSON-RPC batch POST payloads are rejected by default.
- Use compatibility toggles to preserve legacy behavior during rollout:
strictProtocolVersionHeaderValidation: falserejectBatchJsonRpcPayloads: falseenableDnsRebindingProtection: false
- Sampling response shape can now be multi-block:
SamplingMessage.contentandCreateMessageResult.contentmay be either a single block or a list.- Prefer normalized access via
contentBlocks.
- Enum expansion:
StopReasonnow includestoolUse; exhaustiveswitchstatements may need an additional branch.
Features #
- Added SDK runtime logging helper APIs:
setMcpLogHandler,resetMcpLogHandler, andsilenceMcpLogs. - Added
Logger.resetHandler()to restore the default internal log output. - Added backward-compatible sampling/content API shims while keeping 2025-11-25 wire-format compliance:
CreateMessageRequest.toolChoicesupports legacy map and typedToolChoiceSamplingMessage.contentandCreateMessageResult.contentaccept single or array content forms with normalizedcontentBlocksaccessResourceLink.annotationssupports map form with typedparsedAnnotationsaccessor
- Added Streamable HTTP compatibility toggles:
strictProtocolVersionHeaderValidationrejectBatchJsonRpcPayloads
- Added related-task metadata compatibility behavior by dual-writing
io.modelcontextprotocol/related-taskand legacyrelatedTaskkeys.
Documentation #
- Added runtime logging guidance with
package:loggingintegration examples using import aliases. - Updated transport logging middleware examples to match SDK logger methods (
debug/info/warn/error). - Added
doc/migration_2025_11_25_compat.mdwith compatibility-mode and API migration guidance. - Updated transport/client/quick-reference docs for strict defaults and compatibility toggles.
Reliability #
- Fixed Streamable HTTP
Acceptheader parsing to handle repeated/multi-value headers without throwingHttpException, improving compatibility with clients that send duplicated or splitAcceptvalues. - Centralized DNS rebinding validation across Streamable HTTP and legacy SSE server entry points.
- Added interop coverage for Dart/TypeScript sampling flows (
sampling.toolscapability and tool-choice propagation).
2.0.0 #
Breaking Changes #
- JSON Schema API:
JsonObject.additionalPropertiesandJsonSchema.object(additionalProperties: ...)now useObject?instead ofbool?.additionalPropertiesmay now be eitherboolorJsonSchema, matching the JSON Schema specification.
Features #
- MCP Apps Support:
- Added typed MCP Apps metadata models and helpers (
McpUiToolMeta,McpUiResourceMeta,McpUiCsp,McpUiPermissions) with extension capability helpers forio.modelcontextprotocol/ui. - Added TypeScript-style server helpers (
registerAppTool,registerAppResource,getUiCapability) and metadata normalization for_meta.ui.resourceUriand legacy_meta['ui/resourceUri']. - Added MCP Apps server examples for helper-based and manual metadata wiring.
- Added typed MCP Apps metadata models and helpers (
Compatibility #
- Host Rendering:
- Updated MCP Apps weather examples to use host-safe tool names (
weather_get_current), include explicitresource_linktool output, and demonstrate host-rendered UI updates from tool input/result notifications.
- Updated MCP Apps weather examples to use host-safe tool names (
Documentation #
- Added and expanded MCP Apps documentation across guides and quick reference, including host compatibility guidance for tool naming constraints.
Reliability #
- JSON Schema Parsing:
- Fixed
JsonObject.fromJsonto accept untyped map values foradditionalProperties(for example{}decoded asMap<dynamic, dynamic>), so schema objects are not silently dropped.
- Fixed
1.3.0 #
- Spec Alignment:
- Added
ResourceLink(resource_link) content type support. - Added icon metadata support with
McpIcon,IconTheme, and optionaliconsfields across tools/prompts/resources/templates. - Added
ResourceAnnotations.lastModified(ISO 8601). - Added MCP
extensionscapability support for client/server initialization capability negotiation.
- Added
- Security:
- Added optional DNS rebinding protection to streamable HTTP/SSE server entry points via host/origin allowlists.
- Reliability:
- Tightened null handling for JSON-RPC tool params and task store TTL parsing paths.
- Fixed URI template matching for RFC 6570 multi-variable operators (for example
{?status,assignee}) soresources/readresolves templated URIs correctly. - Fixed tool metadata passthrough so registered
meta(including nested_metavalues) is preserved intools/listresponses. - Improved URI template variable typing and protocol cancellation reason typing.
- Docs:
- Updated transport, client, server, tools, and quick-reference docs for new fields and security options.
1.2.2 #
- Fix pana analysis issues
1.2.1 #
-
Features:
- Progress Notifications: Implemented full support for progress tracking.
- Added
RequestHandlerExtra.sendProgress()helper for servers to report progress. - Added
RequestOptions.onprogresscallback for clients to receive progress updates. - Updated
ProgressandProgressNotificationtypes to include optionalmessagefield (compliant with 2025-11-25 spec).
- Added
- Protocol Improvements:
JsonRpcMessage.fromJsonnow supports custom/unknown methods instead of throwing.- Fixed
JsonRpcRequestmetadata extraction to correctly handle nested_metainparams. - Updated
ToolAnnotationsto maketitleoptional, preventing deserialization errors when the field is missing.
- Progress Notifications: Implemented full support for progress tracking.
-
Fixes:
- StreamableHTTP: Prevented the client from attempting to "reconnect" to short-lived POST response streams (used for tool calls). This fixes an issue where multiple tool calls could exhaust the browser's connection limit by spawning zombie reconnection attempts.
-
Examples:
- New Jaspr Client: Added a comprehensive web client example (
example/jaspr-client) built with Jaspr, featuring:- Interactive UI for Tools, Resources, Prompts, and Tasks.
- Real-time connection management.
- Visual task progression and sampling dialogs.
- Anthropic Client: Fixed issues in the Anthropic client example.
- Task Server: Added CORS headers and logging to
simple_task_interactive_server.dart. - Updated examples to remove deprecated API usage.
- New Jaspr Client: Added a comprehensive web client example (
-
Documentation:
- Overhauled documentation (
doc/) to match current API (v1.1.2+). - Added
AGENTS.mdwith comprehensive developer guidelines.
- Overhauled documentation (
-
Testing:
- Updated
test/types_test.dartandtest/types_edge_cases_test.dartto correct expectations for unknown methods.JsonRpcMessage.fromJsonreturns a genericJsonRpcRequest(orJsonRpcNotification) for unknown methods instead of throwing, aligning tests with existing library behavior.
- Updated
1.2.0 #
Breaking Changes #
Tip
All breaking changes below are auto-fixable. Run dart fix --apply to automatically update your code.
- Renamed Core Classes:
Clientis nowMcpClientto avoid conflicts with other libraries (likehttp).ClientOptionsis nowMcpClientOptions.ServerOptionsis nowMcpServerOptions.
- Renamed Request/Notification Parameters:
ReadResourceRequestParams->ReadResourceRequestGetPromptRequestParams->GetPromptRequestElicitRequestParams->ElicitRequestCreateMessageRequestParams->CreateMessageRequestLoggingMessageNotificationParams->LoggingMessageNotificationCancelledNotificationParams->CancelledNotificationProgressNotificationParams->ProgressNotificationTaskCreationParams->TaskCreation
1.1.2 #
- Fixed StdioClientTransport stderr handling: Corrected process mode to always use
ProcessStartMode.normalto ensure stdin/stdout piping works correctly. Fixed inverted stderr mode logic wherestderrMode: normalnow properly exposes stderr via getter (without internal listening), andstderrMode: inheritStdionow manually pipes stderr to parent process.
1.1.1 #
- Structured Content Support: Added explicit
structuredContentfield toCallToolResultwith automatic backward compatibility support.CallToolResult.fromStructuredContentnow automatically populates bothstructuredContent(for modern clients) andcontent(as JSON string for legacy clients).- Updated validation logic to correctly validate
structuredContentpayload against tool schema.
1.1.0 #
Breaking Changes #
- Protocol Version Update: Updated default protocol version to
2025-11-25. - Strict Capabilities Typing:
ServerCapabilitiesandClientCapabilitiesfields (tasks, sampling, elicitation, etc.) are now strictly typed objects instead ofMap<String, dynamic>orbool.- Updated
ServerCapabilitiesto useServerCapabilitiesTasks,ServerCapabilitiesTools, etc. - Updated
ClientCapabilitiesto useClientCapabilitiesTasks,ClientCapabilitiesElicitation,ClientCapabilitiesSampling, etc. - Migration: Update capability declarations to use the new typed classes (e.g.,
ServerCapabilities(tasks: ServerCapabilitiesTasks(listChanged: true))).
- Updated
- File Removal:
lib/src/server/mcp.darthas been removed. Uselib/src/server/mcp_server.dart(exported vialib/src/server/module.dart) instead. - Transport Interface Change:
Transport.sendnow accepts an optional named parameterrelatedRequestId. Custom transports must update their method signature. - Client Validation:
Client.callToolnow strictly validates tool outputs against their defined JSON schema (if present). Mismatches will throw anMcpError(ErrorCode.invalidParams). - API Refactoring:
McpServer.tool,resource, andpromptare deprecated. UseregisterTool,registerResource, andregisterPromptinstead.McpServer.registerTooluses a new callback signature:FutureOr<CallToolResult> Function(Map<String, dynamic> args, RequestHandlerExtra extra).- The deprecated
McpServer.toolretains the old named-parameter signature for backward compatibility.
- Tool Schema Definitions:
ToolInputSchema(akaJsonObject) now requires properties to be defined usingJsonSchemaobjects (e.g.,JsonSchema.string()) instead of raw Maps. - Tool Listing Types:
ListToolsRequestParamshas been replaced byListToolsRequest(update any code passingparams:toClient.listToolsor constructingJsonRpcListToolsRequest). - Tool Result Structured Content:
CallToolResultno longer uses a dedicatedstructuredContentfield in its API; structured results are represented as additional top-level fields (CallToolResult.extra).CallToolResult.fromStructuredContentnow takes a singleMap<String, dynamic>argument. - RequestHandlerExtra Signature Changes:
RequestHandlerExtra.sendNotificationandRequestHandlerExtra.sendRequesthave updated signatures (added task-related metadata/options). Update any server callbacks that call these helpers directly.
Features #
- Task Management System:
- Implemented comprehensive Task support in
lib/src/server/tasks/. - Introduced
TaskStoreabstract interface withInMemoryTaskStoreas the default implementation. - Added strictly typed
TaskResultHandlerandTaskSession. - Introduced
TaskMessageQueuefor handling task messages.
- Implemented comprehensive Task support in
- McpServer Enhancements:
- Added
McpServerhigh-level support for tasks viatasks(...)method. - Integrated
notifyTaskStatusintoMcpServer. - Added
McpServersupport forsampling/createMessage. - Exposed
onErrorhandler setter/getter onMcpServer.
- Added
- StreamableMcpServer:
- Added
StreamableMcpServerclass for simplified Streamable HTTP server creation (handlesserverFactory, event store, and connection management).
- Added
- Client Enhancements:
- Added
onTaskStatuscallback toClient. - Simplified client request handlers for sampling and elicitation.
- Added
Fixes #
- Fixed
Taskserialization. - Fixed capabilities recognition in
McpServer. - Added comprehensive tests for StreamableMcpServer and Task features.
1.0.2 #
- Fix pana analysis issues
- Fix Web support for StreamableHTTP client
1.0.1 #
- Fix Documentation links in README.md
1.0.0 #
- Update protocol version to 2025-06-18
- Add Elicitation support (server-initiated input collection)
- API:
McpServer.elicitUserInput()(server) |Client.onElicitRequest(client handler) - Types: ElicitRequestParams (
message,requestedSchema), ElicitResult (action,content), ClientCapabilitiesElicitation - Uses
elicitation/createmethod (Inspector-compatible) - Accepts JSON Schema Maps for flexible schema definition
- Helpers:
.accepted,.declined,.cancelledgetters on ElicitResult - Example: elicitation_http_server.dart
- Tests: elicitation_test.dart
- API:
- CRITICAL FIX: Logger → stderr (prevents JSON-RPC corruption in stdio)
- Comprehensive Test Coverage: Added 203 new tests across 4 phases (+13.1% overall coverage: 56.9% → 70.0%)
- Phase 1: External API coverage (Server MCP, URI templates, Client/Server capabilities) - 108 tests
- Phase 2: Transport coverage (Stdio, SSE, HTTPS) - 38 tests
- Phase 3: Types & edge cases (Protocol lifecycle, error handling) - 45 tests
- Phase 4: Advanced scenarios (Protocol timeouts/aborts, Streamable HTTPS integration) - 12 tests
- Fixed critical URI template variable duplication bug
- Fixed McpError code preservation in request handlers
- All 351 tests passing ✅
0.7.0 #
- Add support for Completions capability per MCP 2025-06-18 spec
- Add ServerCapabilitiesCompletions class for explicit completions capability declaration
- Update ServerCapabilities to include completions field
- Update client capability check to use explicit completions capability instead of inferring from prompts/resources
- Add integration tests and example for completions capability usage
0.6.4 #
- Fix issue with StreamableHTTP server not setting correct content-type for SSE
0.6.3 #
- Replace print statements with lightweight logging implementation
0.6.2 #
- Remove trailing CR before processing the lines
0.6.1 #
- Fix issue with CallToolResult not including metadata
0.6.0 #
- Add ToolInputSchema and ToolOutputSchema support in server.tool()
- Deprecate inputSchemaProperties and outputSchemaProperties in server.tool()
- Update examples to use ToolInputSchema and ToolOutputSchema
0.5.3 #
- Support Web Client for StreamableHTTP
0.5.2 #
- Preserve required fields in ToolInputSchema
0.5.1 #
- Add support for OutputScheme (https://modelcontextprotocol.io/specification/draft/server/tools#output-schema)
0.5.0 #
- Protocol version 2025-03-26
0.4.3 #
- Fix SSE behavior on StreamableHTTP
- Added sendNotification and sendRequest to extra for server callbacks
0.4.2 #
- Add Tool Annotation
- Remove additionalProperties from all models
- Add AudioContent
0.4.1 #
- Add IOStreamTransport to connect a client and server via dart streams in a single application
0.4.0 #
- Add support for StreamableHTTP client
- Add support for StreamableHTTP server
0.3.6 #
- Improve pub.dev points
0.3.5 #
- Lower min dart sdk to 3.0.0
0.3.4 #
- Fix Sampling result parsing error
0.3.3 #
- Add Gemini MCP Client Example
- Add Anthropic MCP Client Example
- Add Weather MCP Server Example
0.3.2 #
- Add SSE Server Manager for easier SSE server implementation
0.3.1 #
- Add Client support (stdio)
- Add resource and prompts example to stdio server and client
0.3.0 #
- Full refactor of the codebase to match it with the Typescript SDK implementation.
0.2.0 #
- Make it no need to call trasnport.connect()
0.1.1 #
- Add examples visible in pub.dev
0.1.0 #
- Add SSE support
0.0.2 #
- Expose more types
0.0.1 #
- Initial version.