Skip to content

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Aug 8, 2025

Some of the built-in tools like run_tests overlap with built-in VS Code functionality, but the model might choose the SDK version despite having less functionality.

TODO

  • Figure out exactly which tools we should exclude
  • run_tests seems like a like candidate
  • analyzer_files - maybe? VS Code has Problems, but it's not clear if the model can read them all, or only for a given file?
  • create_project ?
  • dart_fix ?
  • hot_reload ?
  • pub - should we expose the built-in Dart-Code commands so it can call things that show in the UI?

Edit: For now, only excluding runTests because it's the only one that specifically does overlap- the others require us to expose new tools from Dart-Code, or VS Code changes (I've opened #5647 to track the problems tool replacing analyze_files).

Some of the built-in tools like `run_tests` overlap with built-in VS Code functionality, but the model might choose the SDK version despite having less functionality.
@DanTup DanTup added this to the v3.118.0 milestone Aug 8, 2025
@DanTup DanTup added is enhancement in ai Relates to AI, such as use of the MCP APIs labels Aug 8, 2025
@DanTup DanTup requested a review from Copilot August 8, 2025 14:31
@DanTup
Copy link
Member Author

DanTup commented Aug 8, 2025

/gemini review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for excluding specific MCP tools from the Dart MCP server to avoid conflicts with built-in VS Code functionality. The implementation allows users to configure which tools should be excluded via a new dart.mcpServerTools setting.

  • Adds a new configuration option dart.mcpServerTools to control which MCP tools are enabled/disabled
  • Implements --exclude-tool argument passing to the Dart MCP server when supported (Dart SDK >= 3.10.0)
  • Defaults to excluding run_tests tool to prevent overlap with VS Code's built-in test functionality

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Adds new dart.mcpServerTools configuration with default exclusion of run_tests
src/extension/config.ts Exposes the new configuration option through the Config class
src/shared/capabilities/dart.ts Adds version check for MCP server exclude-tool support
src/extension/providers/mcp_server_definition_provider.ts Implements exclude-tool argument generation based on configuration
src/extension/extension.ts Exposes MCP server provider for testing and type safety improvements
src/shared/vscode/interfaces.ts Adds MCP server provider to internal API interface
src/extension/views/packages_view.ts Makes projectFinder public (likely for testing)
src/test/dart/mcp_server.test.ts Comprehensive test suite for the new exclude-tool functionality


// Add exclude-tool flags if supported and configured (tools set to false are excluded)
if (this.dartCapabilities.supportsMcpServerExcludeTool) {
const tools: Record<string, boolean> = config.mcpServerTools ?? {};
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback to empty object {} conflicts with the default configuration defined in package.json. Consider using the actual default value from the configuration or document why the fallback differs from the declared default.

Suggested change
const tools: Record<string, boolean> = config.mcpServerTools ?? {};
const defaultMcpServerTools: Record<string, boolean> = packageJson.contributes?.configuration?.properties?.["dart.mcpServerTools"]?.default ?? {};
const tools: Record<string, boolean> = config.mcpServerTools ?? defaultMcpServerTools;

Copilot uses AI. Check for mistakes.
get mcpServer(): boolean { return this.getConfig<boolean>("mcpServer", true); }
get mcpServerLogFile(): undefined | string { return createFolderForFile(insertWorkspaceName(resolvePaths(this.getConfig<null | string>("mcpServerLogFile", null)))); }
// eslint-disable-next-line camelcase
get mcpServerTools(): Record<string, boolean> { return this.getConfig<Record<string, boolean>>("mcpServerTools", {/* defaults from package.json */ }); }
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment /* defaults from package.json */ is misleading as the actual default is an empty object {}, not the default from package.json which includes {"run_tests": false}. This inconsistency could lead to unexpected behavior where the package.json default is not applied.

Suggested change
get mcpServerTools(): Record<string, boolean> { return this.getConfig<Record<string, boolean>>("mcpServerTools", {/* defaults from package.json */ }); }
get mcpServerTools(): Record<string, boolean> { return this.getConfig<Record<string, boolean>>("mcpServerTools", { run_tests: false }); }

Copilot uses AI. Check for mistakes.
if (config.mcpServerLogFile && this.dartCapabilities.supportsMcpServerLogFile)
args.push("--log-file", config.mcpServerLogFile);

// Add exclude-tool flags if supported and configured (tools set to false are excluded)
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should clarify the merge behavior with default exclusions. Currently it doesn't explain that user configuration merges with defaults defined in package.json.

Suggested change
// Add exclude-tool flags if supported and configured (tools set to false are excluded)
// Add exclude-tool flags if supported and configured.
// Note: The tools configuration is merged with defaults defined in package.json;
// tools set to false (either by user or default) are excluded.

Copilot uses AI. Check for mistakes.
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for excluding MCP tools from the Dart MCP server by introducing a new setting dart.mcpServerTools. The implementation is mostly correct and includes good test coverage. However, there's a critical issue in how the new configuration is read, as it doesn't merge user-provided settings with the defaults, which would cause the feature to not work as intended. I've provided a fix for this in src/extension/config.ts. I've also included a minor cleanup suggestion in src/extension/providers/mcp_server_definition_provider.ts that becomes relevant after applying the main fix. The other changes, mainly for exposing components for testing, look good.


// Add exclude-tool flags if supported and configured (tools set to false are excluded)
if (this.dartCapabilities.supportsMcpServerExcludeTool) {
const tools: Record<string, boolean> = config.mcpServerTools ?? {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With the proposed change to config.mcpServerTools, it will always return an object and never be null or undefined. Therefore, the nullish coalescing operator (?? {}) is redundant and can be removed for clarity.

Suggested change
const tools: Record<string, boolean> = config.mcpServerTools ?? {};
const tools: Record<string, boolean> = config.mcpServerTools;

@DanTup DanTup merged commit d122249 into master Aug 12, 2025
21 checks passed
@DanTup DanTup deleted the exclude-tools branch August 12, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in ai Relates to AI, such as use of the MCP APIs is enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants