Skip to content

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Oct 18, 2025

Description

Additionals in dashboard MCP server PR:

  • MCP server with access to tools from AI chat
  • MCP endpoint
  • Header icon and dialog for getting MCP details
  • API key auth for MCP server
  • Integration tests

Fixes #10957

MCP dialog below. Description and instructions to add MCP server are work in progress and will be finalized in follow up PRs:

image

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copy link
Contributor

github-actions bot commented Oct 18, 2025

🚀 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 -- 12148

Or

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

Copy link
Contributor

@Copilot 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

Adds MCP server support to the dashboard, including configuration, authentication, endpoint hosting, UI integration, and integration tests.

  • Introduces MCP endpoint, auth modes (unsecured/API key), environment/config options, and server tools.
  • Refactors telemetry/log limiting helpers and adds MCP-related warnings and UI dialog.
  • Adds integration tests for MCP endpoint and API key behavior.

Reviewed Changes

Copilot reviewed 54 out of 57 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
AssistantChatDataContextTests.cs Removed legacy limit tests after refactor to AIHelpers.
AIHelpersTests.cs Added limit tests now targeting AIHelpers.
StartupTests.cs Added log assertion for unsecured MCP warning.
DashboardServerFixture.cs Injects MCP auth mode config for tests.
McpServiceTests.cs New integration tests for MCP endpoint and API key auth.
IntegrationTestHelpers.cs Adds MCP URL configuration.
FrontendBrowserTokenAuthTests.cs Adds MCP unsecured warning assertion.
KnownConfigNames.cs Adds MCP endpoint env var constant.
DashboardConfigNames.cs Adds MCP-related config keys.
DistributedApplicationBuilder.cs Persists generated MCP API key to user secrets.
TransportOptionsValidator.cs Validates MCP endpoint URL parsing.
DashboardOptions.cs (Hosting) Adds MCP endpoint/api key options.
DashboardEventHandlers.cs Adds MCP endpoint handling and env var population.
BrowserStorageKeys.cs Adds storage key for MCP unsecured message dismissal.
IDashboardClient.cs / DashboardClient.cs Exposes GetResources with locking.
Localization .xlf and .resx files Adds MCP unsecured warning strings.
AssistantChatDataContext.cs Moves limit logic to AIHelpers.
AIHelpers.cs Centralizes limits and list trimming logic.
ResourceMcpTools.cs Implements MCP server tools (resources, logs, traces, commands).
McpServerModel.cs Defines MCP server model + source gen context.
McpExtensions.cs Registers MCP server and tools via SDK.
Mcp* authentication handlers Adds MCP auth modes and composite handler.
DashboardWebApplication.cs Hosts MCP server, maps /mcp, configures endpoint & auth.
Validate/PostConfigureDashboardOptions.cs Parses/validates MCP options and defaults.
DashboardOptions.cs (Dashboard) Adds McpOptions class with parsing.
MainLayout.* Adds MCP dialog and unsecured message display.
McpServerDialog.* UI dialog for MCP server config & install links.
AspireIcons.cs Adds MCP icon.
ConnectionType* Adds MCP connection type & scheme.
Aspire.Dashboard.csproj Adds ModelContextProtocol packages & Razor feature flag.
RunCommand.cs Adds MCP endpoint env var for CLI run profile.
launchSettings.json Adds MCP endpoint env vars for playground app.
Directory.Packages.props Updates MCP protocol package versions.
Files not reviewed (1)
  • src/Aspire.Dashboard/Resources/Layout.Designer.cs: Language not supported


return response;
}
catch { }
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Swallowing all exceptions without logging obscures failures in GetResourceGraph; replace with a specific exception catch or log the exception (at least debug/trace) to aid diagnostics.

Copilot uses AI. Check for mistakes.

@if (McpEnabled)
{
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae condimentum nulla, nec viverra purus. Morbi cursus egestas leo, eget lacinia quam hendrerit non.
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Placeholder "Lorem ipsum" text should be replaced with real guidance explaining MCP server usage (e.g. purpose, how to install, security considerations); substitute with actionable, product-appropriate content.

Suggested change
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae condimentum nulla, nec viverra purus. Morbi cursus egestas leo, eget lacinia quam hendrerit non.
The Aspire MCP (Model Context Protocol) server enables advanced integration with development tools such as Visual Studio Code. By running the MCP server, you can connect your Aspire application to supported IDEs for enhanced debugging, diagnostics, and management features.

Copilot uses AI. Check for mistakes.

</p>
<h5>MCP JSON</h5>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae condimentum nulla, nec viverra purus. Morbi cursus egestas leo, eget lacinia quam hendrerit non.
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Second occurrence of placeholder text—replace with an explanation of the MCP JSON configuration (fields meaning, how to use in clients, security of headers).

Suggested change
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae condimentum nulla, nec viverra purus. Morbi cursus egestas leo, eget lacinia quam hendrerit non.
The MCP JSON configuration describes how clients can connect to and authenticate with the Aspire MCP server. Each field in the JSON has a specific purpose:
<ul>
<li><strong>endpoint</strong>: The base URL of the MCP server.</li>
<li><strong>headers</strong>: Optional HTTP headers (such as authentication tokens) that clients should include in requests. <strong>Keep these headers secure</strong>—they may contain sensitive information.</li>
<li><strong>protocolVersion</strong>: The version of the MCP protocol supported by the server.</li>
<!-- Add other fields as appropriate -->
</ul>
<br />
To use this configuration, import the JSON into your client or tool (such as VS Code) to enable secure and authenticated communication with the MCP server. <strong>Do not share this configuration publicly if it contains sensitive headers.</strong>

Copilot uses AI. Check for mistakes.

@davidfowl
Copy link
Member

Tried this but the template isn't updated with the right config so I cant see the mcp server 😄

}

[McpServerTool(Name = "aspire_execute_command"), Description("Executes a command on a resource.")]
public static async Task ExecuteCommand(IDashboardClient dashboardClient, [Description("The resource name")] string resourceName, [Description("The command name")] string commandName)
Copy link
Contributor

Choose a reason for hiding this comment

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

what would happen here if the command uses the interactive service and prompt the user for inputs?

Copy link
Contributor

@Meir017 Meir017 left a comment

Choose a reason for hiding this comment

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

instead of adding the mcp-vscode images, can we use markdown? similar to this https://github.com/github/github-mcp-server/blob/main/README.md?plain=1#L19C1-L19C655?

@JamesNK
Copy link
Member Author

JamesNK commented Oct 21, 2025

instead of adding the mcp-vscode images, can we use markdown? similar to this github/github-mcp-server@main/README.md?plain=1#L19C1-L19C655?

Those aren't used anymore. UI already uses SVG. I'll remove the old images.

I don't want to reference an external badge service. Using SVG generated by them has the same effect without the delay in calling another website.

@JamesNK
Copy link
Member Author

JamesNK commented Oct 21, 2025

Tried this but the template isn't updated with the right config so I cant see the mcp server 😄

@davidfowl What should happen if there isn't MCP server config? All existing Aspire apps won't have an MCP URL in config.

Two options:

  1. Viewing the MCP dialog displays a message that MCP isn't configured and give instructions for adding it to launchSettings.json
  2. Or, default the mcp endpoint to the browser endpoint if an MCP endpoint isn't specifically defined. MCP would just work without extra configuraiton.

@davidfowl
Copy link
Member

Viewing the MCP dialog displays a message that MCP isn't configured and give instructions for adding it to launchSettings.json

Yes

Or, default the mcp endpoint to the browser endpoint if an MCP endpoint isn't specifically defined. MCP would just work without extra configuraiton.

This sounds better.

If we do the latter, we don't need to update the templates. We can do both though. Thoughts? Maybe we allow configuring the MCP server on a different endpoint but by default it can hang off the dashboard endpoint.

@davidfowl
Copy link
Member

@JamesNK
Copy link
Member Author

JamesNK commented Oct 21, 2025

If we do the latter, we don't need to update the templates. We can do both though. Thoughts? Maybe we allow configuring the MCP server on a different endpoint but by default it can hang off the dashboard endpoint.

I think MCP should be:

  • Configurable as its own endpoint and have new configuration added to templates
  • Default to the frontend endpoint if not configured for backwards compatibility
  • If you really don't want MCP, there will be a config flag to disable it (will also hide the icon in the dashboard)

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 built-in MCP server (preview) to dashboard with streaming HTTP and minimal tool surface

3 participants