You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While attempting to run my mcp_client against @modelcontextprotocol/server-filesystem I hit an issue:
$ dart run bin/mcp_client.dart \ npx -y @modelcontextprotocol/server-filesystem \ ../../colorist_uiconnecting to serverserver startedinitializing server[StdErr from server npx]: Secure MCP Filesystem Server running on stdio[StdErr from server npx]: Allowed directories: [ '/Users/brett/Documents/GitHub/colorist_ui' ]Unhandled exception:type 'Null' is not a subtype of type 'String' in type cast#0 InitializeResult.instructions (package:dart_mcp/src/api/initialization.dart:68:53)#1 main (file:///Users/brett/Documents/GitHub/developer_assistant_mcp/mcp_client/bin/mcp_client.dart:38:36)<asynchronous suspension>
The core issue is that the dart_mcp initialization code assumes that the server always supplies instructions.
Here's my code, for reference:
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file// for details. All rights reserved. Use of this source code is governed by a// BSD-style license that can be found in the LICENSE file.import'package:dart_mcp/client.dart';
voidmain(List<String> args) async {
if (args.isEmpty) {
print('Usage: dart mcp_client.dart <mcp server command>');
return;
}
final client =MCPClient(
ClientImplementation(name:'example dart client', version:'0.1.0'),
);
print('connecting to server');
final server =await client.connectStdioServer(
args.first,
args.length >1? args.sublist(1) : [],
);
print('server started');
print('initializing server');
final initializeResult =await server.initialize(
InitializeRequest(
protocolVersion: protocolVersion,
capabilities: client.capabilities,
clientInfo: client.implementation,
),
);
print('''Initialized: Protocol Version: ${initializeResult.protocolVersion} Capabilities: ${initializeResult.capabilities} Server Info: Name: ${initializeResult.serverInfo.name} Version: ${initializeResult.serverInfo.version} Instructions: ${initializeResult.instructions}''');
if (initializeResult.protocolVersion != protocolVersion) {
throwStateError(
'Protocol version mismatch, expected $protocolVersion, ''got ${initializeResult.protocolVersion}',
);
}
if (initializeResult.capabilities.tools ==null) {
await server.shutdown();
throwStateError('Server doesn\'t support tools!');
}
server.notifyInitialized(InitializedNotification());
print('sent initialized notification');
print('Listing tools from server: ');
final toolsResult =await server.listTools(ListToolsRequest());
for (final tool in toolsResult.tools) {
print(' - Tool: ${tool.name}');
final description = tool.description;
if (description !=null) print(' Description: $description');
}
await client.shutdown();
}
The text was updated successfully, but these errors were encountered:
While attempting to run my
mcp_client
against@modelcontextprotocol/server-filesystem
I hit an issue:The core issue is that the
dart_mcp
initialization code assumes that the server always suppliesinstructions
.Here's my code, for reference:
The text was updated successfully, but these errors were encountered: