Skip to content

Commit 7c59687

Browse files
authored
Add availability check for NuGet Solver MCP Server tool (#7149)
1 parent 3a2648c commit 7c59687

17 files changed

Lines changed: 90 additions & 1 deletion

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Telemetry/FixVulnerabilitiesWithCopilotErrorType.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public enum FixVulnerabilitiesWithCopilotErrorType
1010
ServiceBrokerNotAvailable,
1111
CopilotServiceNotAvailable,
1212
McpToolServiceNotAvailable,
13-
CopilotAccessDenied
13+
CopilotAccessDenied,
14+
NuGetSolverNotAvailable,
1415
}
1516
}

src/NuGet.Clients/NuGet.Tools/FixVulnerablitiesService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Collections.Generic;
88
using System.ComponentModel.Composition;
9+
using System.Linq;
910
using System.Threading;
1011
using System.Threading.Tasks;
1112
using Microsoft.ServiceHub.Framework;
@@ -26,6 +27,8 @@ internal class FixVulnerablitiesService : IFixVulnerabilitiesService
2627
private const string AgentModeResponderServiceMoniker = "Microsoft.VisualStudio.Copilot.AgentModeResponder";
2728
private const string AuthStatusDetermined = "c936efcc-6baa-4ad3-9c2b-7ba750acf18f";
2829
private const string ServiceName = "Microsoft.VisualStudio.Copilot.SolutionContextProvider";
30+
private const string NuGetMCPServerName = "nuget";
31+
private const string NuGetSolverToolName = "get-nuget-solver";
2932

3033
private static readonly Guid CopilotReadyUIContext = new(AuthStatusDetermined);
3134
private static readonly ServiceRpcDescriptor ProviderDescriptor = CopilotDescriptors.CreateContextProviderDescriptor(ServiceName);
@@ -99,6 +102,13 @@ public async Task LaunchFixVulnerabilitiesAsync(CancellationToken cancellationTo
99102
string solutionPathContext = $"The current solution file path is: {GetSolutionPath()}.";
100103
CopilotContext context = new CopilotContext(ProviderDescriptor.Moniker, ContextDescriptor, request.CorrelationId, solutionPathContext);
101104
IReadOnlyList<CopilotFunctionDescriptor> functions = await cfp.GetFunctionsAsync(request.CorrelationId, cancellationToken);
105+
if (functions is null || !functions.Any(f => string.Equals(f.Name, $"{NuGetMCPServerName}_{NuGetSolverToolName}", StringComparison.OrdinalIgnoreCase)))
106+
{
107+
SendTelemetryEvent(FixVulnerabilitiesWithCopilotErrorType.NuGetSolverNotAvailable);
108+
ShowWarningMessage(Resources.Error_NuGetSolverNotAvailable);
109+
return;
110+
}
111+
102112
CopilotRequest requestWithFunctionsAndContext = request.WithFunctions(functions).WithContext(context);
103113

104114
try

src/NuGet.Clients/NuGet.Tools/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NuGet.Clients/NuGet.Tools/Resources.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,8 @@
292292
<value>Access denied. Please ensure you are signed in to GitHub Copilot.</value>
293293
<comment>Do not translate GitHub or Copilot</comment>
294294
</data>
295+
<data name="Error_NuGetSolverNotAvailable" xml:space="preserve">
296+
<value>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</value>
297+
<comment>Do not translate GitHub or Copilot</comment>
298+
</data>
295299
</root>

src/NuGet.Clients/NuGet.Tools/xlf/Resources.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<target state="translated">Služba MCP Tool není k dispozici. Ujistěte se, že je GitHub Copilot nainstalovaný a že jste přihlášení.</target>
4343
<note>Do not translate GitHub or Copilot</note>
4444
</trans-unit>
45+
<trans-unit id="Error_NuGetSolverNotAvailable">
46+
<source>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</source>
47+
<target state="new">The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</target>
48+
<note>Do not translate GitHub or Copilot</note>
49+
</trans-unit>
4550
<trans-unit id="Error_PackageSourceMappingPattern_Missing">
4651
<source>A package pattern must be provided.</source>
4752
<target state="translated">Je nutné zadat vzor balíčku.</target>

src/NuGet.Clients/NuGet.Tools/xlf/Resources.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<target state="translated">Der MCP-Tooldienst ist nicht verfügbar. Bitte stellen Sie sicher, dass GitHub Copilot installiert ist und eine Anmeldung erfolgt ist.</target>
4343
<note>Do not translate GitHub or Copilot</note>
4444
</trans-unit>
45+
<trans-unit id="Error_NuGetSolverNotAvailable">
46+
<source>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</source>
47+
<target state="new">The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</target>
48+
<note>Do not translate GitHub or Copilot</note>
49+
</trans-unit>
4550
<trans-unit id="Error_PackageSourceMappingPattern_Missing">
4651
<source>A package pattern must be provided.</source>
4752
<target state="translated">Ein Paketmuster muss angegeben werden.</target>

src/NuGet.Clients/NuGet.Tools/xlf/Resources.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<target state="translated">El servicio de herramientas MCP no está disponible. Asegúrese de que GitHub Copilot está instalado e iniciado sesión.</target>
4343
<note>Do not translate GitHub or Copilot</note>
4444
</trans-unit>
45+
<trans-unit id="Error_NuGetSolverNotAvailable">
46+
<source>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</source>
47+
<target state="new">The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</target>
48+
<note>Do not translate GitHub or Copilot</note>
49+
</trans-unit>
4550
<trans-unit id="Error_PackageSourceMappingPattern_Missing">
4651
<source>A package pattern must be provided.</source>
4752
<target state="translated">Se debe proporcionar un patrón de paquete.</target>

src/NuGet.Clients/NuGet.Tools/xlf/Resources.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<target state="translated">Désolé, le service MCP Tool n’est pas disponible. Veuillez vérifier que GitHub Copilot est installé et que vous êtes connecté(e).</target>
4343
<note>Do not translate GitHub or Copilot</note>
4444
</trans-unit>
45+
<trans-unit id="Error_NuGetSolverNotAvailable">
46+
<source>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</source>
47+
<target state="new">The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</target>
48+
<note>Do not translate GitHub or Copilot</note>
49+
</trans-unit>
4550
<trans-unit id="Error_PackageSourceMappingPattern_Missing">
4651
<source>A package pattern must be provided.</source>
4752
<target state="translated">Le modèle de package doit être fourni.</target>

src/NuGet.Clients/NuGet.Tools/xlf/Resources.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<target state="translated">Il servizio dello strumento MCP non è disponibile. Assicurati di aver installato ed eseguito l'accesso a GitHub Copilot.</target>
4343
<note>Do not translate GitHub or Copilot</note>
4444
</trans-unit>
45+
<trans-unit id="Error_NuGetSolverNotAvailable">
46+
<source>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</source>
47+
<target state="new">The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</target>
48+
<note>Do not translate GitHub or Copilot</note>
49+
</trans-unit>
4550
<trans-unit id="Error_PackageSourceMappingPattern_Missing">
4651
<source>A package pattern must be provided.</source>
4752
<target state="translated">Specificare un modello di pacchetto.</target>

src/NuGet.Clients/NuGet.Tools/xlf/Resources.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<target state="translated">MCP ツール サービスは使用できません。GitHub Copilot がインストールされ、サインインしていることを確認してください。</target>
4343
<note>Do not translate GitHub or Copilot</note>
4444
</trans-unit>
45+
<trans-unit id="Error_NuGetSolverNotAvailable">
46+
<source>The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</source>
47+
<target state="new">The NuGet Solver tool is unavailable. Please enable the NuGet MCP Server in the GitHub Copilot chat window and try again.</target>
48+
<note>Do not translate GitHub or Copilot</note>
49+
</trans-unit>
4550
<trans-unit id="Error_PackageSourceMappingPattern_Missing">
4651
<source>A package pattern must be provided.</source>
4752
<target state="translated">パッケージ パターンを指定する必要があります。</target>

0 commit comments

Comments
 (0)