Skip to content

Add runtime errors resource and tool to clear errors. #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 2, 2025
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
2 changes: 2 additions & 0 deletions pkgs/dart_mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
`ResourceListChangedNotification`s and `ResourceUpdatedNotification`s. The
delay can be modified by overriding
`ResourcesSupport.resourceUpdateThrottleDelay`.
- Only send notifications if the peer is still connected. Fixes issues where
notifications are delayed due to throttling and the client has since closed.
- **Breaking**: Fixed paginated result subtypes to use `nextCursor` instead of
`cursor` as the key for the next cursor.
- **Breaking**: Change the `ProgressNotification.progress` and
Expand Down
2 changes: 1 addition & 1 deletion pkgs/dart_mcp/lib/src/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ base class MCPBase {

/// Sends a notification to the peer.
void sendNotification(String method, [Notification? notification]) =>
_peer.sendNotification(method, notification);
_peer.isClosed ? null : _peer.sendNotification(method, notification);

/// Notifies the peer of progress towards completing some request.
void notifyProgress(ProgressNotification notification) =>
Expand Down
11 changes: 6 additions & 5 deletions pkgs/dart_tooling_mcp_server/lib/src/mixins/analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:language_server_protocol/protocol_generated.dart' as lsp;
import 'package:meta/meta.dart';

import '../lsp/wire_format.dart';
import '../utils/constants.dart';

/// Mix this in to any MCPServer to add support for analyzing Dart projects.
///
Expand Down Expand Up @@ -245,7 +246,7 @@ base mixin DartAnalyzerSupport
for (var entry in diagnostics.entries) {
for (var diagnostic in entry.value) {
final diagnosticJson = diagnostic.toJson();
diagnosticJson['uri'] = entry.key.toString();
diagnosticJson[ParameterNames.uri] = entry.key.toString();
messages.add(TextContent(text: jsonEncode(diagnosticJson)));
}
}
Expand All @@ -263,7 +264,7 @@ base mixin DartAnalyzerSupport
final errorResult = await _ensurePrerequisites(request);
if (errorResult != null) return errorResult;

final query = request.arguments!['query'] as String;
final query = request.arguments![ParameterNames.query] as String;
final result = await _lspConnection.sendRequest(
lsp.Method.workspace_symbol.toString(),
lsp.WorkspaceSymbolParams(query: query).toJson(),
Expand Down Expand Up @@ -306,7 +307,7 @@ base mixin DartAnalyzerSupport
);
diagnostics[diagnosticParams.uri] = diagnosticParams.diagnostics;
log(LoggingLevel.debug, {
'uri': diagnosticParams.uri,
ParameterNames.uri: diagnosticParams.uri,
'diagnostics':
diagnosticParams.diagnostics.map((d) => d.toJson()).toList(),
});
Expand Down Expand Up @@ -369,14 +370,14 @@ base mixin DartAnalyzerSupport
description: 'Look up a symbol or symbols in all workspaces by name.',
inputSchema: Schema.object(
properties: {
'query': Schema.string(
ParameterNames.query: Schema.string(
description:
'Queries are matched based on a case-insensitive partial name '
'match, and do not support complex pattern matching, regexes, '
'or scoped lookups.',
),
},
required: ['query'],
required: [ParameterNames.query],
),
annotations: ToolAnnotations(title: 'Project search', readOnlyHint: true),
);
Expand Down
Loading