Skip to content

Commit 2d98c5e

Browse files
committed
adding MCP server poc
1 parent 5691433 commit 2d98c5e

File tree

5 files changed

+614
-2
lines changed

5 files changed

+614
-2
lines changed

src/AppInstallerCLI.sln

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{8D53
3636
..\azure-pipelines.yml = ..\azure-pipelines.yml
3737
..\cgmanifest.json = ..\cgmanifest.json
3838
..\README.md = ..\README.md
39-
..\doc\Settings.md = ..\doc\Settings.md
4039
..\doc\ReleaseNotes.md = ..\doc\ReleaseNotes.md
40+
..\doc\Settings.md = ..\doc\Settings.md
4141
..\WinGetInProcCom.nuspec = ..\WinGetInProcCom.nuspec
4242
..\WinGetUtil.nuspec = ..\WinGetUtil.nuspec
4343
EndProjectSection
@@ -206,6 +206,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "targets", "targets", "{A0B4
206206
EndProject
207207
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PureLib", "PureLib\PureLib.vcxitems", "{A33223D2-550B-4D99-A53D-488B1F68683E}"
208208
EndProject
209+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinGetMCPServer", "WinGetMCPServer\WinGetMCPServer.csproj", "{33745E4A-39E2-676F-7E23-50FB43848D25}"
210+
EndProject
209211
Global
210212
GlobalSection(SolutionConfigurationPlatforms) = preSolution
211213
Debug|ARM64 = Debug|ARM64
@@ -1122,6 +1124,36 @@ Global
11221124
{9406322E-6272-487E-902A-9953889719EA}.TestRelease|ARM64.ActiveCfg = Release|Any CPU
11231125
{9406322E-6272-487E-902A-9953889719EA}.TestRelease|x64.ActiveCfg = Release|Any CPU
11241126
{9406322E-6272-487E-902A-9953889719EA}.TestRelease|x86.ActiveCfg = Release|Any CPU
1127+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|ARM64.ActiveCfg = Debug|arm64
1128+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|ARM64.Build.0 = Debug|arm64
1129+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x64.ActiveCfg = Debug|x64
1130+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x64.Build.0 = Debug|x64
1131+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x86.ActiveCfg = Debug|x86
1132+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x86.Build.0 = Debug|x86
1133+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|ARM64.ActiveCfg = Release|arm64
1134+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|ARM64.Build.0 = Release|arm64
1135+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x64.ActiveCfg = Release|x64
1136+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x64.Build.0 = Release|x64
1137+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x86.ActiveCfg = Release|x86
1138+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x86.Build.0 = Release|x86
1139+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|ARM64.ActiveCfg = Release|arm64
1140+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|ARM64.Build.0 = Release|arm64
1141+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x64.ActiveCfg = Release|x64
1142+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x64.Build.0 = Release|x64
1143+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x86.ActiveCfg = Release|x86
1144+
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x86.Build.0 = Release|x86
1145+
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|ARM64.ActiveCfg = Release|arm64
1146+
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|ARM64.Build.0 = Release|arm64
1147+
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x64.ActiveCfg = Release|x64
1148+
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x64.Build.0 = Release|x64
1149+
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x86.ActiveCfg = Release|x86
1150+
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x86.Build.0 = Release|x86
1151+
{33745E4A-39E2-676F-7E23-50FB43848D25}.TestRelease|ARM64.ActiveCfg = Release|arm64
1152+
{33745E4A-39E2-676F-7E23-50FB43848D25}.TestRelease|ARM64.Build.0 = Release|arm64
1153+
{33745E4A-39E2-676F-7E23-50FB43848D25}.TestRelease|x64.ActiveCfg = Release|x64
1154+
{33745E4A-39E2-676F-7E23-50FB43848D25}.TestRelease|x64.Build.0 = Release|x64
1155+
{33745E4A-39E2-676F-7E23-50FB43848D25}.TestRelease|x86.ActiveCfg = Release|x86
1156+
{33745E4A-39E2-676F-7E23-50FB43848D25}.TestRelease|x86.Build.0 = Release|x86
11251157
EndGlobalSection
11261158
GlobalSection(SolutionProperties) = preSolution
11271159
HideSolutionNode = FALSE

src/Directory.Packages.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project>
1+
<Project>
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<!--
@@ -10,13 +10,15 @@
1010
<PackageVersion Include="coverlet.collector" Version="3.1.2" />
1111
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.21.0" />
1212
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
13+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.6" />
1314
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
1415
<PackageVersion Include="Microsoft.Msix.Utils" Version="2.1.1" />
1516
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
1617
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.6" />
1718
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
1819
<PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
1920
<PackageVersion Include="Microsoft.Windows.SDK.Contracts" Version="10.0.26100.1742" />
21+
<PackageVersion Include="ModelContextProtocol" Version="0.2.0-preview.3" />
2022
<PackageVersion Include="Moq" Version="4.18.2" />
2123
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
2224
<PackageVersion Include="nunit" Version="3.12.0" />

src/WinGetMCPServer/Program.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Microsoft.Extensions.Hosting;
3+
using Microsoft.Extensions.Logging;
4+
using ModelContextProtocol.Protocol;
5+
using ModelContextProtocol.Server;
6+
7+
namespace WinGetMCPServer
8+
{
9+
internal class Program
10+
{
11+
private const string ServerName = "winget-mcp";
12+
// TODO: Same version as winget
13+
private const string ServerVersion = "0.0.1";
14+
15+
static void Main(string[] args)
16+
{
17+
RunWithToolsType<WingetPackage_Reflection>();
18+
}
19+
20+
private static void RunWithToolsType<ToolsType>()
21+
{
22+
var builder = Host.CreateApplicationBuilder();
23+
builder.Logging.AddConsole(consoleOptions => { consoleOptions.LogToStandardErrorThreshold = LogLevel.Trace; });
24+
25+
builder.Services
26+
.AddMcpServer(configureOptions =>
27+
{
28+
// TODO: More options setup?
29+
configureOptions.ServerInfo = new Implementation() { Name = ServerName, Version = ServerVersion };
30+
})
31+
.WithStdioServerTransport()
32+
.WithTools<ToolsType>();
33+
34+
builder.Build().Run();
35+
}
36+
}
37+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetWindowsVersion>10.0.26100.0</TargetWindowsVersion>
6+
<TargetFramework>net8.0-windows$(TargetWindowsVersion)</TargetFramework>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
10+
<Platforms>x64;x86;arm64</Platforms>
11+
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
12+
<SelfContained>true</SelfContained>
13+
<RuntimeIdentifiers>win-x64;win-x86;win-arm64</RuntimeIdentifiers>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition=" '$(Platform)' == 'x64' ">
17+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
18+
</PropertyGroup>
19+
20+
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
21+
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
22+
</PropertyGroup>
23+
24+
<PropertyGroup Condition=" '$(Platform)' == 'arm64' ">
25+
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<PackageReference Include="Microsoft.Extensions.Hosting" />
30+
<PackageReference Include="ModelContextProtocol" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<ProjectReference Include="..\Microsoft.Management.Deployment\Microsoft.Management.Deployment.vcxproj">
35+
<OutputItemType>Content</OutputItemType>
36+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
37+
</ProjectReference>
38+
</ItemGroup>
39+
40+
<Import Project="..\targets\EmbeddedCsWinRT.targets" />
41+
42+
<!-- TODO: CLEAN ME UP! -->
43+
<PropertyGroup>
44+
<CsWinRTIncludes>
45+
Microsoft.Management.Deployment;
46+
Windows.Data.Text.TextSegmen;
47+
Windows.Devices.Geolocation;
48+
Windows.Foundation;
49+
Windows.Globalization.DayOfWee;
50+
Windows.Networking.Connectivity;
51+
Windows.Networking.DomainNameTyp;
52+
Windows.Networking.EndpointPai;
53+
Windows.Networking.IEndpointPai;
54+
Windows.Networking.HostNam;
55+
Windows.Networking.IHostNam;
56+
Windows.Security.Cryptography.Certificates;
57+
Windows.Storage;
58+
Windows.Storage.Provider.FileUpdateStatu;
59+
Windows.System.ProcessorArchitectur;
60+
Windows.System.Use;
61+
Windows.System.IUse;
62+
</CsWinRTIncludes>
63+
<CsWinRTExcludes>
64+
Windows.Foundation.PropertyType;
65+
Windows.Storage.Provider;
66+
</CsWinRTExcludes>
67+
<CsWinRTWindowsMetadata>$(TargetWindowsVersion)</CsWinRTWindowsMetadata>
68+
<!-- Ensure Support for Windows 10, Version 1809 -->
69+
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
70+
</PropertyGroup>
71+
72+
</Project>

0 commit comments

Comments
 (0)