Allow registering Aspire MCP server in VS Code extension#14917
Allow registering Aspire MCP server in VS Code extension#14917adamint merged 6 commits intomicrosoft:release/13.2from
Conversation
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.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14917Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14917" |
There was a problem hiding this comment.
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
McpServerDefinitionProvideron extension activation to surface anaspire agent mcpstdio MCP server definition. - Add temporary TypeScript type declarations for the MCP API until
@types/vscodeincludes 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.jsonbut no**/*.csproj/**/apphost.cs, the extension won’t activate and the MCP server won’t be registered. Consider addingworkspaceContains:**/.aspire/settings.jsonto 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
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? |
|
We dont want the mcp by default in 13.2, see #14837 |
* 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>
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 initor manually create.vscode/mcp.json— the Aspire MCP server (aspire agent mcp) just appears automatically.How it works
McpServerDefinitionProvidervia the stable VS Code APIvscode.lm.registerMcpServerDefinitionProvider..aspire/settings.json).McpStdioServerDefinitionforaspire agent mcp, which makes the Aspire MCP tools (list resources, view logs, traces, etc.) available to Copilot and other AI agents automatically.typeofcheck 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, andregisterMcpServerDefinitionProvidertypes are part of VS Code's stable API (present invscode.d.tssince VS Code 1.105). However, the@types/vscodenpm package has not yet published these types (even the latest 1.109.0 release is missing them). The filevscode.proposed.mcpServerDefinitions.d.tsprovides the type declarations needed for compilation until@types/vscodecatches up. Despite the filename containing "proposed", the registration API itself is stable — the actual proposed portion (lm.mcpServerDefinitionsread-only list) is not used here.Files changed
extension/src/mcp/AspireMcpServerDefinitionProvider.ts— New provider that supplies the Aspire MCP server definitionextension/src/vscode.proposed.mcpServerDefinitions.d.ts— Type declarations for the MCP API (until@types/vscodepublishes them)extension/package.json— AddedmcpServerDefinitionProviderscontribution pointextension/package.nls.json— Localization string for the MCP provider labelextension/src/extension.ts— Registers the provider during activationChecklist