Skip to content

Allow registering Aspire MCP server in VS Code extension#14917

Merged
adamint merged 6 commits intomicrosoft:release/13.2from
adamint:dev/adamint/auto-mcp-server-provider
Mar 4, 2026
Merged

Allow registering Aspire MCP server in VS Code extension#14917
adamint merged 6 commits intomicrosoft:release/13.2from
adamint:dev/adamint/auto-mcp-server-provider

Conversation

@adamint
Copy link
Member

@adamint adamint commented Mar 3, 2026

Description

Automatically register the Aspire MCP server in VS Code's MCP tools list when the Aspire extension activates in an Aspire workspace. This eliminates the need for users to run aspire agent init or manually create .vscode/mcp.json — the Aspire MCP server (aspire agent mcp) just appears automatically.

How it works

  • The extension registers an McpServerDefinitionProvider via the stable VS Code API vscode.lm.registerMcpServerDefinitionProvider.
  • On activation, the provider checks if the Aspire CLI is available and whether the workspace is an Aspire project (by looking for .aspire/settings.json).
  • If both conditions are met, it provides an McpStdioServerDefinition for aspire agent mcp, which makes the Aspire MCP tools (list resources, view logs, traces, etc.) available to Copilot and other AI agents automatically.
  • A runtime typeof check ensures graceful degradation on older VS Code versions that don't support this API.

Why the type declarations are copied into the repo

The McpStdioServerDefinition, McpServerDefinitionProvider, and registerMcpServerDefinitionProvider types are part of VS Code's stable API (present in vscode.d.ts since VS Code 1.105). However, the @types/vscode npm package has not yet published these types (even the latest 1.109.0 release is missing them). The file vscode.proposed.mcpServerDefinitions.d.ts provides the type declarations needed for compilation until @types/vscode catches up. Despite the filename containing "proposed", the registration API itself is stable — the actual proposed portion (lm.mcpServerDefinitions read-only list) is not used here.

Files changed

  • extension/src/mcp/AspireMcpServerDefinitionProvider.ts — New provider that supplies the Aspire MCP server definition
  • extension/src/vscode.proposed.mcpServerDefinitions.d.ts — Type declarations for the MCP API (until @types/vscode publishes them)
  • extension/package.json — Added mcpServerDefinitionProviders contribution point
  • extension/package.nls.json — Localization string for the MCP provider label
  • extension/src/extension.ts — Registers the provider during activation

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Register McpServerDefinitionProvider so the Aspire MCP server
(aspire agent mcp) appears automatically in VS Code's MCP tools
list for Aspire workspaces, eliminating the need for users to
run 'aspire agent init' or manually configure .vscode/mcp.json.
Copilot AI review requested due to automatic review settings March 3, 2026 22:03
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14917

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14917"

@adamint adamint changed the base branch from main to release/13.2 March 3, 2026 22:05
Copy link
Contributor

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 automatic MCP server registration to the Aspire VS Code extension (so aspire agent mcp appears in VS Code’s MCP tools when the extension activates in an Aspire workspace), and introduces a “Get started” walkthrough with CLI install/run guidance.

Changes:

  • Register an McpServerDefinitionProvider on extension activation to surface an aspire agent mcp stdio MCP server definition.
  • Add temporary TypeScript type declarations for the MCP API until @types/vscode includes them.
  • Add a “Get started” walkthrough (markdown + commands) and wire up new walkthrough commands and contributions in package.json / package.nls.json.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
extension/src/mcp/AspireMcpServerDefinitionProvider.ts New MCP server definition provider for aspire agent mcp.
extension/src/vscode.proposed.mcpServerDefinitions.d.ts Adds MCP type declarations for compilation.
extension/src/extension.ts Registers walkthrough commands and MCP provider during activation.
extension/src/commands/walkthroughCommands.ts Adds CLI install/verify commands used by the walkthrough.
extension/package.json Adds MCP provider contribution point, walkthrough contribution, and new commands/activation events.
extension/package.nls.json Adds localized strings for walkthrough steps/commands and MCP provider label.
extension/walkthrough/*.md Adds walkthrough markdown steps (welcome/install/create/run/dashboard/next steps).
Comments suppressed due to low confidence (1)

extension/package.json:33

  • The MCP auto-registration logic identifies Aspire workspaces via .aspire/settings.json, but activationEvents don’t include that file. In a workspace that has .aspire/settings.json but no **/*.csproj / **/apphost.cs, the extension won’t activate and the MCP server won’t be registered. Consider adding workspaceContains:**/.aspire/settings.json to activationEvents.
    "onDebugDynamicConfigurations:aspire",
    "workspaceContains:**/*.csproj",
    "onView:workbench.view.debug",
    "workspaceContains:**/apphost.cs",
    "onCommand:aspire-vscode.installCliStable",

You can also share your feedback on Copilot code review. Take the survey.

adamint and others added 2 commits March 3, 2026 17:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@adamint adamint enabled auto-merge (squash) March 4, 2026 03:35
@davidfowl
Copy link
Contributor

I think this was a good idea before we were headed the CLI route. I think we should make this optional.

@adamint adamint disabled auto-merge March 4, 2026 06:45
@adamint
Copy link
Member Author

adamint commented Mar 4, 2026

I think this was a good idea before we were headed the CLI route. I think we should make this optional.

We can add a setting to disable?

@davidfowl
Copy link
Contributor

We dont want the mcp by default in 13.2, see #14837

@adamint adamint enabled auto-merge (squash) March 4, 2026 14:36
@adamint adamint changed the title Auto-register Aspire MCP server in VS Code extension Allow registering Aspire MCP server in VS Code extension Mar 4, 2026
@adamint adamint merged commit ab8e3d9 into microsoft:release/13.2 Mar 4, 2026
384 of 385 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 4, 2026
Copilot AI pushed a commit that referenced this pull request Mar 10, 2026
* Auto-register Aspire MCP server in VS Code extension

Register McpServerDefinitionProvider so the Aspire MCP server
(aspire agent mcp) appears automatically in VS Code's MCP tools
list for Aspire workspaces, eliminating the need for users to
run 'aspire agent init' or manually configure .vscode/mcp.json.

* Update extension/src/mcp/AspireMcpServerDefinitionProvider.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update extension/src/mcp/AspireMcpServerDefinitionProvider.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* add a setting whether to register mcp (false by default)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants