-
Notifications
You must be signed in to change notification settings - Fork 704
Add dashboard MCP server #12148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JamesNK
wants to merge
7
commits into
main
Choose a base branch
from
jamesnk/dashboardmcp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add dashboard MCP server #12148
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7f74c9
Add dashboard MCP server
JamesNK 11bf681
Update
JamesNK 61fcd05
Revert deps
JamesNK b26c9c7
Improve MCP icon, remove duplication
JamesNK 6cf84cd
Improve MCP dialog
JamesNK 5fa3b7d
Clean up
JamesNK f3b2b7e
Add MCP endpoint, tests
JamesNK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ public enum ConnectionType | |
{ | ||
None, | ||
Frontend, | ||
Otlp | ||
Otlp, | ||
Mcp | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/Aspire.Dashboard/Components/Dialogs/McpServerDialog.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||||||||||||||||||
@implements IDialogContentComponent | ||||||||||||||||||||||
|
||||||||||||||||||||||
@using Aspire.Dashboard.Components.CustomIcons | ||||||||||||||||||||||
@using Aspire.Dashboard.Configuration | ||||||||||||||||||||||
@using Aspire.Dashboard.Mcp | ||||||||||||||||||||||
@using Aspire.Dashboard.Model.Markdown | ||||||||||||||||||||||
@using Microsoft.AspNetCore.Components | ||||||||||||||||||||||
@using Microsoft.Extensions.Options | ||||||||||||||||||||||
@using System.Text.Encodings.Web | ||||||||||||||||||||||
@using System.Text.Json | ||||||||||||||||||||||
|
||||||||||||||||||||||
<div class="mcp-server-dialog-content"> | ||||||||||||||||||||||
@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. | ||||||||||||||||||||||
</p> | ||||||||||||||||||||||
<h5>Add to VS Code</h5> | ||||||||||||||||||||||
<p> | ||||||||||||||||||||||
<a href="@($"vscode:mcp/install?{Uri.EscapeDataString(_mcpServerJson)}")"> | ||||||||||||||||||||||
<svg xmlns="http://www.w3.org/2000/svg" width="225" height="20" role="img" aria-label="VS Code: Install Aspire MCP Server"> | ||||||||||||||||||||||
<title>VS Code: Install Aspire MCP Server</title> | ||||||||||||||||||||||
<g shape-rendering="crispEdges"><rect width="74" height="20" fill="#555" /><rect x="74" width="151" height="20" fill="#0098ff" /></g> | ||||||||||||||||||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><image x="5" y="3" width="14" height="14" href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJ3aGl0ZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRpdGxlPk1vZGVsIENvbnRleHQgUHJvdG9jb2w8L3RpdGxlPjxwYXRoIGQ9Ik0xMy44NSAwYTQuMTYgNC4xNiAwIDAgMC0yLjk1IDEuMjE3TDEuNDU2IDEwLjY2YS44MzUuODM1IDAgMCAwIDAgMS4xOC44MzUuODM1IDAgMCAwIDEuMTggMGw5LjQ0Mi05LjQ0MmEyLjQ5IDIuNDkgMCAwIDEgMy41NDEgMCAyLjQ5IDIuNDkgMCAwIDEgMCAzLjU0MUw4LjU5IDEyLjk3bC0uMS4xYS44MzUuODM1IDAgMCAwIDAgMS4xOC44MzUuODM1IDAgMCAwIDEuMTggMGwuMS0uMDk4IDcuMDMtNy4wMzRhMi40OSAyLjQ5IDAgMCAxIDMuNTQyIDBsLjA0OS4wNWEyLjQ5IDIuNDkgMCAwIDEgMCAzLjU0bC04LjU0IDguNTRhMS45NiAxLjk2IDAgMCAwIDAgMi43NTVsMS43NTMgMS43NTNhLjgzNS44MzUgMCAwIDAgMS4xOCAwIC44MzUuODM1IDAgMCAwIDAtMS4xOGwtMS43NTMtMS43NTNhLjI2Ni4yNjYgMCAwIDEgMC0uMzk0bDguNTQtOC41NGE0LjE4NSA0LjE4NSAwIDAgMCAwLTUuOWwtLjA1LS4wNWE0LjE2IDQuMTYgMCAwIDAtMi45NS0xLjIxOGMtLjIgMC0uNDAxLjAyLS42LjA0OGE0LjE3IDQuMTcgMCAwIDAtMS4xNy0zLjU1MkE0LjE2IDQuMTYgMCAwIDAgMTMuODUgMG0wIDMuMzMzYS44NC44NCAwIDAgMC0uNTkuMjQ1TDYuMjc1IDEwLjU2YTQuMTg2IDQuMTg2IDAgMCAwIDAgNS45MDIgNC4xODYgNC4xODYgMCAwIDAgNS45MDIgMEwxOS4xNiA5LjQ4YS44MzUuODM1IDAgMCAwIDAtMS4xOC44MzUuODM1IDAgMCAwLTEuMTggMGwtNi45ODUgNi45ODRhMi40OSAyLjQ5IDAgMCAxLTMuNTQgMCAyLjQ5IDIuNDkgMCAwIDEgMC0zLjU0bDYuOTgzLTYuOTg1YS44MzUuODM1IDAgMCAwIDAtMS4xOC44NC44NCAwIDAgMC0uNTktLjI0NSIvPjwvc3ZnPg==" /><text x="465" y="140" transform="scale(.1)" fill="#fff" textLength="470">VS Code</text><text x="1485" y="140" transform="scale(.1)" fill="#fff" textLength="1410">Install Aspire MCP Server</text></g> | ||||||||||||||||||||||
</svg> | ||||||||||||||||||||||
@* | ||||||||||||||||||||||
Generated from: | ||||||||||||||||||||||
https://img.shields.io/badge/VS_Code-Install_Aspire_MCP_Server-0098FF?style=flat-square&logo=modelcontextprotocol&logoColor=white | ||||||||||||||||||||||
*@ | ||||||||||||||||||||||
</a> | ||||||||||||||||||||||
</p> | ||||||||||||||||||||||
<p> | ||||||||||||||||||||||
<a href="@($"vscode-insiders:mcp/install?{Uri.EscapeDataString(_mcpServerJson)}")"> | ||||||||||||||||||||||
<svg xmlns="http://www.w3.org/2000/svg" width="273" height="20" role="img" aria-label="VS Code Insiders: Install Aspire MCP Server"> | ||||||||||||||||||||||
<title>VS Code Insiders: Install Aspire MCP Server</title> | ||||||||||||||||||||||
<g shape-rendering="crispEdges"><rect width="122" height="20" fill="#555" /><rect x="122" width="151" height="20" fill="#65bba5" /></g> | ||||||||||||||||||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><image x="5" y="3" width="14" height="14" href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJ3aGl0ZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRpdGxlPk1vZGVsIENvbnRleHQgUHJvdG9jb2w8L3RpdGxlPjxwYXRoIGQ9Ik0xMy44NSAwYTQuMTYgNC4xNiAwIDAgMC0yLjk1IDEuMjE3TDEuNDU2IDEwLjY2YS44MzUuODM1IDAgMCAwIDAgMS4xOC44MzUuODM1IDAgMCAwIDEuMTggMGw5LjQ0Mi05LjQ0MmEyLjQ5IDIuNDkgMCAwIDEgMy41NDEgMCAyLjQ5IDIuNDkgMCAwIDEgMCAzLjU0MUw4LjU5IDEyLjk3bC0uMS4xYS44MzUuODM1IDAgMCAwIDAgMS4xOC44MzUuODM1IDAgMCAwIDEuMTggMGwuMS0uMDk4IDcuMDMtNy4wMzRhMi40OSAyLjQ5IDAgMCAxIDMuNTQyIDBsLjA0OS4wNWEyLjQ5IDIuNDkgMCAwIDEgMCAzLjU0bC04LjU0IDguNTRhMS45NiAxLjk2IDAgMCAwIDAgMi43NTVsMS43NTMgMS43NTNhLjgzNS44MzUgMCAwIDAgMS4xOCAwIC44MzUuODM1IDAgMCAwIDAtMS4xOGwtMS43NTMtMS43NTNhLjI2Ni4yNjYgMCAwIDEgMC0uMzk0bDguNTQtOC41NGE0LjE4NSA0LjE4NSAwIDAgMCAwLTUuOWwtLjA1LS4wNWE0LjE2IDQuMTYgMCAwIDAtMi45NS0xLjIxOGMtLjIgMC0uNDAxLjAyLS42LjA0OGE0LjE3IDQuMTcgMCAwIDAtMS4xNy0zLjU1MkE0LjE2IDQuMTYgMCAwIDAgMTMuODUgMG0wIDMuMzMzYS44NC44NCAwIDAgMC0uNTkuMjQ1TDYuMjc1IDEwLjU2YTQuMTg2IDQuMTg2IDAgMCAwIDAgNS45MDIgNC4xODYgNC4xODYgMCAwIDAgNS45MDIgMEwxOS4xNiA5LjQ4YS44MzUuODM1IDAgMCAwIDAtMS4xOC44MzUuODM1IDAgMCAwLTEuMTggMGwtNi45ODUgNi45ODRhMi40OSAyLjQ5IDAgMCAxLTMuNTQgMCAyLjQ5IDIuNDkgMCAwIDEgMC0zLjU0bDYuOTgzLTYuOTg1YS44MzUuODM1IDAgMCAwIDAtMS4xOC44NC44NCAwIDAgMC0uNTktLjI0NSIvPjwvc3ZnPg==" /><text x="705" y="140" transform="scale(.1)" fill="#fff" textLength="950">VS Code Insiders</text><text x="1965" y="140" transform="scale(.1)" fill="#fff" textLength="1410">Install Aspire MCP Server</text></g> | ||||||||||||||||||||||
</svg> | ||||||||||||||||||||||
@* | ||||||||||||||||||||||
Generated from: | ||||||||||||||||||||||
https://img.shields.io/badge/VS_Code_Insiders-Install_Aspire_MCP_Server-65BBA5?style=flat-square&logo=modelcontextprotocol&logoColor=white | ||||||||||||||||||||||
*@ | ||||||||||||||||||||||
</a> | ||||||||||||||||||||||
</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. | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||
</p> | ||||||||||||||||||||||
<MarkdownRenderer Markdown="@GetJsonConfigurationMarkdown()" MarkdownProcessor="@_markdownProcessor" /> | ||||||||||||||||||||||
} | ||||||||||||||||||||||
else | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
<p> | ||||||||||||||||||||||
MCP isn't configured. | ||||||||||||||||||||||
</p> | ||||||||||||||||||||||
} | ||||||||||||||||||||||
</div> |
84 changes: 84 additions & 0 deletions
84
src/Aspire.Dashboard/Components/Dialogs/McpServerDialog.razor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text.Json; | ||
using Aspire.Dashboard.Configuration; | ||
using Aspire.Dashboard.Mcp; | ||
using Aspire.Dashboard.Model.Markdown; | ||
using Aspire.Dashboard.Resources; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.Extensions.Localization; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
namespace Aspire.Dashboard.Components.Dialogs; | ||
|
||
public partial class McpServerDialog | ||
{ | ||
[CascadingParameter] | ||
public FluentDialog Dialog { get; set; } = default!; | ||
|
||
[Inject] | ||
public required IStringLocalizer<ControlsStrings> ControlsStringsLoc { get; init; } | ||
|
||
[Inject] | ||
public required IStringLocalizer<Resources.Dialogs> Loc { get; init; } | ||
|
||
[Inject] | ||
public required NavigationManager NavigationManager { get; init; } | ||
|
||
[Inject] | ||
public required IOptions<DashboardOptions> DashboardOptions { get; init; } | ||
|
||
private MarkdownProcessor _markdownProcessor = default!; | ||
private string? _mcpServerJson; | ||
private string? _mcpUrl; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
_markdownProcessor = new MarkdownProcessor(ControlsStringsLoc, MarkdownHelpers.SafeUrlSchemes, []); | ||
_mcpUrl = DashboardOptions.Value.Mcp.PublicUrl ?? DashboardOptions.Value.Mcp.EndpointUrl; | ||
|
||
if (McpEnabled) | ||
{ | ||
_mcpServerJson = GetMcpServerJson(); | ||
} | ||
} | ||
|
||
[MemberNotNullWhen(true, nameof(_mcpServerJson))] | ||
[MemberNotNullWhen(true, nameof(_mcpUrl))] | ||
private bool McpEnabled => !string.IsNullOrEmpty(_mcpUrl); | ||
|
||
private string GetMcpServerJson() | ||
{ | ||
Dictionary<string, string>? headers = null; | ||
|
||
if (DashboardOptions.Value.Mcp.AuthMode == McpAuthMode.ApiKey) | ||
{ | ||
headers = new Dictionary<string, string> | ||
{ | ||
[McpApiKeyAuthenticationHandler.ApiKeyHeaderName] = DashboardOptions.Value.Mcp.PrimaryApiKey! | ||
}; | ||
} | ||
|
||
var url = new Uri(baseUri: new Uri(_mcpUrl!), relativeUri: "/mcp").ToString(); | ||
|
||
return JsonSerializer.Serialize( | ||
new McpServerModel | ||
{ | ||
Name = "aspire-dashboard", | ||
Type = "http", | ||
Url = url, | ||
Headers = headers | ||
}, | ||
McpServerModelContext.Default.McpServerModel); | ||
} | ||
|
||
private string GetJsonConfigurationMarkdown() => | ||
$""" | ||
```json | ||
{_mcpServerJson} | ||
``` | ||
"""; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
Copilot uses AI. Check for mistakes.