-
Notifications
You must be signed in to change notification settings - Fork 340
Replace MCP server format/fix with IDE-friendly versions #5795
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
Conversation
To avoid issues with format/fix calls through the AI interfering with unsaved files in the editor, this swaps the MCP-server commands with versions that call the in-editor commands instead. Fixes #5785
|
@codex review |
There was a problem hiding this 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 replaces the MCP server's dart_format and dart_fix tools with IDE-friendly versions that operate on in-editor documents rather than directly on disk files. This prevents conflicts with unsaved changes in the editor when AI assistants invoke format/fix operations through the MCP server.
Key changes:
- Introduced new custom MCP tools (
dart_formatanddart_fix) that open files in the editor and use VS Code commands - Added these tools to the default exclusion list for the Dart MCP server to avoid duplication
- Added comprehensive test coverage for the new tool implementations
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/vscode/mcp.ts | New file implementing McpTools class with custom dart_format and dart_fix tools that use editor commands |
| src/extension/extension.ts | Refactored to instantiate McpTools class instead of inline tool registration |
| package.json | Added tool definitions for dart_format and dart_fix, and included them in default exclusion list for MCP server |
| src/test/dart/mcp_server.test.ts | Updated test expectations and added new tests for dart_format and dart_fix tool implementations |
| src/test/helpers.ts | Added guard to prevent errors when closing files with no open editors |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this 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 replaces the MCP server commands for formatting and fixing with IDE-friendly versions that call in-editor commands. This is a solid improvement to avoid issues with unsaved files. The changes are well-implemented, including adding a new McpTools class to encapsulate the logic and updating tests accordingly. I have one minor suggestion to improve code readability in the new McpTools class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Remove redundant if block - Ensure opened editor gets focus so commands always apply to it and not another editor
To avoid issues with format/fix calls through the AI interfering with unsaved files in the editor, this swaps the MCP-server commands with versions that call the in-editor commands instead.
Fixes #5785