@web-marketing-hr/azure-devops-mcp 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +238 -0
  3. package/dist/auth.js +117 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/index.js +155 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/logger.js +35 -0
  8. package/dist/logger.js.map +1 -0
  9. package/dist/org-tenants.js +79 -0
  10. package/dist/org-tenants.js.map +1 -0
  11. package/dist/prompts.js +21 -0
  12. package/dist/prompts.js.map +1 -0
  13. package/dist/shared/domains.js +126 -0
  14. package/dist/shared/domains.js.map +1 -0
  15. package/dist/shared/tool-validation.js +93 -0
  16. package/dist/shared/tool-validation.js.map +1 -0
  17. package/dist/tools/advanced-security.js +109 -0
  18. package/dist/tools/advanced-security.js.map +1 -0
  19. package/dist/tools/auth.js +64 -0
  20. package/dist/tools/auth.js.map +1 -0
  21. package/dist/tools/core.js +96 -0
  22. package/dist/tools/core.js.map +1 -0
  23. package/dist/tools/pipelines.js +322 -0
  24. package/dist/tools/pipelines.js.map +1 -0
  25. package/dist/tools/repositories.js +938 -0
  26. package/dist/tools/repositories.js.map +1 -0
  27. package/dist/tools/search.js +211 -0
  28. package/dist/tools/search.js.map +1 -0
  29. package/dist/tools/test-plans.js +387 -0
  30. package/dist/tools/test-plans.js.map +1 -0
  31. package/dist/tools/wiki.js +390 -0
  32. package/dist/tools/wiki.js.map +1 -0
  33. package/dist/tools/work-items.js +1007 -0
  34. package/dist/tools/work-items.js.map +1 -0
  35. package/dist/tools/work.js +299 -0
  36. package/dist/tools/work.js.map +1 -0
  37. package/dist/tools.js +30 -0
  38. package/dist/tools.js.map +1 -0
  39. package/dist/useragent.js +21 -0
  40. package/dist/useragent.js.map +1 -0
  41. package/dist/utils.js +94 -0
  42. package/dist/utils.js.map +1 -0
  43. package/dist/version.js +2 -0
  44. package/dist/version.js.map +1 -0
  45. package/package.json +86 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # ⭐ Azure DevOps MCP Server
2
+
3
+ Easily install the Azure DevOps MCP Server for VS Code or VS Code Insiders:
4
+
5
+ [![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-Install_AzureDevops_MCP_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=ado&config=%7B%20%22type%22%3A%20%22stdio%22%2C%20%22command%22%3A%20%22npx%22%2C%20%22args%22%3A%20%5B%22-y%22%2C%20%22%40azure-devops%2Fmcp%22%2C%20%22%24%7Binput%3Aado_org%7D%22%5D%7D&inputs=%5B%7B%22id%22%3A%20%22ado_org%22%2C%20%22type%22%3A%20%22promptString%22%2C%20%22description%22%3A%20%22Azure%20DevOps%20organization%20name%20%20%28e.g.%20%27contoso%27%29%22%7D%5D)
6
+ [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_AzureDevops_MCP_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=ado&quality=insiders&config=%7B%20%22type%22%3A%20%22stdio%22%2C%20%22command%22%3A%20%22npx%22%2C%20%22args%22%3A%20%5B%22-y%22%2C%20%22%40azure-devops%2Fmcp%22%2C%20%22%24%7Binput%3Aado_org%7D%22%5D%7D&inputs=%5B%7B%22id%22%3A%20%22ado_org%22%2C%20%22type%22%3A%20%22promptString%22%2C%20%22description%22%3A%20%22Azure%20DevOps%20organization%20name%20%20%28e.g.%20%27contoso%27%29%22%7D%5D)
7
+
8
+ This TypeScript project provides a **local** MCP server for Azure DevOps, enabling you to perform a wide range of Azure DevOps tasks directly from your code editor.
9
+
10
+ ## WEB Marketing fork goals
11
+ 1. Add option to use on premise DevOps
12
+ 2. Add option to set DevOps API version
13
+
14
+ ### Added Environment variables
15
+ - `apiVersion`:
16
+ - set DevOps API version
17
+ - default: `"7.2-preview.1"`
18
+ - env: `ADO_MCP_API_VERSION`
19
+ - `batchApiVersion`:
20
+ - set DevOps Batch API version
21
+ - default: `"5.0"`
22
+ - env: `ADO_MCP_BATCH_API_VERSION`
23
+ - `markdownCommentsApiVersion`:
24
+ - set DevOps Markdown API version
25
+ - default: `"7.2-preview.4"`
26
+ - env: `ADO_MCP_MARKDOWN_COMMENTS_API_VERSION`
27
+ - `ADO_MCP_MODE`:
28
+ - set DevOps Server mode On Premise or on Azure
29
+ - `"cloud"` (default) ili `"onprem"`
30
+ - `ADO_MCP_ORG_URL`:
31
+ - full URL of on premise instance, for example:
32
+ `https://my-server/tfs/MyCollection` ili `https://devops.moja-firma.hr/MyCollection`
33
+
34
+ ## 📄 Table of Contents
35
+
36
+ 1. [📺 Overview](#-overview)
37
+ 2. [🏆 Expectations](#-expectations)
38
+ 3. [⚙️ Supported Tools](#️-supported-tools)
39
+ 4. [🔌 Installation & Getting Started](#-installation--getting-started)
40
+ 5. [🌏 Using Domains](#-using-domains)
41
+ 6. [📝 Troubleshooting](#-troubleshooting)
42
+ 7. [🎩 Examples & Best Practices](#-examples--best-practices)
43
+ 8. [🙋‍♀️ Frequently Asked Questions](#️-frequently-asked-questions)
44
+ 9. [📌 Contributing](#-contributing)
45
+
46
+ ## 📺 Overview
47
+
48
+ The Azure DevOps MCP Server brings Azure DevOps context to your agents. Try prompts like:
49
+
50
+ - "List my ADO projects"
51
+ - "List ADO Builds for 'Contoso'"
52
+ - "List ADO Repos for 'Contoso'"
53
+ - "List test plans for 'Contoso'"
54
+ - "List teams for project 'Contoso'"
55
+ - "List iterations for project 'Contoso'"
56
+ - "List my work items for project 'Contoso'"
57
+ - "List work items in current iteration for 'Contoso' project and 'Contoso Team'"
58
+ - "List all wikis in the 'Contoso' project"
59
+ - "Create a wiki page '/Architecture/Overview' with content about system design"
60
+ - "Update the wiki page '/Getting Started' with new onboarding instructions"
61
+ - "Get the content of the wiki page '/API/Authentication' from the Documentation wiki"
62
+
63
+ ## 🏆 Expectations
64
+
65
+ The Azure DevOps MCP Server is built from tools that are concise, simple, focused, and easy to use—each designed for a specific scenario. We intentionally avoid complex tools that try to do too much. The goal is to provide a thin abstraction layer over the REST APIs, making data access straightforward and letting the language model handle complex reasoning.
66
+
67
+ ## ⚙️ Supported Tools
68
+
69
+ See [TOOLSET.md](./docs/TOOLSET.md) for a comprehensive list.
70
+
71
+ ## 🔌 Installation & Getting Started
72
+
73
+ For the best experience, use Visual Studio Code and GitHub Copilot. See the [getting started documentation](./docs/GETTINGSTARTED.md) to use our MCP Server with other tools such as Visual Studio 2022, Claude Code, and Cursor.
74
+
75
+ ### Prerequisites
76
+
77
+ 1. Install [VS Code](https://code.visualstudio.com/download) or [VS Code Insiders](https://code.visualstudio.com/insiders)
78
+ 2. Install [Node.js](https://nodejs.org/en/download) 20+
79
+ 3. Open VS Code in an empty folder
80
+
81
+ ### Installation
82
+
83
+ #### ✨ One-Click Install
84
+
85
+ [![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-Install_AzureDevops_MCP_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=ado&config=%7B%20%22type%22%3A%20%22stdio%22%2C%20%22command%22%3A%20%22npx%22%2C%20%22args%22%3A%20%5B%22-y%22%2C%20%22%40azure-devops%2Fmcp%22%2C%20%22%24%7Binput%3Aado_org%7D%22%5D%7D&inputs=%5B%7B%22id%22%3A%20%22ado_org%22%2C%20%22type%22%3A%20%22promptString%22%2C%20%22description%22%3A%20%22Azure%20DevOps%20organization%20name%20%20%28e.g.%20%27contoso%27%29%22%7D%5D)
86
+ [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_AzureDevops_MCP_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=ado&quality=insiders&config=%7B%20%22type%22%3A%20%22stdio%22%2C%20%22command%22%3A%20%22npx%22%2C%20%22args%22%3A%20%5B%22-y%22%2C%20%22%40azure-devops%2Fmcp%22%2C%20%22%24%7Binput%3Aado_org%7D%22%5D%7D&inputs=%5B%7B%22id%22%3A%20%22ado_org%22%2C%20%22type%22%3A%20%22promptString%22%2C%20%22description%22%3A%20%22Azure%20DevOps%20organization%20name%20%20%28e.g.%20%27contoso%27%29%22%7D%5D)
87
+
88
+ After installation, select GitHub Copilot Agent Mode and refresh the tools list. Learn more about Agent Mode in the [VS Code Documentation](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode).
89
+
90
+ #### 🧨 Install from Public Feed (Recommended)
91
+
92
+ This installation method is the easiest for all users of Visual Studio Code.
93
+
94
+ 🎥 [Watch this quick start video to get up and running in under two minutes!](https://youtu.be/EUmFM6qXoYk)
95
+
96
+ ##### Steps
97
+
98
+ In your project, add a `.vscode\mcp.json` file with the following content:
99
+
100
+ ```json
101
+ {
102
+ "inputs": [
103
+ {
104
+ "id": "ado_org",
105
+ "type": "promptString",
106
+ "description": "Azure DevOps organization name (e.g. 'contoso')"
107
+ }
108
+ ],
109
+ "servers": {
110
+ "ado": {
111
+ "type": "stdio",
112
+ "command": "npx",
113
+ "args": ["-y", "@azure-devops/mcp", "${input:ado_org}"]
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ 🔥 To stay up to date with the latest features, you can use our nightly builds. Simply update your `mcp.json` configuration to use `@azure-devops/mcp@next`. Here is an updated example:
120
+
121
+ ```json
122
+ {
123
+ "inputs": [
124
+ {
125
+ "id": "ado_org",
126
+ "type": "promptString",
127
+ "description": "Azure DevOps organization name (e.g. 'contoso')"
128
+ }
129
+ ],
130
+ "servers": {
131
+ "ado": {
132
+ "type": "stdio",
133
+ "command": "npx",
134
+ "args": ["-y", "@azure-devops/mcp@next", "${input:ado_org}"]
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ Save the file, then click 'Start'.
141
+
142
+ ![start mcp server](./docs/media/start-mcp-server.gif)
143
+
144
+ In chat, switch to [Agent Mode](https://code.visualstudio.com/blogs/2025/02/24/introducing-copilot-agent-mode).
145
+
146
+ Click "Select Tools" and choose the available tools.
147
+
148
+ ![configure mcp server tools](./docs/media/configure-mcp-server-tools.gif)
149
+
150
+ Open GitHub Copilot Chat and try a prompt like `List ADO projects`. The first time an ADO tool is executed browser will open prompting to login with your Microsoft account. Please ensure you are using credentials matching selected Azure DevOps organization.
151
+
152
+ > 💥 We strongly recommend creating a `.github\copilot-instructions.md` in your project. This will enhance your experience using the Azure DevOps MCP Server with GitHub Copilot Chat.
153
+ > To start, just include "`This project uses Azure DevOps. Always check to see if the Azure DevOps MCP server has a tool relevant to the user's request`" in your copilot instructions file.
154
+
155
+ See the [getting started documentation](./docs/GETTINGSTARTED.md) to use our MCP Server with other tools such as Visual Studio 2022, Claude Code, and Cursor.
156
+
157
+ ## 🌏 Using Domains
158
+
159
+ Azure DevOps exposes a large surface area. As a result, our Azure DevOps MCP Server includes many tools. To keep the toolset manageable, avoid confusing the model, and respect client limits on loaded tools, use Domains to load only the areas you need. Domains are named groups of related tools (for example: core, work, work-items, repositories, wiki). Add the `-d` argument and the domain names to the server args in your `mcp.json` to list the domains to enable.
160
+
161
+ For example, use `"-d", "core", "work", "work-items"` to load only Work Item related tools (see the example below).
162
+
163
+ ```json
164
+ {
165
+ "inputs": [
166
+ {
167
+ "id": "ado_org",
168
+ "type": "promptString",
169
+ "description": "Azure DevOps organization name (e.g. 'contoso')"
170
+ }
171
+ ],
172
+ "servers": {
173
+ "ado_with_filtered_domains": {
174
+ "type": "stdio",
175
+ "command": "npx",
176
+ "args": ["-y", "@azure-devops/mcp", "${input:ado_org}", "-d", "core", "work", "work-items"]
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ Domains that are available are: `core`, `work`, `work-items`, `search`, `test-plans`, `repositories`, `wiki`, `pipelines`, `advanced-security`
183
+
184
+ We recommend that you always enable `core` tools so that you can fetch project level information.
185
+
186
+ > By default all domains are loaded
187
+
188
+ ## 📝 Troubleshooting
189
+
190
+ See the [Troubleshooting guide](./docs/TROUBLESHOOTING.md) for help with common issues and logging.
191
+
192
+ ## 🎩 Examples & Best Practices
193
+
194
+ Explore example prompts in our [Examples documentation](./docs/EXAMPLES.md).
195
+
196
+ For best practices and tips to enhance your experience with the MCP Server, refer to the [How-To guide](./docs/HOWTO.md).
197
+
198
+ ## 🙋‍♀️ Frequently Asked Questions
199
+
200
+ For answers to common questions about the Azure DevOps MCP Server, see the [Frequently Asked Questions](./docs/FAQ.md).
201
+
202
+ ## 📌 Contributing
203
+
204
+ We welcome contributions! During preview, please file issues for bugs, enhancements, or documentation improvements.
205
+
206
+ See our [Contributions Guide](./CONTRIBUTING.md) for:
207
+
208
+ - 🛠️ Development setup
209
+ - ✨ Adding new tools
210
+ - 📝 Code style & testing
211
+ - 🔄 Pull request process
212
+
213
+ ## 🤝 Code of Conduct
214
+
215
+ This project follows the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
216
+ For questions, see the [FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [open@microsoft.com](mailto:open@microsoft.com).
217
+
218
+ ## 📈 Project Stats
219
+
220
+ [![Star History Chart](https://api.star-history.com/svg?repos=microsoft/azure-devops-mcp&type=Date)](https://star-history.com/#microsoft/azure-devops-mcp)
221
+
222
+ ## 🏆 Hall of Fame
223
+
224
+ Thanks to all contributors who make this project awesome! ❤️
225
+
226
+ [![Contributors](https://contrib.rocks/image?repo=microsoft/azure-devops-mcp)](https://github.com/microsoft/azure-devops-mcp/graphs/contributors)
227
+
228
+ > Generated with [contrib.rocks](https://contrib.rocks)
229
+
230
+ ## License
231
+
232
+ Licensed under the [MIT License](./LICENSE.md).
233
+
234
+ ---
235
+
236
+ _Trademarks: This project may include trademarks or logos for Microsoft or third parties. Use of Microsoft trademarks or logos must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Third-party trademarks are subject to their respective policies._
237
+
238
+ <!-- version: 2023-04-07 [Do not delete this line, it is used for analytics that drive template improvements] -->
package/dist/auth.js ADDED
@@ -0,0 +1,117 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { AzureCliCredential, ChainedTokenCredential, DefaultAzureCredential } from "@azure/identity";
4
+ import { PublicClientApplication } from "@azure/msal-node";
5
+ import open from "open";
6
+ import { logger } from "./logger.js";
7
+ const scopes = ["499b84ac-1321-427f-aa17-267ca6975798/.default"];
8
+ class OAuthAuthenticator {
9
+ static clientId = "0d50963b-7bb9-4fe7-94c7-a99af00b5136";
10
+ static defaultAuthority = "https://login.microsoftonline.com/common";
11
+ static zeroTenantId = "00000000-0000-0000-0000-000000000000";
12
+ accountId;
13
+ publicClientApp;
14
+ constructor(tenantId) {
15
+ this.accountId = null;
16
+ let authority = OAuthAuthenticator.defaultAuthority;
17
+ if (tenantId && tenantId !== OAuthAuthenticator.zeroTenantId) {
18
+ authority = `https://login.microsoftonline.com/${tenantId}`;
19
+ logger.debug(`OAuthAuthenticator: Using tenant-specific authority for tenantId='${tenantId}'`);
20
+ }
21
+ else {
22
+ logger.debug(`OAuthAuthenticator: Using default common authority`);
23
+ }
24
+ this.publicClientApp = new PublicClientApplication({
25
+ auth: {
26
+ clientId: OAuthAuthenticator.clientId,
27
+ authority,
28
+ },
29
+ });
30
+ logger.debug(`OAuthAuthenticator: Initialized with clientId='${OAuthAuthenticator.clientId}'`);
31
+ }
32
+ async getToken() {
33
+ let authResult = null;
34
+ if (this.accountId) {
35
+ logger.debug(`OAuthAuthenticator: Attempting silent token acquisition for cached account`);
36
+ try {
37
+ authResult = await this.publicClientApp.acquireTokenSilent({
38
+ scopes,
39
+ account: this.accountId,
40
+ });
41
+ logger.debug(`OAuthAuthenticator: Successfully acquired token silently`);
42
+ }
43
+ catch (error) {
44
+ logger.debug(`OAuthAuthenticator: Silent token acquisition failed: ${error instanceof Error ? error.message : String(error)}`);
45
+ authResult = null;
46
+ }
47
+ }
48
+ else {
49
+ logger.debug(`OAuthAuthenticator: No cached account available, interactive auth required`);
50
+ }
51
+ if (!authResult) {
52
+ logger.debug(`OAuthAuthenticator: Starting interactive token acquisition`);
53
+ authResult = await this.publicClientApp.acquireTokenInteractive({
54
+ scopes,
55
+ openBrowser: async (url) => {
56
+ logger.debug(`OAuthAuthenticator: Opening browser for authentication`);
57
+ open(url);
58
+ },
59
+ });
60
+ this.accountId = authResult.account;
61
+ logger.debug(`OAuthAuthenticator: Successfully acquired token interactively, account cached`);
62
+ }
63
+ if (!authResult.accessToken) {
64
+ logger.error(`OAuthAuthenticator: Authentication result contains no access token`);
65
+ throw new Error("Failed to obtain Azure DevOps OAuth token.");
66
+ }
67
+ logger.debug(`OAuthAuthenticator: Token obtained successfully`);
68
+ return authResult.accessToken;
69
+ }
70
+ }
71
+ function createAuthenticator(type, tenantId) {
72
+ logger.debug(`Creating authenticator of type '${type}' with tenantId='${tenantId ?? "undefined"}'`);
73
+ switch (type) {
74
+ case "envvar":
75
+ logger.debug(`Authenticator: Using environment variable authentication (ADO_MCP_AUTH_TOKEN)`);
76
+ // Read token from fixed environment variable
77
+ return async () => {
78
+ logger.debug(`${type}: Reading token from ADO_MCP_AUTH_TOKEN environment variable`);
79
+ const token = process.env["ADO_MCP_AUTH_TOKEN"];
80
+ if (!token) {
81
+ logger.error(`${type}: ADO_MCP_AUTH_TOKEN environment variable is not set or empty`);
82
+ throw new Error("Environment variable 'ADO_MCP_AUTH_TOKEN' is not set or empty. Please set it with a valid Azure DevOps Personal Access Token.");
83
+ }
84
+ logger.debug(`${type}: Successfully retrieved token from environment variable`);
85
+ return token;
86
+ };
87
+ case "azcli":
88
+ case "env":
89
+ if (type !== "env") {
90
+ logger.debug(`${type}: Setting AZURE_TOKEN_CREDENTIALS to 'dev' for development credential chain`);
91
+ process.env.AZURE_TOKEN_CREDENTIALS = "dev";
92
+ }
93
+ let credential = new DefaultAzureCredential(); // CodeQL [SM05138] resolved by explicitly setting AZURE_TOKEN_CREDENTIALS
94
+ if (tenantId) {
95
+ // Use Azure CLI credential if tenantId is provided for multi-tenant scenarios
96
+ const azureCliCredential = new AzureCliCredential({ tenantId });
97
+ credential = new ChainedTokenCredential(azureCliCredential, credential);
98
+ }
99
+ return async () => {
100
+ const result = await credential.getToken(scopes);
101
+ if (!result) {
102
+ logger.error(`${type}: Failed to obtain token - credential.getToken returned null/undefined`);
103
+ throw new Error("Failed to obtain Azure DevOps token. Ensure you have Azure CLI logged or use interactive type of authentication.");
104
+ }
105
+ logger.debug(`${type}: Successfully obtained Azure DevOps token`);
106
+ return result.token;
107
+ };
108
+ default:
109
+ logger.debug(`Authenticator: Using OAuth interactive authentication (default)`);
110
+ const authenticator = new OAuthAuthenticator(tenantId);
111
+ return () => {
112
+ return authenticator.getToken();
113
+ };
114
+ }
115
+ }
116
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,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAChE,UAAU,GAAG,IAAI,sBAAsB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;YAC1E,CAAC;YACD,OAAO,KAAK,IAAI,EAAE;gBAChB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,wEAAwE,CAAC,CAAC;oBAC9F,MAAM,IAAI,KAAK,CAAC,kHAAkH,CAAC,CAAC;gBACtI,CAAC;gBACD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,4CAA4C,CAAC,CAAC;gBAClE,OAAO,MAAM,CAAC,KAAK,CAAC;YACtB,CAAC,CAAC;QAEJ;YACE,MAAM,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;YAChF,MAAM,aAAa,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YACvD,OAAO,GAAG,EAAE;gBACV,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC;YAClC,CAAC,CAAC;IACN,CAAC;AACH,CAAC;AACD,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { getBasicHandler, getBearerHandler, WebApi } from "azure-devops-node-api";
7
+ import yargs from "yargs";
8
+ import { hideBin } from "yargs/helpers";
9
+ import { createAuthenticator } from "./auth.js";
10
+ import { logger } from "./logger.js";
11
+ import { getOrgTenant } from "./org-tenants.js";
12
+ //import { configurePrompts } from "./prompts.js";
13
+ import { configureAllTools } from "./tools.js";
14
+ import { UserAgentComposer } from "./useragent.js";
15
+ import { packageVersion } from "./version.js";
16
+ import { DomainsManager } from "./shared/domains.js";
17
+ import { getAzureDevOpsConfig } from "./utils.js";
18
+ function isGitHubCodespaceEnv() {
19
+ return process.env.CODESPACES === "true" && !!process.env.CODESPACE_NAME;
20
+ }
21
+ const defaultAuthenticationType = isGitHubCodespaceEnv() ? "azcli" : "interactive";
22
+ // Parse command line arguments using yargs
23
+ const argv = yargs(hideBin(process.argv))
24
+ .scriptName("mcp-server-azuredevops")
25
+ .usage("Usage: $0 <organization> [options]")
26
+ .version(packageVersion)
27
+ .command("$0 <organization> [options]", "Azure DevOps MCP Server", (yargs) => {
28
+ yargs.positional("organization", {
29
+ describe: "Azure DevOps organization name",
30
+ type: "string",
31
+ demandOption: true,
32
+ });
33
+ })
34
+ .option("domains", {
35
+ alias: "d",
36
+ describe: "Domain(s) to enable: 'all' for everything, or specific domains like 'repositories builds work'. Defaults to 'all'.",
37
+ type: "string",
38
+ array: true,
39
+ default: "all",
40
+ })
41
+ .option("authentication", {
42
+ alias: "a",
43
+ describe: "Type of authentication to use",
44
+ type: "string",
45
+ choices: ["interactive", "azcli", "env", "envvar"],
46
+ default: defaultAuthenticationType,
47
+ })
48
+ .option("tenant", {
49
+ alias: "t",
50
+ describe: "Azure tenant ID (optional, applied when using 'interactive' and 'azcli' type of authentication)",
51
+ type: "string",
52
+ })
53
+ .help()
54
+ .parseSync();
55
+ export const orgName = argv.organization;
56
+ const { orgUrl, mode: deploymentMode } = getAzureDevOpsConfig(orgName);
57
+ const domainsManager = new DomainsManager(argv.domains);
58
+ export const enabledDomains = domainsManager.getEnabledDomains();
59
+ function getAzureDevOpsClient(getAzureDevOpsToken, userAgentComposer, authentication) {
60
+ return async () => {
61
+ const accessToken = await getAzureDevOpsToken();
62
+ const isBasicAuth = process.env["ADO_MCP_AUTH_TYPE"] == "basic";
63
+ const authHandler = isBasicAuth ? getBasicHandler("", accessToken) : getBearerHandler(accessToken);
64
+ const connection = new WebApi(orgUrl, authHandler, undefined, {
65
+ productName: "AzureDevOps.MCP",
66
+ productVersion: packageVersion,
67
+ userAgent: userAgentComposer.userAgent,
68
+ });
69
+ return connection;
70
+ };
71
+ }
72
+ async function main() {
73
+ logger.info("Starting Azure DevOps MCP Server", {
74
+ organization: orgName,
75
+ organizationUrl: orgUrl,
76
+ deploymentMode,
77
+ authentication: argv.authentication,
78
+ tenant: argv.tenant,
79
+ domains: argv.domains,
80
+ enabledDomains: Array.from(enabledDomains),
81
+ version: packageVersion,
82
+ isCodespace: isGitHubCodespaceEnv(),
83
+ });
84
+ const server = new McpServer({
85
+ name: "Azure DevOps On Premise MCP Server",
86
+ version: packageVersion,
87
+ icons: [
88
+ {
89
+ src: "https://cdn.vsassets.io/content/icons/favicon.ico",
90
+ },
91
+ ],
92
+ });
93
+ const userAgentComposer = new UserAgentComposer(packageVersion);
94
+ server.server.oninitialized = () => {
95
+ userAgentComposer.appendMcpClientInfo(server.server.getClientVersion());
96
+ };
97
+ const tenantId = deploymentMode === "cloud" ? (await getOrgTenant(orgName)) ?? argv.tenant : undefined;
98
+ const authenticator = createAuthenticator(argv.authentication, tenantId);
99
+ // removing prompts untill further notice
100
+ // configurePrompts(server);
101
+ const connectionProvider = getAzureDevOpsClient(authenticator, userAgentComposer, argv.authentication);
102
+ configureAllTools(server, authenticator, connectionProvider, () => userAgentComposer.userAgent, enabledDomains);
103
+ // TESTING CONNECTION TO DevOps API
104
+ await testApi(connectionProvider, authenticator);
105
+ const transport = new StdioServerTransport();
106
+ await server.connect(transport);
107
+ }
108
+ async function testApi(connectionProvider, tokenProvider) {
109
+ const connection = await connectionProvider();
110
+ const coreApi = await connection.getCoreApi();
111
+ const workItemApi = await connection.getWorkItemTrackingApi();
112
+ const accessToken = await tokenProvider();
113
+ const baseUrl = connection.serverUrl.replace(/\/$/, "");
114
+ const isOnPrem = process.env["ADO_MCP_MODE"] === "onprem";
115
+ const url = isOnPrem
116
+ ? `${baseUrl}/${orgName}/_apis/search/workitemsearchresults?api-version=6.0-preview`
117
+ : `https://almsearch.dev.azure.com/${orgName}/_apis/search/workitemsearchresults?api-version=6.0`;
118
+ const searchText = "Antonio";
119
+ const includeFacets = false;
120
+ const requestBody = {
121
+ searchText,
122
+ includeFacets,
123
+ $skip: 0,
124
+ $top: 10,
125
+ };
126
+ const isBasicAuth = process.env["ADO_MCP_AUTH_TYPE"] === "basic";
127
+ const authHeader = isBasicAuth ? `Basic ${Buffer.from(":" + accessToken).toString("base64")}` : `Bearer ${accessToken}`;
128
+ const response = await fetch(url, {
129
+ method: "POST",
130
+ headers: {
131
+ "Content-Type": "application/json",
132
+ "Authorization": authHeader,
133
+ "User-Agent": "AzureDevOps.MCP TestApi",
134
+ },
135
+ body: JSON.stringify(requestBody),
136
+ });
137
+ if (!response.ok) {
138
+ const errorBody = await response.text();
139
+ logger.error("Azure DevOps Work Item Search API error", {
140
+ status: response.status,
141
+ statusText: response.statusText,
142
+ url,
143
+ requestBody,
144
+ responseBody: errorBody,
145
+ });
146
+ throw new Error(`Azure DevOps Work Item Search API error: ${response.status} ${response.statusText}`);
147
+ }
148
+ const result = await response.text();
149
+ logger.info("Test API Work Item Search result:", result);
150
+ }
151
+ main().catch((error) => {
152
+ logger.error("Fatal error in main():", error);
153
+ process.exit(1);
154
+ });
155
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,O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,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QACjC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,UAAU;YAC3B,YAAY,EAAE,yBAAyB;SACvC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;KACjC,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE;YACvD,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,GAAG;YACH,WAAW;YACX,YAAY,EAAE,SAAS;SACvB,CAAC,CAAC;QACH,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;AAE1D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACtB,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,35 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import winston from "winston";
4
+ import { setLogLevel } from "@azure/logger";
5
+ const logLevel = process.env.LOG_LEVEL?.toLowerCase();
6
+ if (logLevel && ["verbose", "debug", "info", "warning", "error"].includes(logLevel)) {
7
+ // Map Winston log levels to Azure log levels
8
+ const logLevelMap = {
9
+ verbose: "verbose",
10
+ debug: "info",
11
+ info: "info",
12
+ warning: "warning",
13
+ error: "error",
14
+ };
15
+ const azureLogLevel = logLevelMap[logLevel];
16
+ setLogLevel(azureLogLevel);
17
+ }
18
+ /**
19
+ * Logger utility for MCP server
20
+ *
21
+ * Since MCP servers use stdio transport for communication on stdout,
22
+ * we log to stderr to avoid interfering with the MCP protocol.
23
+ */
24
+ export const logger = winston.createLogger({
25
+ level: process.env.LOG_LEVEL || "info",
26
+ format: winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true }), winston.format.json()),
27
+ transports: [
28
+ new winston.transports.Stream({
29
+ stream: process.stderr,
30
+ }),
31
+ ],
32
+ // Prevent Winston from exiting on error
33
+ exitOnError: false,
34
+ });
35
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAE3D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,CAAC;AACtD,IAAI,QAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IACpF,6CAA6C;IAC7C,MAAM,WAAW,GAAkC;QACjD,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,OAAO;KACf,CAAC;IAEF,MAAM,aAAa,GAAkB,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC3D,WAAW,CAAC,aAAa,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,M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