Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Unreleased

### Platform support

- Inherited the stable 2.2.2 web/WASM-safe default export path, preserving
Dart IO native exports while working around pub.dev/pana 0.23.13 WASM
platform scoring for conditional exports.

### Conformance and interoperability

- Updated official conformance gates to
Expand Down Expand Up @@ -112,6 +118,14 @@ explicitly and may still change before the official spec release.
- Pointed prerelease package documentation links at `dev/2026-07-28-rc` so
pub.dev users see the draft/RC docs that match the dev package.

## 2.2.2

### Platform support

- Made the package barrel's default export path web/WASM-safe while preserving
Dart IO native exports, working around pub.dev/pana 0.23.13 WASM platform
scoring for conditional exports.

## 2.2.1

### Spec Alignment
Expand Down
10 changes: 7 additions & 3 deletions lib/mcp_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export 'src/types.dart'; // Exports shared types used across the MCP protocol.
export 'src/shared/uuid.dart'; // Exports UUID generation utilities.
export 'src/shared/logging.dart'; // Exports logging for customization

// Platform-specific exports
export 'src/exports.dart' // Stub export for other platforms
if (dart.library.js_interop) 'src/exports_web.dart'; // Web-specific exports
// Platform-specific exports.
//
// Keep the default branch web/WASM-safe. Pub.dev currently runs pana 0.23.13,
// which does not select `dart.library.js_interop` for WASM platform scoring and
// would otherwise follow the native `dart:io` exports. Native platforms still
// get the full implementation through `dart.library.io`.
export 'src/exports_web.dart' if (dart.library.io) 'src/exports.dart';
1 change: 1 addition & 0 deletions lib/src/client/module_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
library;

export './client.dart'; // Client-side implementation for MCP protocol.
export './stdio_stub.dart'; // API-compatible stdio stubs.
export './streamable_https.dart'; // Streamable HTTPS implementation.
export './task_client.dart'; // Task client helper.
75 changes: 75 additions & 0 deletions lib/src/client/stdio_stub.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'dart:async';

import 'package:mcp_dart/src/shared/transport.dart';
import 'package:mcp_dart/src/types.dart';

Never _unsupported() => throw UnsupportedError(
'StdioClientTransport is only available on Dart IO platforms.',
);

/// Configuration parameters for launching a stdio server process.
///
/// This web/default-platform stub preserves the public API shape without
/// importing `dart:io`. The real implementation is selected on Dart IO
/// platforms through the package barrel's conditional export.
class StdioServerParameters {
/// The executable command to run to start the server process.
final String command;

/// Command line arguments to pass to the executable.
final List<String> args;

/// Environment variables to use when spawning the process.
final Map<String, String>? environment;

/// How to handle the stderr stream of the child process on IO platforms.
final Object? stderrMode;

/// The working directory to use when spawning the process.
final String? workingDirectory;

/// Creates parameters for launching the stdio server.
const StdioServerParameters({
required this.command,
this.args = const [],
this.environment,
this.stderrMode,
this.workingDirectory,
});
}

/// Stub for the stdio client transport on platforms without `dart:io`.
class StdioClientTransport implements Transport {
/// Creates a stdio client transport stub.
StdioClientTransport(this.serverParams);

/// Configuration for launching the server process.
final StdioServerParameters serverParams;

@override
void Function()? onclose;

@override
void Function(Error error)? onerror;

@override
void Function(JsonRpcMessage message)? onmessage;

@override
String? get sessionId => null;

/// Stderr is unavailable without a spawned process.
Stream<List<int>>? get stderr => null;

@override
Future<void> start() async => _unsupported();

@override
Future<void> close() async {
onclose?.call();
}

@override
Future<void> send(JsonRpcMessage message, {int? relatedRequestId}) async =>
_unsupported();
}
Loading