Skip to content

Commit 10c9860

Browse files
committed
Fix config file JSON
1 parent f000ac7 commit 10c9860

File tree

5 files changed

+91
-44
lines changed

5 files changed

+91
-44
lines changed

src/Aspire.Dashboard/Components/Dialogs/McpServerDialog.razor

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
@if (McpEnabled)
1414
{
1515
<p>
16-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae condimentum nulla, nec viverra purus. Morbi cursus egestas leo, eget lacinia quam hendrerit non.
16+
Aspire MCP connects AI assistants to Aspire app data. AI can use Aspire MCP to get information about app resources, health checks, commands, console logs and real-time telemetry.
17+
For more information, see <a href="" target="_blank">Use Aspire MCP with AI</a>.
1718
</p>
1819
<h5>Add to VS Code</h5>
1920
<p>
20-
<a href="@($"vscode:mcp/install?{Uri.EscapeDataString(_mcpServerJson)}")">
21+
<a href="@($"vscode:mcp/install?{Uri.EscapeDataString(_mcpServerInstallButtonJson)}")">
2122
<svg xmlns="http://www.w3.org/2000/svg" width="225" height="20" role="img" aria-label="VS Code: Install Aspire MCP Server">
2223
<title>VS Code: Install Aspire MCP Server</title>
2324
<g shape-rendering="crispEdges"><rect width="74" height="20" fill="#555" /><rect x="74" width="151" height="20" fill="#0098ff" /></g>
@@ -28,9 +29,8 @@
2829
https://img.shields.io/badge/VS_Code-Install_Aspire_MCP_Server-0098FF?style=flat-square&logo=modelcontextprotocol&logoColor=white
2930
*@
3031
</a>
31-
</p>
32-
<p>
33-
<a href="@($"vscode-insiders:mcp/install?{Uri.EscapeDataString(_mcpServerJson)}")">
32+
&nbsp;&nbsp;
33+
<a href="@($"vscode-insiders:mcp/install?{Uri.EscapeDataString(_mcpServerInstallButtonJson)}")">
3434
<svg xmlns="http://www.w3.org/2000/svg" width="273" height="20" role="img" aria-label="VS Code Insiders: Install Aspire MCP Server">
3535
<title>VS Code Insiders: Install Aspire MCP Server</title>
3636
<g shape-rendering="crispEdges"><rect width="122" height="20" fill="#555" /><rect x="122" width="151" height="20" fill="#65bba5" /></g>
@@ -42,16 +42,26 @@
4242
*@
4343
</a>
4444
</p>
45-
<h5>MCP JSON</h5>
4645
<p>
47-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae condimentum nulla, nec viverra purus. Morbi cursus egestas leo, eget lacinia quam hendrerit non.
46+
<div class="block-warning">
47+
<div class="block-warning-icon">
48+
<FluentIcon Value="new Icons.Filled.Size16.Warning()" Color="Color.Warning" />
49+
</div>
50+
51+
<div class="block-warning-message">
52+
<span class="title">VS Code limitation</span>
53+
As of October 2025, VS Code does not support using Aspire MCP over HTTPS.
54+
<br />
55+
<br />
56+
To use VS Code with Aspire MCP, configure the MCP endpoint to use HTTP instead of HTTPSfor example, by launching the app host with the <code>http</code> profile.
57+
<a href="">More information</a>
58+
</div>
59+
</div>
4860
</p>
49-
<MarkdownRenderer Markdown="@GetJsonConfigurationMarkdown()" MarkdownProcessor="@_markdownProcessor" />
50-
}
51-
else
52-
{
61+
<h5>MCP JSON</h5>
5362
<p>
54-
MCP isn't configured.
63+
Add Aspire MCP to your AI tools by including the following JSON in your AI client's <code>mcp.json</code> file.
5564
</p>
65+
<MarkdownRenderer Markdown="@GetJsonConfigurationMarkdown()" MarkdownProcessor="@_markdownProcessor" />
5666
}
5767
</div>

src/Aspire.Dashboard/Components/Dialogs/McpServerDialog.razor.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public partial class McpServerDialog
3232
public required IOptions<DashboardOptions> DashboardOptions { get; init; }
3333

3434
private MarkdownProcessor _markdownProcessor = default!;
35-
private string? _mcpServerJson;
35+
private string? _mcpServerInstallButtonJson;
36+
private string? _mcpServerConfigFileJson;
3637
private string? _mcpUrl;
3738

3839
protected override void OnInitialized()
@@ -42,19 +43,19 @@ protected override void OnInitialized()
4243

4344
if (McpEnabled)
4445
{
45-
_mcpServerJson = GetMcpServerJson();
46+
(_mcpServerInstallButtonJson, _mcpServerConfigFileJson) = GetMcpServerInstallButtonJson();
4647
}
4748
else
4849
{
4950
throw new InvalidOperationException("MCP server is not enabled or configured.");
5051
}
5152
}
5253

53-
[MemberNotNullWhen(true, nameof(_mcpServerJson))]
54+
[MemberNotNullWhen(true, nameof(_mcpServerInstallButtonJson))]
5455
[MemberNotNullWhen(true, nameof(_mcpUrl))]
5556
private bool McpEnabled => !DashboardOptions.Value.Mcp.Disabled.GetValueOrDefault() && !string.IsNullOrEmpty(_mcpUrl);
5657

57-
private string GetMcpServerJson()
58+
private (string InstallButtonJson, string ConfigFileJson) GetMcpServerInstallButtonJson()
5859
{
5960
Dictionary<string, string>? headers = null;
6061

@@ -67,22 +68,40 @@ private string GetMcpServerJson()
6768
}
6869

6970
var url = new Uri(baseUri: new Uri(_mcpUrl!), relativeUri: "/mcp").ToString();
71+
var name = "aspire-dashboard";
7072

71-
return JsonSerializer.Serialize(
72-
new McpServerModel
73+
var installButtonJson = JsonSerializer.Serialize(
74+
new McpInstallButtonServerModel
7375
{
74-
Name = "aspire-dashboard",
76+
Name = name,
7577
Type = "http",
7678
Url = url,
7779
Headers = headers
7880
},
79-
McpServerModelContext.Default.McpServerModel);
81+
McpInstallButtonModelContext.Default.McpInstallButtonServerModel);
82+
83+
var configFileJson = JsonSerializer.Serialize(
84+
new McpJsonFileServerModel
85+
{
86+
Servers = new()
87+
{
88+
[name] = new()
89+
{
90+
Type = "http",
91+
Url = url,
92+
Headers = headers
93+
}
94+
}
95+
},
96+
McpConfigFileModelContext.Default.McpJsonFileServerModel);
97+
98+
return (installButtonJson, configFileJson);
8099
}
81100

82101
private string GetJsonConfigurationMarkdown() =>
83102
$"""
84103
```json
85-
{_mcpServerJson}
104+
{_mcpServerConfigFileJson}
86105
```
87106
""";
88107
}

src/Aspire.Dashboard/Components/Layout/MainLayout.razor.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,11 @@ private async Task LaunchMcpAsync()
209209
{
210210
Title = "Aspire MCP server",
211211
DismissTitle = DialogsLoc[nameof(Resources.Dialogs.DialogCloseButtonText)],
212-
PrimaryAction = "Close",
213-
PrimaryActionEnabled = true,
212+
PrimaryAction = null,
214213
SecondaryAction = null,
215214
TrapFocus = true,
216215
Modal = true,
217-
Alignment = HorizontalAlignment.Center,
218216
Width = "700px",
219-
Height = "auto",
220217
Id = McpDialogId,
221218
OnDialogClosing = EventCallback.Factory.Create<DialogInstance>(this, HandleDialogClose)
222219
};
@@ -233,6 +230,7 @@ private async Task LaunchMcpAsync()
233230

234231
_openPageDialog = await DialogService.ShowDialogAsync<McpServerDialog>(parameters).ConfigureAwait(true);
235232
}
233+
236234
private async Task LaunchHelpAsync()
237235
{
238236
DialogParameters parameters = new()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Text.Json.Serialization;
5+
6+
namespace Aspire.Dashboard.Mcp;
7+
8+
// Used by the VS Code install button. The server name is included in the JSON object.
9+
public sealed class McpInstallButtonServerModel
10+
{
11+
public required string Name { get; init; }
12+
public required string Type { get; init; }
13+
public required string Url { get; init; }
14+
public Dictionary<string, string>? Headers { get; init; }
15+
}
16+
17+
// Used by the VS Code mcp.json file config. Server names are keys in a JSON object.
18+
public sealed class McpJsonFileServerModel
19+
{
20+
public required Dictionary<string, McpJsonFileServerInstanceModel> Servers { get; init; }
21+
}
22+
23+
public sealed class McpJsonFileServerInstanceModel
24+
{
25+
public required string Type { get; init; }
26+
public required string Url { get; init; }
27+
public Dictionary<string, string>? Headers { get; init; }
28+
}
29+
30+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
31+
[JsonSerializable(typeof(McpInstallButtonServerModel))]
32+
[JsonSerializable(typeof(Dictionary<string, string>))]
33+
public sealed partial class McpInstallButtonModelContext : JsonSerializerContext;
34+
35+
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, WriteIndented = true)]
36+
[JsonSerializable(typeof(McpJsonFileServerModel))]
37+
[JsonSerializable(typeof(McpJsonFileServerInstanceModel))]
38+
[JsonSerializable(typeof(Dictionary<string, string>))]
39+
public sealed partial class McpConfigFileModelContext : JsonSerializerContext;

src/Aspire.Dashboard/Mcp/McpServerModel.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)