Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 4, 2025

This PR adds support for configuring a log file for the Dart SDK's MCP server through a new dart.mcpServerLogFile setting.

Changes Made

1. Configuration Setting

  • Added dart.mcpServerLogFile setting in package.json with:
    • Type: ["null", "string"] (optional string setting)
    • Default: null
    • Scope: machine-overridable
    • Markdown description with workspace name and home directory substitution support

2. Config Implementation

  • Added mcpServerLogFile getter in config.ts following the same pattern as other log file settings
  • Uses createFolderForFile(insertWorkspaceName(resolvePaths(...))) for proper path resolution with workspace name substitution

3. MCP Server Provider Updates

  • Updated DartMcpServerDefinitionProvider to conditionally add --log-file=${config.mcpServerLogFile} argument when the setting is configured
  • Added dart.mcpServerLogFile to the configuration change listener so VS Code updates the MCP server definition when the log file setting changes

Usage Example

Users can now configure MCP server logging by setting:

{
  "dart.mcpServerLogFile": "~/logs/mcp-server-${workspaceName}.log"
}

This will result in the MCP server being launched with:

dart mcp-server --log-file=/path/to/logs/mcp-server-my-workspace.log

Implementation Notes

  • Follows existing patterns used by other log file settings in the extension
  • Only adds the --log-file flag when the setting is actually configured (not null/empty)
  • Supports workspace name substitution and home directory expansion like other log file settings
  • Maintains compatibility with existing MCP server functionality

Fixes #5556.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: DanTup <1078012+DanTup@users.noreply.github.com>
Copilot AI changed the title [WIP] Add the a log file setting for the MCP server Add dart.mcpServerLogFile setting for MCP server logging Jul 4, 2025
Copilot AI requested a review from DanTup July 4, 2025 23:07
Copilot finished work on behalf of DanTup July 4, 2025 23:07
package.json Outdated
"description": "Whether to register the Dart SDK's MCP server with VS Code. This only applies to Dart SDKs >= v3.9.0 which added the server.",
"scope": "window"
},
"dart.mcpServerLogFile": {
Copy link
Member

Choose a reason for hiding this comment

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

We should add this new setting in the "Logging" section rather than the "SDK" section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the setting to the Logging section in commit dd1662e.

Comment on lines 40 to 41
if (config.mcpServerLogFile)
args.push(`--log-file=${config.mcpServerLogFile}`);
Copy link
Member

Choose a reason for hiding this comment

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

Push the flag name and the value as two different values in the args array.

Also, we need to ensure that we are using at least Dart 3.9.0-303 so add a new field for whether this is supported to DartCapabilities and check it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to push flag and value separately, and added version check for 3.9.0-303 in DartCapabilities in commit dd1662e.

Comment on lines 36 to 37
if (this.dartCapabilities.mcpServerRequiresExperimentalFlag)
args.push("--experimental-mcp-server");
Copy link
Member

Choose a reason for hiding this comment

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

This experimental flag is not required since 3.9.0-293 so update mcpServerRequiresExperimentalFlag to only provide this for versions up until then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated mcpServerRequiresExperimentalFlag to only return true for versions before 3.9.0-293 in commit dd1662e.

…, add version checks

Co-authored-by: DanTup <1078012+DanTup@users.noreply.github.com>
Copilot AI requested a review from DanTup July 5, 2025 07:11
Copilot finished work on behalf of DanTup July 5, 2025 07:11
@DanTup DanTup self-requested a review July 5, 2025 07:34
Copy link
Member

@DanTup DanTup left a comment

Choose a reason for hiding this comment

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

There is a lint failure:

/home/runner/work/Dart-Code/Dart-Code/src/extension/providers/mcp_server_definition_provider.ts
Error:   38:1  error  Trailing spaces not allowed  no-trailing-spaces

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

Co-authored-by: DanTup <1078012+DanTup@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 5, 2025

There is a lint failure:

...

Fixed the trailing spaces lint error in commit a5b3c8d.

Copilot finished work on behalf of DanTup July 5, 2025 07:38
Copilot AI requested a review from DanTup July 5, 2025 07:38
@DanTup DanTup marked this pull request as ready for review July 5, 2025 08:12
@DanTup DanTup merged commit 2ffed26 into master Jul 7, 2025
21 checks passed
@DanTup DanTup added this to the v3.116.0 milestone Jul 7, 2025
@DanTup DanTup deleted the copilot/fix-5556 branch July 7, 2025 09:48
@gabber-ops1
Copy link

There is a lint failure:

...

Fixed the trailing spaces lint error in commit a5b3c8d.

@gabber-ops1
Copy link

Address PR feedback: move setting to Logging section, fix args format, add version checks

Co-authored-by: DanTup 1078012+DanTup@users.noreply.github.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the a log file setting for the MCP server

3 participants