Skip to content
Open
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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## 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**:
- `Client` is now `McpClient` to avoid conflicts with other libraries (like `http`).
- `ClientOptions` is now `McpClientOptions`.
- `ServerOptions` is now `McpServerOptions`.
- **Renamed Request/Notification Parameters**:
- `ReadResourceRequestParams` -> `ReadResourceRequest`
- `GetPromptRequestParams` -> `GetPromptRequest`
- `ElicitRequestParams` -> `ElicitRequest`
- `CreateMessageRequestParams` -> `CreateMessageRequest`
- `LoggingMessageNotificationParams` -> `LoggingMessageNotification`
- `CancelledNotificationParams` -> `CancelledNotification`
- `ProgressNotificationParams` -> `ProgressNotification`
- `TaskCreationParams` -> `TaskCreation`

## 1.1.2

- **Fixed StdioClientTransport stderr handling**: Corrected process mode to always use `ProcessStartMode.normal` to ensure stdin/stdout piping works correctly. Fixed inverted stderr mode logic where `stderrMode: normal` now properly exposes stderr via getter (without internal listening), and `stderrMode: inheritStdio` now manually pipes stderr to parent process.
Expand Down
52 changes: 26 additions & 26 deletions doc/client-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Complete guide to building MCP clients with the Dart SDK.
import 'package:mcp_dart/mcp_dart.dart';

void main() async {
final client = Client(
final client = McpClient(
Implementation(
name: 'my-client',
version: '1.0.0',
Expand All @@ -49,7 +49,7 @@ void main() async {
### Client Configuration Options

```dart
final client = Client(
final client = McpClient(
Implementation(
name: 'my-client',
version: '1.0.0',
Expand All @@ -65,7 +65,7 @@ final client = Client(
Declare what your client supports:

```dart
final client = Client(
final client = McpClient(
Implementation(
name: 'my-client',
version: '1.0.0',
Expand Down Expand Up @@ -202,7 +202,7 @@ for (final resource in response.resources) {
```dart
// Read specific resource
final result = await client.readResource(
ReadResourceRequestParams(
ReadResourceRequest(
uri: 'file:///docs/readme.md',
),
);
Expand All @@ -224,7 +224,7 @@ for (final content in result.contents) {
```dart
// Subscribe to changes
await client.subscribeResource(
SubscribeRequestParams(
SubscribeRequest(
uri: 'file:///data/metrics.json',
),
);
Expand All @@ -235,7 +235,7 @@ client.onResourceUpdated = (notification) {

// Re-read the resource
client.readResource(
ReadResourceRequestParams(
ReadResourceRequest(
uri: notification.uri,
),
).then((result) {
Expand All @@ -245,7 +245,7 @@ client.onResourceUpdated = (notification) {

// Unsubscribe when done
await client.unsubscribeResource(
UnsubscribeRequestParams(
UnsubscribeRequest(
uri: 'file:///data/metrics.json',
),
);
Expand All @@ -266,7 +266,7 @@ for (final resource in response.resources) {

// Read from template
final result = await client.readResource(
ReadResourceRequestParams(
ReadResourceRequest(
uri: 'users://alice/profile', // Expands template
),
);
Expand Down Expand Up @@ -299,7 +299,7 @@ for (final prompt in response.prompts) {
```dart
// Get prompt without arguments
final result = await client.getPrompt(
GetPromptRequestParams(
GetPromptRequest(
name: 'code-review',
),
);
Expand All @@ -315,7 +315,7 @@ for (final message in result.messages) {
```dart
// Get prompt with arguments
final result = await client.getPrompt(
GetPromptRequestParams(
GetPromptRequest(
name: 'translate',
arguments: {
'target_language': 'Spanish',
Expand All @@ -334,7 +334,7 @@ for (final message in result.messages) {

```dart
final result = await client.getPrompt(
GetPromptRequestParams(
GetPromptRequest(
name: 'analyze-file',
arguments: {'file_uri': 'file:///data.json'},
),
Expand All @@ -349,7 +349,7 @@ for (final message in result.messages) {
// Resolve the embedded resource
final resourceUri = content.resource.uri;
final resourceData = await client.readResource(
ReadResourceRequestParams(uri: resourceUri),
ReadResourceRequest(uri: resourceUri),
);
print('Embedded: ${resourceData.contents.first.text}');
}
Expand All @@ -361,7 +361,7 @@ for (final message in result.messages) {
Handle LLM sampling requests from the server (server asking client to use an LLM):

```dart
final client = Client(
final client = McpClient(
Implementation(
name: 'my-client',
version: '1.0.0',
Expand Down Expand Up @@ -412,7 +412,7 @@ Get argument completion suggestions:
```dart
// Complete resource template variable
final result = await client.complete(
CompleteRequestParams(
CompleteRequest(
ref: CompletionReference(
type: CompletionReferenceType.resourceRef,
uri: 'users://{userId}/profile',
Expand All @@ -437,7 +437,7 @@ if (result.completion.hasMore == true) {
```dart
// Complete prompt argument
final result = await client.complete(
CompleteRequestParams(
CompleteRequest(
ref: CompletionReference(
type: CompletionReferenceType.promptRef,
name: 'translate',
Expand All @@ -460,7 +460,7 @@ for (final lang in result.completion.values) {
Roots are filesystem locations the client exposes to the server:

```dart
final client = Client(
final client = McpClient(
Implementation(
name: 'my-client',
version: '1.0.0',
Expand Down Expand Up @@ -499,7 +499,7 @@ await client.sendRootsListChanged();
```dart
// Set server's logging level
await client.setLoggingLevel(
SetLevelRequestParams(
SetLevelRequest(
level: LoggingLevel.debug,
),
);
Expand Down Expand Up @@ -538,7 +538,7 @@ await client.close();
### Reconnection Logic

```dart
Future<void> connectWithRetry(Client client, Transport transport) async {
Future<void> connectWithRetry(McpClient client, Transport transport) async {
var retries = 0;
const maxRetries = 3;

Expand Down Expand Up @@ -608,7 +608,7 @@ print(' ${prompts.prompts.length} prompts');

```dart
Future<CallToolResult?> callToolSafely(
Client client,
McpClient client,
String toolName,
Map<String, dynamic> args,
) async {
Expand Down Expand Up @@ -645,7 +645,7 @@ Future<CallToolResult?> callToolSafely(

```dart
// Set up all notification handlers
void setupNotifications(Client client) {
void setupNotifications(McpClient client) {
// Resource updates
client.onResourceUpdated = (notification) {
print('Resource updated: ${notification.uri}');
Expand Down Expand Up @@ -704,7 +704,7 @@ try {

```dart
Future<void> useClient() async {
final client = Client(
final client = McpClient(
Implementation(name: 'client', version: '1.0.0'),
);

Expand Down Expand Up @@ -751,14 +751,14 @@ processResult(result);
```dart
// ✅ Good
if (client.serverCapabilities?.resources?.subscribe == true) {
await client.subscribeResource(SubscribeRequestParams(uri: uri));
await client.subscribeResource(SubscribeRequest(uri: uri));
} else {
// Fallback: poll for changes
pollResourceForChanges(uri);
}

// ❌ Bad - assume capability exists
await client.subscribeResource(SubscribeRequestParams(uri: uri));
await client.subscribeResource(SubscribeRequest(uri: uri));
```

### 4. Use Progress for Long Operations
Expand Down Expand Up @@ -798,14 +798,14 @@ final subscriptions = <String>{};

Future<void> subscribe(String uri) async {
if (!subscriptions.contains(uri)) {
await client.subscribeResource(SubscribeRequestParams(uri: uri));
await client.subscribeResource(SubscribeRequest(uri: uri));
subscriptions.add(uri);
}
}

Future<void> unsubscribe(String uri) async {
if (subscriptions.contains(uri)) {
await client.unsubscribeResource(UnsubscribeRequestParams(uri: uri));
await client.unsubscribeResource(UnsubscribeRequest(uri: uri));
subscriptions.remove(uri);
}
}
Expand All @@ -814,7 +814,7 @@ Future<void> unsubscribe(String uri) async {
Future<void> cleanUp() async {
await Future.wait(
subscriptions.map((uri) =>
client.unsubscribeResource(UnsubscribeRequestParams(uri: uri)),
client.unsubscribeResource(UnsubscribeRequest(uri: uri)),
),
);
subscriptions.clear();
Expand Down
4 changes: 2 additions & 2 deletions doc/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ final response = await makeAuthenticatedRequest(
```dart
// Argument completion
final result = await client.complete(
CompleteRequestParams(
CompleteRequest(
ref: CompletionReference(
type: CompletionReferenceType.resourceRef,
uri: 'users://{userId}/profile',
Expand Down Expand Up @@ -497,7 +497,7 @@ test('tool execution', () async {
));
// Create client
final client = Client(
final client = McpClient(
Implementation(name: 'test', version: '1.0.0'),
);
Expand Down
12 changes: 6 additions & 6 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ server.registerResource(

// Client reads the resource
await client.readResource(
ReadResourceRequestParams(
ReadResourceRequest(
uri: 'file:///docs/readme.md',
),
);
Expand Down Expand Up @@ -114,7 +114,7 @@ server.registerPrompt(

// Client gets the prompt
await client.getPrompt(
GetPromptRequestParams(
GetPromptRequest(
name: 'code-review',
arguments: {'language': 'Dart'},
),
Expand Down Expand Up @@ -143,7 +143,7 @@ void main() async {
name: 'my-first-server',
version: '1.0.0',
),
options: ServerOptions(
options: McpServerOptions(
capabilities: ServerCapabilities(
tools: ServerCapabilitiesTools(),
resources: ServerCapabilitiesResources(),
Expand Down Expand Up @@ -209,7 +209,7 @@ import 'package:mcp_dart/mcp_dart.dart';

void main() async {
// Create the client
final client = Client(
final client = McpClient(
Implementation(
name: 'my-first-client',
version: '1.0.0',
Expand Down Expand Up @@ -246,7 +246,7 @@ void main() async {
// Read a resource
print('\nReading server info resource...');
final resource = await client.readResource(
ReadResourceRequestParams(
ReadResourceRequest(
uri: 'info://server',
),
);
Expand Down Expand Up @@ -448,7 +448,7 @@ await client.callTool(
Increase timeout for slow operations:

```dart
final client = Client(
final client = McpClient(
Implementation(name: 'client', version: '1.0.0'),
requestTimeout: Duration(seconds: 30), // Default is 10 seconds
);
Expand Down
10 changes: 5 additions & 5 deletions doc/quick-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final server = McpServer(
name: 'server-name',
version: '1.0.0',
),
options: ServerOptions(
options: McpServerOptions(
capabilities: ServerCapabilities(
tools: ServerCapabilitiesTools(),
),
Expand Down Expand Up @@ -175,7 +175,7 @@ await server.connect(transport);
### Create Client

```dart
final client = Client(
final client = McpClient(
Implementation(
name: 'client-name',
version: '1.0.0',
Expand Down Expand Up @@ -569,7 +569,7 @@ await server.sendPromptListChanged();
final server = McpServer(
Implementation(name: 'server', version: '1.0.0'),
// Capabilities auto-detected from registrations
options: ServerOptions(
options: McpServerOptions(
capabilities: ServerCapabilities(
tools: ServerCapabilitiesTools(),
),
Expand All @@ -580,7 +580,7 @@ final server = McpServer(
### Client Capabilities

```dart
final client = Client(
final client = McpClient(
Implementation(name: 'client', version: '1.0.0'),
capabilities: ClientCapabilities(
sampling: ClientCapabilitiesSampling(tools: true),
Expand Down Expand Up @@ -720,7 +720,7 @@ test('example', () async {
outputSink: s2c.sink,
));

final client = Client(...);
final client = McpClient(...);
await client.connect(IOStreamTransport(
inputStream: s2c.stream,
outputSink: c2s.sink,
Expand Down
Loading