Skip to content

Fix MCP experimental flag passed to wrong CLI command#5114

Closed
nikolay-1986 wants to merge 1 commit intomainfrom
bug/mcp-experimental-flag-fix
Closed

Fix MCP experimental flag passed to wrong CLI command#5114
nikolay-1986 wants to merge 1 commit intomainfrom
bug/mcp-experimental-flag-fix

Conversation

@nikolay-1986
Copy link
Copy Markdown
Collaborator

Summary

Fixes the --experimental flag for the GitKraken MCP server not taking effect when enabled via gitlens.gitkraken.mcp.experimental.enabled setting.

Root cause

Commit e4abb9b ("Adds JSON-only setting for GK CLI --experimental flag") introduced the gitkraken.mcp.experimental.enabled setting and added code to pass --experimental to the CLI. However, the flag was appended to the gk mcp config command (the configuration query), not to the MCP server's runtime args.

The two-stage flow works like this:

  1. Config query: GitLens runs gk mcp config vscode --source=gitlens --scheme=vscode to get the server definition
  2. Server startup: VS Code starts the MCP server using the command and args from the config response

The mcp config subcommand does not recognize --experimental — it warns "unknown flag" and ignores it. Even if it did, the flag would only affect the config query, not the actual MCP server process. The returned args array never included --experimental, so the MCP server always started without experimental features.

Verified against CLI versions:

  • gk.exe v3.1.55-rc.2 (bundled) — Warning: unknown flag: --experimental
  • gk-insiders.exe v3.1.55-rc.3 — Warning: unknown flag: --experimental

Fix

  • Moves --experimental injection from the config query args to the returned config.args array, so the MCP server itself receives the flag at startup
  • Adds a guard (!config.args.includes('--experimental')) to avoid duplication if a future CLI version starts including it in the config response
  • Registers gitlens.gitkraken.mcp.experimental.enabled in package.json so VS Code recognizes it as a valid setting (was only defined in src/config.ts TypeScript types)

Before (broken)

GitLens calls:  gk mcp config vscode --source=gitlens --scheme=vscode --experimental
CLI warns:      "unknown flag: --experimental"
CLI returns:    { args: ["mcp", "--host=vscode", "--source=gitlens", "--scheme=vscode"] }
Server starts:  gk.exe mcp --host=vscode --source=gitlens --scheme=vscode  ← no --experimental

After (fixed)

GitLens calls:  gk mcp config vscode --source=gitlens --scheme=vscode
CLI returns:    { args: ["mcp", "--host=vscode", "--source=gitlens", "--scheme=vscode"] }
GitLens adds:   args.push("--experimental")
Server starts:  gk.exe mcp --host=vscode --source=gitlens --scheme=vscode --experimental  ✓

Test plan

  • Set "gitlens.gitkraken.mcp.experimental.enabled": true in settings.json
  • Reload VS Code and verify the GitKraken MCP server starts with --experimental flag
  • Verify experimental tools (e.g. git_status) appear in VS Code Copilot chat via @gitkraken
  • Verify that with the setting set to false (default), --experimental is NOT appended
  • Verify the setting appears as a recognized configuration in VS Code settings UI

🤖 Generated with Claude Code

The `--experimental` flag was being passed to `gk mcp config` (the
configuration query command) instead of being appended to the MCP
server's runtime args. The CLI's `mcp config` subcommand does not
support `--experimental` (warns "unknown flag") and never includes
it in the returned args, so the MCP server was always started without
experimental features regardless of the setting.

Moves `--experimental` injection from the config query args to the
returned `config.args` array, so the MCP server itself receives the
flag at startup — matching the behavior of manual mcp.json configuration.

Also registers the `gitlens.gitkraken.mcp.experimental.enabled` setting
in package.json so VS Code recognizes it as a valid configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 7, 2026

🤖 Augment PR Summary

Summary: Fixes the GitKraken MCP experimental setting by ensuring the --experimental flag is applied to the MCP server startup args rather than the gk mcp config query.
Changes: Registers gitlens.gitkraken.mcp.experimental.enabled in package.json and appends --experimental to the returned config.args with a duplication guard.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@nikolay-1986 nikolay-1986 self-assigned this Apr 7, 2026
@nikolay-1986 nikolay-1986 added the area-mcp Issues or features related to the GitKraken MCP label Apr 7, 2026
"tags": [
"experimental"
]
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We're explicitly leaving this out of the package.json/contributions.json so it doesn't show in the settings UI.

Comment on lines +168 to +169
// Append --experimental to the MCP server args (not the config command)
// so the server itself runs with experimental features enabled
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment explains the fix, but doesn't really feel necessary or make sense out of context. It should probably just be removed.

nikolay-1986 added a commit that referenced this pull request Apr 7, 2026
- Validates getMcpConfig() returns correct server config (name, type, command, args)
- Verifies mcp subcommand is present in config args
- Tests --experimental flag injection with withSettings() for enabled/disabled states
  (expected to fail until PR #5114 registers the setting in package.json)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nikolay-1986
Copy link
Copy Markdown
Collaborator Author

I'm closing current PR, because the reason of the issue is on the CLI side when responding to the MCP config request https://github.com/gitkraken/gkcli/issues/722; the setting may also be hidden.

nikolay-1986 added a commit that referenced this pull request Apr 9, 2026
- Validates getMcpConfig() returns correct server config (name, type, command, args)
- Verifies mcp subcommand is present in config args
- Tests --experimental flag injection with withSettings() for enabled/disabled states
  (expected to fail until PR #5114 registers the setting in package.json)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nikolay-1986 added a commit that referenced this pull request Apr 9, 2026
CLI v3.1.55 supports --experimental in `gk mcp config` — the flag is
correctly passed through to server args. PR #5114 is closed as resolved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-mcp Issues or features related to the GitKraken MCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants