使用说明
Azure DevOps MCP Server
A Model Context Protocol (MCP) server that enables AI assistants like GitHub Copilot to interact with Azure DevOps. This server provides a comprehensive set of tools for managing work items, repositories, pull requests, builds, and projects through natural language commands.
Server Configuration
| Setting | Value |
|---|---|
| Server URL | http://cdp-devops.net.dcs.hull.ac.uk/CDPProjects |
| Protocol | Model Context Protocol (MCP) |
| Transport | stdio |
Table of Contents
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Available Tools
- Example Queries
- Troubleshooting
- License
Features
This MCP server provides 17 tools organized into 5 categories:
| Category | Tools | Description |
|---|---|---|
| Work Items | 4 | Create, read, update, and query work items |
| Repositories | 3 | List repos, get details, view branches |
| Pull Requests | 3 | Create, list, and view pull requests |
| Builds/Pipelines | 4 | Manage CI/CD pipelines and builds |
| Projects | 2 | List and view project details |
Prerequisites
Before using this MCP server, ensure you have:
- Node.js (v18 or later) - Download
- npm (comes with Node.js)
- Azure DevOps Personal Access Token (PAT) with appropriate permissions
- VS Code with GitHub Copilot extension (for MCP integration)
Installation
Step 1: Clone or Download the Project
cd /path/to/your/workspace
git clone <repository-url>
cd azure-boards-mcp
Step 2: Install Dependencies
npm install
Step 3: Build the Project
npm run build
This compiles the TypeScript source files to JavaScript in the dist/ folder.
Configuration
Creating a Personal Access Token (PAT)
- Navigate to your Azure DevOps organization
- Click on your profile icon → Personal Access Tokens
- Click "New Token"
- Configure the token:
- Name: Give it a descriptive name (e.g., "MCP Server Token")
- Expiration: Set appropriate expiration date
- Scopes: Select the following permissions:
| Scope | Permission | Required For |
|---|---|---|
| Work Items | Read & Write | Creating, updating, querying work items |
| Code | Read & Write | Repository access, pull requests |
| Build | Read & Execute | Pipeline management |
| Project and Team | Read | Listing projects |
- Click Create and copy the generated token immediately (you won't see it again!)
Setting the Environment Variable
Choose the method appropriate for your operating system:
Windows PowerShell
$env:ADO_PAT = "your_personal_access_token_here"
Windows CMD
set ADO_PAT=your_personal_access_token_here
Linux/macOS
export ADO_PAT=your_personal_access_token_here
VS Code MCP Configuration
The server is pre-configured in .vscode/mcp.json. When VS Code starts the MCP server, it will prompt you for your PAT securely.
{
"servers": {
"azure-devops": {
"type": "stdio",
"command": "node",
"args": ["dist/index.js"],
"env": {
"ADO_PAT": "${input:adoPat}"
}
}
}
}
Usage
Running the Server Manually
npm start
Development Mode (with auto-reload)
npm run dev
Using with VS Code Copilot
Once the MCP server is running, you can interact with Azure DevOps through natural language in VS Code Copilot Chat. Examples:
- "List all my tasks in Sprint 1"
- "Create a new bug titled 'Login page not loading'"
- "Assign task 4857 to John Smith"
- "Show me all active pull requests"
Available Tools
Work Items
get_work_item
Retrieve a specific work item by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | Yes | The work item ID |
project |
string | No | Project name (optional) |
Example Usage:
"Get work item 4857"
list_work_items
Query work items using WIQL (Work Item Query Language).
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | Yes | WIQL query string |
project |
string | No | Project name (optional) |
Example Usage:
"List all tasks assigned to me" "Show all bugs with state 'Active'"
create_work_item
Create a new work item in Azure DevOps.
| Parameter | Type | Required | Description |
|---|---|---|---|
project |
string | Yes | Project name |
workItemType |
string | Yes | Type: 'Task', 'Bug', 'User Story', etc. |
title |
string | Yes | Title of the work item |
description |
string | No | Detailed description |
assignedTo |
string | No | Person to assign (name or email) |
state |
string | No | Initial state |
Example Usage:
"Create a new task titled 'Update documentation' assigned to John"
update_work_item
Update an existing work item.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | Yes | Work item ID to update |
title |
string | No | New title |
description |
string | No | New description |
state |
string | No | New state |
assignedTo |
string | No | New assignee |
Example Usage:
"Update task 4955 - assign it to Jane Doe" "Change the state of bug 123 to 'Resolved'"
Repositories
list_repositories
List all Git repositories in a project.
| Parameter | Type | Required | Description |
|---|---|---|---|
project |
string | No | Project name (lists all if not specified) |
Example Usage:
"List all repositories in the project"
get_repository
Get details of a specific repository.
| Parameter | Type | Required | Description |
|---|---|---|---|
repositoryId |
string | Yes | Repository ID or name |
project |
string | No | Project name |
Example Usage:
"Get details of the main repository"
list_branches
List all branches in a repository.
| Parameter | Type | Required | Description |
|---|---|---|---|
repositoryId |
string | Yes | Repository ID or name |
project |
string | No | Project name |
Example Usage:
"Show all branches in the frontend repo"
Pull Requests
list_pull_requests
List pull requests in a repository.
| Parameter | Type | Required | Description |
|---|---|---|---|
repositoryId |
string | Yes | Repository ID or name |
project |
string | No | Project name |
status |
string | No | Filter: 'active', 'completed', 'abandoned', 'all' |
Example Usage:
"Show all active pull requests"
get_pull_request
Get details of a specific pull request.
| Parameter | Type | Required | Description |
|---|---|---|---|
repositoryId |
string | Yes | Repository ID or name |
pullRequestId |
number | Yes | Pull request ID |
project |
string | No | Project name |
Example Usage:
"Get details of pull request #42"
create_pull_request
Create a new pull request.
| Parameter | Type | Required | Description |
|---|---|---|---|
repositoryId |
string | Yes | Repository ID or name |
sourceRefName |
string | Yes | Source branch (e.g., 'refs/heads/feature') |
targetRefName |
string | Yes | Target branch (e.g., 'refs/heads/main') |
title |
string | Yes | PR title |
description |
string | No | PR description |
project |
string | No | Project name |
Example Usage:
"Create a pull request from feature-login to main"
Builds/Pipelines
list_builds
List builds/pipelines in a project.
| Parameter | Type | Required | Description |
|---|---|---|---|
project |
string | Yes | Project name |
top |
number | No | Maximum number of builds to return |
Example Usage:
"Show the last 10 builds"
get_build
Get details of a specific build.
| Parameter | Type | Required | Description |
|---|---|---|---|
project |
string | Yes | Project name |
buildId |
number | Yes | Build ID |
Example Usage:
"Get details of build #567"
list_build_definitions
List all pipeline definitions.
| Parameter | Type | Required | Description |
|---|---|---|---|
project |
string | Yes | Project name |
Example Usage:
"List all pipeline definitions"
queue_build
Queue a new build.
| Parameter | Type | Required | Description |
|---|---|---|---|
project |
string | Yes | Project name |
definitionId |
number | Yes | Pipeline definition ID |
sourceBranch |
string | No | Branch to build (e.g., 'refs/heads/main') |
Example Usage:
"Queue a build for the main branch"
Projects
list_projects
List all projects in the organization.
| Parameter | Type | Required | Description |
|---|---|---|---|
| None | - | - | - |
Example Usage:
"List all projects"
get_project
Get details of a specific project.
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId |
string | Yes | Project ID or name |
Example Usage:
"Get details of project Hull Truck"
Example WIQL Queries
WIQL (Work Item Query Language) is used with the list_work_items tool. Here are common examples:
Get All Active Bugs
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.WorkItemType] = 'Bug'
AND [System.State] = 'Active'
Get Work Items Assigned to Me
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.AssignedTo] = @Me
Get Tasks in a Specific Sprint
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.WorkItemType] = 'Task'
AND [System.IterationPath] UNDER 'ProjectName\Sprint 1'
Get Recently Created Work Items (Last 7 Days)
SELECT [System.Id], [System.Title], [System.CreatedDate]
FROM WorkItems
WHERE [System.CreatedDate] >= @Today - 7
ORDER BY [System.CreatedDate] DESC
Get Work Items by State
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.State] IN ('New', 'Active', 'In Progress')
ORDER BY [System.State]
Troubleshooting
Common Issues
1. "ADO_PAT environment variable is required"
Solution: Ensure you've set the PAT environment variable before starting the server.
$env:ADO_PAT = "your_token_here"
npm start
2. "TF400813: The user is not authorized"
Solution: Your PAT may have expired or lack required permissions. Create a new token with the correct scopes.
3. "TF51011: The specified iteration path does not exist"
Solution: Check the exact iteration path name in Azure DevOps. Iteration paths are case-sensitive and must match exactly.
4. Connection Timeout
Solution: Verify network connectivity to http://cdp-devops.net.dcs.hull.ac.uk/CDPProjects
5. "Cannot find module" errors
Solution: Run npm install followed by npm run build
Checking Your Connection
Run this command to verify your PAT and connection:
npm start
If successful, you'll see: Azure DevOps MCP Server running on stdio
Project Structure
ADOMCP/
├── .github/
│ └── copilot-instructions.md # Copilot context file
├── .vscode/
│ └── mcp.json # VS Code MCP configuration
├── dist/ # Compiled JavaScript (generated)
├── node_modules/ # Dependencies (generated)
├── src/
│ └── index.ts # Main MCP server implementation
├── package.json # Project configuration
├── package-lock.json # Dependency lock file
├── tsconfig.json # TypeScript configuration
└── README.md # This file
References
License
MIT
