Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ MAKEINTRESOURCE
makemsix
MANIFESTSCHEMA
MANIFESTVERSION
mcp
Memberwise
meme
metadatas
Expand Down
1 change: 1 addition & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@
^src/SfsClient/
^src/Xlang/
^src/VcpkgPortOverlay/
^src/WinGetMCPServer/WinGetMCPServer.csproj$
ignore$
2 changes: 1 addition & 1 deletion doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## New in v1.12
*No applicable update found*
MCP server available; run `winget mcp` for assistance on configuring your client.

## Experimental Features
* Experimental support for Fonts
Expand Down
10 changes: 10 additions & 0 deletions doc/admx/DesktopAppInstaller.admx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="EnableWindowsPackageManagerMcpServer" class="Machine" displayName="$(string.EnableWindowsPackageManagerMcpServer)" explainText="$(string.EnableWindowsPackageManagerMcpServerExplanation)" key="Software\Policies\Microsoft\Windows\AppInstaller" valueName="EnableWindowsPackageManagerMcpServer">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In case we have not done it, we'll need to talk to policy team about updating the policy template later.

<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="WindowsPackageManagerDefaultProxy" class="Machine" displayName="$(string.WindowsPackageManagerDefaultProxy)" explainText="$(string.WindowsPackageManagerDefaultProxyExplanation)" presentation="$(presentation.WindowsPackageManagerDefaultProxy)" key="Software\Policies\Microsoft\Windows\AppInstaller">
<parentCategory ref="AppInstaller" />
<supportedOn ref="windows:SUPPORTED_Windows_10_0_RS5" />
Expand Down
7 changes: 7 additions & 0 deletions doc/admx/en-US/DesktopAppInstaller.adml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ If you disable this setting, users will not be able to use the Windows Package M
If you enable this setting, users will be able to configure the Windows Package Manager's use of proxy through the command line.

If you disable or do not configure this setting, users will not be able to to configure the Windows Package Manager's use of proxy through the command line.</string>
<string id="EnableWindowsPackageManagerMcpServer">Enable Windows Package Manager MCP Server</string>
<string id="EnableWindowsPackageManagerMcpServerExplanation">
This policy controls whether the Windows Package Manager Model Context Protocol (MCP) server can be used.

If you enable or do not configure this setting, users will be able to use the Windows Package Manager's MCP server.

If you disable this setting, users will not be able to to use the Windows Package Manager's MCP server.</string>
<string id="WindowsPackageManagerDefaultProxy">Set Windows Package Manager Default Proxy</string>
<string id="WindowsPackageManagerDefaultProxyExplanation">This policy controls the default proxy used by the Windows Package Manager.

Expand Down
26 changes: 26 additions & 0 deletions src/AppInstallerCLI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "targets", "targets", "{A0B4
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PureLib", "PureLib\PureLib.vcxitems", "{A33223D2-550B-4D99-A53D-488B1F68683E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinGetMCPServer", "WinGetMCPServer\WinGetMCPServer.csproj", "{33745E4A-39E2-676F-7E23-50FB43848D25}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -966,6 +968,30 @@ Global
{9406322E-6272-487E-902A-9953889719EA}.ReleaseStatic|x64.Build.0 = ReleaseStatic|Any CPU
{9406322E-6272-487E-902A-9953889719EA}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Any CPU
{9406322E-6272-487E-902A-9953889719EA}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Any CPU
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|ARM64.ActiveCfg = Debug|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|ARM64.Build.0 = Debug|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x64.ActiveCfg = Debug|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x64.Build.0 = Debug|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x86.ActiveCfg = Debug|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.Debug|x86.Build.0 = Debug|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|ARM64.ActiveCfg = Release|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|ARM64.Build.0 = Release|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x64.ActiveCfg = Release|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x64.Build.0 = Release|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x86.ActiveCfg = Release|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.Fuzzing|x86.Build.0 = Release|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|ARM64.ActiveCfg = Release|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|ARM64.Build.0 = Release|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x64.ActiveCfg = Release|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x64.Build.0 = Release|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x86.ActiveCfg = Release|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.Release|x86.Build.0 = Release|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|ARM64.ActiveCfg = Release|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|ARM64.Build.0 = Release|arm64
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x64.ActiveCfg = Release|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x64.Build.0 = Release|x64
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x86.ActiveCfg = Release|x86
{33745E4A-39E2-676F-7E23-50FB43848D25}.ReleaseStatic|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 3 additions & 1 deletion src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
<ClInclude Include="Commands\FeaturesCommand.h" />
<ClInclude Include="Commands\HashCommand.h" />
<ClInclude Include="Commands\ListCommand.h" />
<ClInclude Include="Commands\McpCommand.h" />
<ClInclude Include="Commands\PinCommand.h" />
<ClInclude Include="Commands\RepairCommand.h" />
<ClInclude Include="Commands\SearchCommand.h" />
Expand Down Expand Up @@ -409,6 +410,7 @@
<ClCompile Include="Commands\ErrorCommand.cpp" />
<ClCompile Include="Commands\FontCommand.cpp" />
<ClCompile Include="Commands\ImportCommand.cpp" />
<ClCompile Include="Commands\McpCommand.cpp" />
<ClCompile Include="Commands\PinCommand.cpp" />
<ClCompile Include="Commands\RepairCommand.cpp" />
<ClCompile Include="Commands\TestCommand.cpp" />
Expand Down Expand Up @@ -504,4 +506,4 @@
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorTextNuget)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorTextNuget)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>
</Project>
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@
<ClInclude Include="Commands\DscAdminSettingsResource.h">
<Filter>Commands\Configuration</Filter>
</ClInclude>
<ClInclude Include="Commands\McpCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -553,6 +556,9 @@
<ClCompile Include="Commands\DscAdminSettingsResource.cpp">
<Filter>Commands\Configuration</Filter>
</ClCompile>
<ClCompile Include="Commands\McpCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ namespace AppInstaller::CLI
return { type, "accept-configuration-agreements"_liv };
case Execution::Args::Type::ConfigurationSuppressPrologue:
return { type, "suppress-initial-details"_liv };
case Execution::Args::Type::ConfigurationEnable:
case Execution::Args::Type::ExtendedFeaturesEnable:
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::StubType };
case Execution::Args::Type::ConfigurationDisable:
case Execution::Args::Type::ExtendedFeaturesDisable:
return { type, "disable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::StubType };
case Execution::Args::Type::ConfigurationModulePath:
return { type, "module-path"_liv };
Expand Down
18 changes: 9 additions & 9 deletions src/AppInstallerCLICore/Commands/ConfigureCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ namespace AppInstaller::CLI
Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationAcceptWarning, Resource::String::ConfigurationAcceptWarningArgumentDescription, ArgumentType::Flag },
Argument{ Execution::Args::Type::ConfigurationSuppressPrologue, Resource::String::ConfigurationSuppressPrologueArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationEnable, Resource::String::ConfigurationEnableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationDisable, Resource::String::ConfigurationDisableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ExtendedFeaturesEnable, Resource::String::ExtendedFeaturesEnableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ExtendedFeaturesDisable, Resource::String::ExtendedFeaturesDisableMessage, ArgumentType::Flag, Argument::Visibility::Help },
};
}

Expand All @@ -63,15 +63,15 @@ namespace AppInstaller::CLI

void ConfigureCommand::ExecuteInternal(Execution::Context& context) const
{
if (context.Args.Contains(Execution::Args::Type::ConfigurationEnable))
if (context.Args.Contains(Execution::Args::Type::ExtendedFeaturesEnable))
{
context <<
EnableConfiguration;
EnableExtendedFeatures;
}
else if (context.Args.Contains(Execution::Args::Type::ConfigurationDisable))
else if (context.Args.Contains(Execution::Args::Type::ExtendedFeaturesDisable))
{
context <<
DisableConfiguration;
DisableExtendedFeatures;
}
else
{
Expand All @@ -90,12 +90,12 @@ namespace AppInstaller::CLI

void ConfigureCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
if (execArgs.Contains(Execution::Args::Type::ConfigurationEnable) ||
execArgs.Contains(Execution::Args::Type::ConfigurationDisable))
if (execArgs.Contains(Execution::Args::Type::ExtendedFeaturesEnable) ||
execArgs.Contains(Execution::Args::Type::ExtendedFeaturesDisable))
{
if (execArgs.GetArgsCount() > 1)
{
throw CommandException(Resource::String::ConfigurationEnableArgumentError);
throw CommandException(Resource::String::ExtendedFeaturesEnableArgumentError);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "ConfigureListCommand.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.h"
Comment thread
florelis marked this conversation as resolved.
#include "ConfigurationCommon.h"

using namespace AppInstaller::CLI::Workflow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "ConfigureShowCommand.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.h"
#include "ConfigurationCommon.h"

using namespace AppInstaller::CLI::Workflow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "ConfigureTestCommand.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.h"
#include "ConfigurationCommon.h"

using namespace AppInstaller::CLI::Workflow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "ConfigureValidateCommand.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.h"
#include "ConfigurationCommon.h"

using namespace AppInstaller::CLI::Workflow;
Expand Down
83 changes: 83 additions & 0 deletions src/AppInstallerCLICore/Commands/McpCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "McpCommand.h"
#include "Workflows/MSStoreInstallerHandler.h"
#include <AppInstallerRuntime.h>

using namespace AppInstaller::CLI::Workflow;

namespace AppInstaller::CLI
{
McpCommand::McpCommand(std::string_view parent) :
Command("mcp", {}, parent, Settings::TogglePolicy::Policy::McpServer)
{
}

std::vector<Argument> McpCommand::GetArguments() const
{
return {
Argument{ Execution::Args::Type::ExtendedFeaturesEnable, Resource::String::ExtendedFeaturesEnableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ExtendedFeaturesDisable, Resource::String::ExtendedFeaturesDisableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Comment on lines +20 to +21
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So now we can do both winget mcp --disable and winget configure --disable? Won't this be confusing?
I don't have a problem with enabling both together, but if I did winget mcp --disable I wouldn't expect to also lose configuration

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There may come a time in the future when they aren't coupled. If we think that it is a problem, maybe we need to conceptualize "extended features" more fully and integrate with experimental and the feature command. @denelon FYI

};
}

Resource::LocString McpCommand::ShortDescription() const
{
return { Resource::String::McpCommandShortDescription };
}

Resource::LocString McpCommand::LongDescription() const
{
return { Resource::String::McpCommandLongDescription };
}

Utility::LocIndView McpCommand::HelpLink() const
{
return "https://aka.ms/winget-command-mcp"_liv;
}

void McpCommand::ExecuteInternal(Execution::Context& context) const
{
if (context.Args.Contains(Execution::Args::Type::ExtendedFeaturesEnable))
{
context <<
EnableExtendedFeatures;
}
else if (context.Args.Contains(Execution::Args::Type::ExtendedFeaturesDisable))
{
context <<
DisableExtendedFeatures;
}
else
{
context <<
VerifyIsFullPackage <<
[](Execution::Context& context)
{
std::filesystem::path exePath = Runtime::GetPathTo(Runtime::PathName::MCPExecutable);
std::string jsonCompatiblePath = exePath.u8string();
Utility::FindAndReplace(jsonCompatiblePath, "\\", "\\\\");

context.Reporter.Info() << Resource::String::McpConfigurationPreamble <<
R"(
"winget-mcp": {
"type": "stdio",
"command": ")" << jsonCompatiblePath << R"("
})" << std::endl;
};
}
}

void McpCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
if (execArgs.Contains(Execution::Args::Type::ExtendedFeaturesEnable) ||
execArgs.Contains(Execution::Args::Type::ExtendedFeaturesDisable))
{
if (execArgs.GetArgsCount() > 1)
{
throw CommandException(Resource::String::ExtendedFeaturesEnableArgumentError);
}
}
}
}
23 changes: 23 additions & 0 deletions src/AppInstallerCLICore/Commands/McpCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "Command.h"

namespace AppInstaller::CLI
{
struct McpCommand final : public Command
{
McpCommand(std::string_view parent);

std::vector<Argument> GetArguments() const override;

Resource::LocString ShortDescription() const override;
Resource::LocString LongDescription() const override;

Utility::LocIndView HelpLink() const override;

protected:
void ExecuteInternal(Execution::Context& context) const override;
void ValidateArgumentsInternal(Execution::Args& execArgs) const override;
};
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ResumeCommand.h"
#include "RepairCommand.h"
#include "DscCommand.h"
#include "McpCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand Down Expand Up @@ -199,6 +200,7 @@ namespace AppInstaller::CLI
std::make_unique<RepairCommand>(FullName()),
std::make_unique<FontCommand>(FullName()),
std::make_unique<DscCommand>(FullName()),
std::make_unique<McpCommand>(FullName()),
#if _DEBUG
std::make_unique<DebugCommand>(FullName()),
#endif
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/TestCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "TableOutput.h"
#include "Public/ConfigurationSetProcessorFactoryRemoting.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.h"
#include <winrt/Microsoft.Management.Configuration.h>

using namespace AppInstaller::CLI::Workflow;
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/ConfigureExportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "ConfigureExportCommand.h"
#include "Workflows/ConfigurationFlow.h"
#include "Workflows/MSStoreInstallerHandler.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now I'm wondering, why did we not put this command under Commands folder ...

#include "ConfigurationCommon.h"

using namespace AppInstaller::CLI::Workflow;
Expand Down
6 changes: 4 additions & 2 deletions src/AppInstallerCLICore/ExecutionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ namespace AppInstaller::CLI::Execution
// Font Command
Family,

// Stub package (extended features)
ExtendedFeaturesEnable,
ExtendedFeaturesDisable,

// Configuration
ConfigurationFile,
ConfigurationAcceptWarning,
ConfigurationSuppressPrologue,
ConfigurationEnable,
ConfigurationDisable,
ConfigurationProcessorPath,
ConfigurationModulePath,
ConfigurationExportPackageId,
Expand Down
Loading
Loading