Skip to content

Commit 6cfaf7f

Browse files
committed
Using Windows Package Manager with Model Context Protocol (MCP) Server
1 parent 569545b commit 6cfaf7f

1 file changed

Lines changed: 321 additions & 0 deletions

File tree

Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
---
2+
title: Using Windows Package Manager with Model Context Protocol (MCP) Server
3+
description: >-
4+
The Windows Package Manager includes a Model Context Protocol (MCP) server
5+
that enables AI agents and tools to discover and install packages through a
6+
standardized interface, enhancing the authoring experience in supported
7+
editors like VS Code.
8+
ms.date: 01/07/2025
9+
ms.topic: overview
10+
---
11+
12+
# Using Windows Package Manager with Model Context Protocol (MCP) Server
13+
14+
The Windows Package Manager (WinGet) includes a built-in Model Context Protocol
15+
(MCP) server that enables AI agents and development tools to interact with
16+
WinGet's package discovery and installation capabilities through a standardized
17+
interface. This integration provides intelligent assistance for discovering and
18+
installing packages on your system.
19+
20+
The WinGet MCP server exposes WinGet's core functionality to AI agents,
21+
enabling them to help you find packages, understand their details, and assist
22+
with installation workflows. This enhances the overall authoring experience by
23+
providing contextual information about available packages directly to AI-powered
24+
tools.
25+
26+
> [!IMPORTANT]
27+
> The Windows Package Manager MCP server is currently in preview. To use this
28+
> feature, download the [WinGet preview version][00]. Features and functionality
29+
> may change as development continues.
30+
31+
## What is Model Context Protocol (MCP)?
32+
33+
Model Context Protocol (MCP) is an open protocol that enables AI systems to
34+
interact with external data sources and tools in a consistent way. It provides
35+
a standardized interface for AI agents to discover capabilities, retrieve
36+
information, and invoke actions across different systems and services.
37+
38+
MCP allows AI-powered tools to understand what operations are possible and how
39+
to perform them, without requiring custom integrations for each system. This
40+
makes it easier for developers to build AI assistants that can work with
41+
multiple tools and services seamlessly.
42+
43+
To learn more about MCP and how it works with AI agents, see
44+
[Use MCP servers in VS Code][01].
45+
46+
## How AI agents use WinGet MCP tools
47+
48+
The WinGet MCP server enables AI agents to intelligently assist you by
49+
understanding what packages are available and how to install them. Here's how
50+
agents use these capabilities to help fulfill your requests:
51+
52+
### Discovering available packages
53+
54+
When you ask an agent to help with software installation tasks, the agent can
55+
search the WinGet repository for available packages. For example:
56+
57+
- **You ask**: "I need to install Visual Studio Code"
58+
- **Agent searches**: The WinGet repository for Visual Studio Code packages
59+
- **Agent provides**: Package details including ID, version, publisher, and
60+
installation options
61+
62+
This discovery helps agents provide accurate, up-to-date information about
63+
available software.
64+
65+
### Installing packages
66+
67+
When you need to install specific software, agents can assist with the
68+
installation process:
69+
70+
- **You ask**: "Install Python for development"
71+
- **Agent identifies**: The appropriate Python package from the WinGet repository
72+
- **Agent provides**: Installation commands or can initiate the installation
73+
with your approval
74+
75+
This ensures you get the right software installed with the correct
76+
configuration.
77+
78+
## How WinGet MCP integrates with VS Code
79+
80+
The following diagram illustrates how the WinGet MCP server integrates with
81+
VS Code and AI agents:
82+
83+
```mermaid
84+
graph TD
85+
A[VS Code] -->|Copilot Chat| B[AI Agent]
86+
B -->|MCP Protocol| C[WinGet MCP Server]
87+
C -->|winget commands| D[WinGet CLI]
88+
D -->|Search| E[Package Repository]
89+
D -->|Install| F[System Packages]
90+
91+
B -->|Package suggestions| G[User Interface]
92+
B -->|Installation assistance| H[Command Generation]
93+
B -->|Package information| I[Details Display]
94+
95+
style C fill:#e1f5fe
96+
style D fill:#f3e5f5
97+
style A fill:#e8f5e8
98+
```
99+
100+
The integration works as follows:
101+
102+
1. **VS Code Copilot** communicates with AI agents that can access MCP servers
103+
2. **AI agents** use the MCP protocol to query the WinGet MCP server for
104+
information
105+
3. **WinGet MCP server** processes requests and calls the appropriate WinGet CLI
106+
commands
107+
4. **WinGet CLI** performs package searches and installations in the repository
108+
5. **Results** flow back through the chain to provide enhanced assistance
109+
110+
## Prerequisites
111+
112+
Before using the WinGet MCP server integration, ensure you have:
113+
114+
- Windows 10 version 1809 (build 17763) or later, or Windows 11
115+
- WinGet with MCP server support installed on your system
116+
- VS Code v1.104 or above with [GitHub Copilot extension][02] enabled
117+
- Access to [Copilot in VS Code][03]
118+
119+
## Setting up WinGet MCP Server
120+
121+
### Locating the WinGet MCP Server executable
122+
123+
The WinGet MCP server executable is installed alongside the Windows Package
124+
Manager. You can find it using one of the following methods:
125+
126+
#### Method 1: Using the winget mcp command
127+
128+
The **winget** tool includes an **mcp** command that provides the configuration
129+
information needed for MCP clients:
130+
131+
```powershell
132+
winget mcp
133+
```
134+
135+
This command displays the JSON configuration fragment showing the path to the
136+
`WindowsPackageManagerMCPServer.exe` executable.
137+
138+
#### Method 2: Locating via PowerShell
139+
140+
You can locate the WinGet MCP server executable by first finding the WinGet
141+
executable path and then navigating to the same directory:
142+
143+
```powershell
144+
# Find the WinGet executable path
145+
$wingetPath = (Get-Command winget).Source
146+
# Get the directory containing WinGet
147+
$wingetDir = Split-Path $wingetPath -Parent
148+
# The MCP server executable is in the same directory
149+
$mcpServerPath = Join-Path $wingetDir "WindowsPackageManagerMCPServer.exe"
150+
Write-Host "WinGet MCP Server path: $mcpServerPath"
151+
```
152+
153+
The typical location is:
154+
155+
```text
156+
C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\WindowsPackageManagerMCPServer.exe
157+
```
158+
159+
### Configuring the MCP server in VS Code
160+
161+
The recommended way to configure the WinGet MCP server is through an `mcp.json`
162+
configuration file. Create or update your MCP configuration file in the
163+
`.vscode` folder with the following content:
164+
165+
```json
166+
{
167+
"servers": {
168+
"winget-mcp": {
169+
"type": "stdio",
170+
"command": "C:\\Users\\<username>\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\WindowsPackageManagerMCPServer.exe"
171+
}
172+
},
173+
"inputs": []
174+
}
175+
```
176+
177+
Replace `<username>` with your actual Windows username, or use the path
178+
discovered using one of the methods above.
179+
180+
This configuration tells MCP clients to:
181+
182+
- Use the Windows Package Manager MCP server executable as the command
183+
- Use standard I/O communication between the client and server
184+
- Register the server with the identifier `winget-mcp`
185+
186+
For detailed information about MCP configuration and setup in VS Code, refer to
187+
the [official MCP documentation][04].
188+
189+
### Manual command-line testing
190+
191+
You can also start the WinGet MCP server manually for testing or development
192+
purposes by running the executable directly:
193+
194+
```powershell
195+
& "C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\WindowsPackageManagerMCPServer.exe"
196+
```
197+
198+
The server will start and wait for MCP protocol messages on standard input. The
199+
server will continue running until terminated or the input stream is closed.
200+
201+
## Using WinGet MCP tools in VS Code
202+
203+
### Step 1: Open Copilot Chat in Agent Mode
204+
205+
1. Open the GitHub Copilot extension window in VS Code
206+
2. Select "Agent Mode" to enable MCP tool integration
207+
208+
### Step 2: Access WinGet MCP tools
209+
210+
1. Click on the tool icon in the GitHub Copilot chat window
211+
2. Search for "MCP Server: winget-mcp" in the available tools list
212+
3. Verify that the WinGet MCP server tools are available and loaded
213+
214+
### Step 3: Start using WinGet MCP integration
215+
216+
Begin asking questions or requesting assistance with package management tasks.
217+
The AI agent will automatically use the WinGet MCP tools when appropriate to
218+
provide accurate, context-aware help.
219+
220+
Example prompts that work well with WinGet MCP integration:
221+
222+
- "What packages are available for Python development?"
223+
- "Help me install Visual Studio Code"
224+
- "Find packages for Docker on Windows"
225+
- "Install the latest version of Git"
226+
227+
## Available MCP tools
228+
229+
The WinGet MCP server currently provides the following tools:
230+
231+
### find
232+
233+
Searches the WinGet repository for packages matching specified criteria. This
234+
tool helps discover available software and their details.
235+
236+
**Parameters:**
237+
238+
- Search query or package identifier
239+
- Optional filters for source, version, or other criteria
240+
241+
### install
242+
243+
Initiates the installation of a specified package from the WinGet repository.
244+
This tool can install packages with your approval.
245+
246+
**Parameters:**
247+
248+
- Package identifier or name
249+
- Optional version specification
250+
- Optional installation parameters
251+
252+
## Troubleshooting
253+
254+
### Connection issues
255+
256+
If you encounter connection issues between VS Code and the WinGet MCP server:
257+
258+
1. Verify your `mcp.json` configuration file syntax
259+
2. Check that the path to `WindowsPackageManagerMCPServer.exe` is correct
260+
3. Ensure the executable has proper permissions to run
261+
4. Review VS Code's output panel for detailed error messages
262+
5. Try restarting the MCP integration in VS Code
263+
264+
### Limited or no response from AI Agent
265+
266+
If the AI agent doesn't seem to be using WinGet MCP tools:
267+
268+
- Use specific prompts that clearly indicate you want package management
269+
information
270+
- Try phrases like "Search for packages" or "Install using WinGet"
271+
- Verify that Agent Mode is enabled in Copilot Chat
272+
- Check if the WinGet MCP tools are visible in the tools list
273+
274+
### Package installation issues
275+
276+
If package installation fails or behaves unexpectedly:
277+
278+
- Review the installation command or parameters suggested by the AI agent
279+
- Check the [WinGet troubleshooting guide][05] for common issues
280+
- Verify you have appropriate permissions to install software
281+
- Ensure the package source is accessible
282+
283+
## Limitations
284+
285+
> [!IMPORTANT]
286+
> It is your responsibility to review all commands generated with AI assistance.
287+
> **Always validate installation commands and verify the software source before
288+
> executing them on your system.**
289+
290+
Current limitations of the WinGet MCP server integration include:
291+
292+
- **Preview status**: The MCP server is currently in preview and features may
293+
change
294+
- **Agent behavior**: There is no guarantee that AI agents will use WinGet MCP
295+
tools for any particular query, though specific prompting can help guide tool
296+
usage
297+
- **Tool availability**: Currently supports find and install operations;
298+
additional operations may be added in future releases
299+
300+
## See also
301+
302+
- [Use the winget tool to install and manage applications][06]
303+
- [winget install command][07]
304+
- [winget search command][08]
305+
- [WinGet troubleshooting guide][05]
306+
- [Use MCP servers in VS Code][01]
307+
- [Model Context Protocol documentation][09]
308+
- [Windows Package Manager GitHub repository][10]
309+
310+
<!-- Link reference definitions -->
311+
[00]: https://aka.ms/getwingetpreview
312+
[01]: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
313+
[02]: https://marketplace.visualstudio.com/items?itemName=GitHub.copilot
314+
[03]: https://code.visualstudio.com/docs/copilot/overview
315+
[04]: https://code.visualstudio.com/docs/copilot/customization/mcp-servers
316+
[05]: ./troubleshooting.md
317+
[06]: index.md
318+
[07]: install.md
319+
[08]: search.md
320+
[09]: https://modelcontextprotocol.io/docs
321+
[10]: https://github.com/microsoft/winget-cli

0 commit comments

Comments
 (0)