Initial MCP Server implementation by JohnMcPMS · Pull Request #5610 · microsoft/winget-cli

Discussion on further MCP work: #5609

Change

This change adds an MCP server that provides two tools:

  • Find packages
    • Searches for packages based on a single input value, returning information about each one found.
  • Install package
    • Installs a package given a single input value, which is expected to be an identifier, name or moniker (same rules as winget CLI)

The package response looks like:

{
  "identifier":"Microsoft.VisualStudioCode",
  "name":"Microsoft Visual Studio Code",
  "catalog":"winget",
  "isInstalled":true,
  "installedVersion":"1.102.1",
  "installedLocation":"%LOCALAPPDATA%\\Programs\\Microsoft VS Code\\",  <- Is actually real path, not tokenized
  "isUpdateAvailable":false
}

Also includes:

  • A group policy that determines whether the MCP server is allowed to operate
  • An mcp command that helps with manually configuring an MCP client
  • A change to the default COM caller behavior that makes it only use the file name
    • Also changes to not use the package family name if it is the same as the current process (so we can better differentiate our own callers)
  • A Version property on the PackageManager COM object that returns the version string as 1.2.3 or 1.2.3-preview.
    • Start preferentially using this in the PowerShell module to get the version rather than running the CLI

Validation

I have ensured that the various portions of this change function within the context of the dev package.

Microsoft Reviewers: Open in CodeFlow