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?

@github-actions
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 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.
@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
Member

Choose a reason for hiding this comment

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

@JamesNK This is a great question and something we're going to have to handle. Something to file...

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)

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

Done.

It's defaulted in the app host layer. Need to do it there because the app host needs to tell the dashboard what the public URL of the MCP server is. Dashboard uses the public URL, not the proxy endpoint URL, to display in the UI what the MCP endpoint is.

@mitchdenny
Copy link
Member

Overall, I think this looks good. I am wondering whether we should do something more MCP-specific in the resource model beyond allowing resource command execution. For example, should we allow developers to be able to register resource specific MCP tools.

var builder = DistributedApplication.CreateBuilder(args);
builder.AddPostgres(...)
  .WithExecuteQueryTool(...);

@JamesNK
Copy link
Member Author

JamesNK commented Oct 26, 2025

No one has asked for it. Not a V1 feature.

If people put forward where it would be used then it could be considered in the future.

@JamesNK JamesNK force-pushed the jamesnk/dashboardmcp branch from 29cafc3 to 125f323 Compare October 26, 2025 11:07
Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

Lets get this in today (so we can focus on the http vs http problems and how to mitigate)

@mitchdenny
Copy link
Member

Lets get this in today (so we can focus on the http vs http problems and how to mitigate)

Agree. I think the HTTPS issue will be an adoption blocker for this and it would be great to have a workaround.

@mitchdenny
Copy link
Member

Created an issue to track a limitation of our current approach: #12394

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

TLS issue aside this worked really well.

@JamesNK JamesNK enabled auto-merge (squash) October 27, 2025 03:04
@JamesNK JamesNK merged commit 4e6589b into main Oct 27, 2025
305 checks passed
@JamesNK JamesNK deleted the jamesnk/dashboardmcp branch October 27, 2025 03:15
@dotnet-policy-service dotnet-policy-service bot added this to the 13.0 milestone Oct 27, 2025
radical pushed a commit that referenced this pull request Oct 29, 2025
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

6 participants