-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Initial MCP Server implementation #5610
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
Changes from all commits
2d98c5e
1474d94
3051b17
3fb9aa3
ae2e40f
70d9bb9
12c9b94
78d58b1
aa0e9a8
431defd
556ebc9
5802d3a
a006bc2
16c46fd
33cd89a
8de3589
21f92a0
413431c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,6 +167,7 @@ MAKEINTRESOURCE | |
| makemsix | ||
| MANIFESTSCHEMA | ||
| MANIFESTVERSION | ||
| mcp | ||
| Memberwise | ||
| meme | ||
| metadatas | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,4 +104,5 @@ | |
| ^src/SfsClient/ | ||
| ^src/Xlang/ | ||
| ^src/VcpkgPortOverlay/ | ||
| ^src/WinGetMCPServer/WinGetMCPServer.csproj$ | ||
| ignore$ | ||
| 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
Member
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. So now we can do both
Member
Author
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. 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 |
||
| }; | ||
| } | ||
|
|
||
| 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); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| 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; | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| #include "pch.h" | ||
| #include "ConfigureExportCommand.h" | ||
| #include "Workflows/ConfigurationFlow.h" | ||
| #include "Workflows/MSStoreInstallerHandler.h" | ||
|
Contributor
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. Now I'm wondering, why did we not put this command under Commands folder ... |
||
| #include "ConfigurationCommon.h" | ||
|
|
||
| using namespace AppInstaller::CLI::Workflow; | ||
|
|
||
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.
In case we have not done it, we'll need to talk to policy team about updating the policy template later.