Skip to content

Instantly share code, notes, and snippets.

@SaravananRajaraman
Created July 21, 2025 00:50
Show Gist options
  • Select an option

  • Save SaravananRajaraman/5a9f1ef3a74c93aabed87c9a5fe5bf5e to your computer and use it in GitHub Desktop.

Select an option

Save SaravananRajaraman/5a9f1ef3a74c93aabed87c9a5fe5bf5e to your computer and use it in GitHub Desktop.

Absolutely! Below is a complete, detailed README.md you can drop at the root of your project. It includes:

  • πŸ“˜ Project overview & goals
  • πŸ—‚οΈ File/folder structure
  • πŸ› οΈ Tools implemented
  • βš™οΈ Setup instructions for Copilot Agent Mode
  • βœ… Usage examples
  • πŸ“š References

πŸ“„ README.md (Place this in your root project folder)

# πŸš€ Azure DevOps MCP Server

> A modular [MCP (Model Context Protocol)](https://modelcontextprotocol.org/) Server built with Node.js that connects GitHub Copilot’s Agent Mode to your Azure DevOps projects (boards, pipelines, pull requests, and more) using natural language.

---

## 🎯 What Are We Trying to Achieve?

GitHub Copilot in **Agent Mode** can understand natural language and use external tools to help developers automate tasks.

This project builds an **MCP server** that integrates with Azure DevOps APIs to allow Copilot to:

- 🧠 Understand prompts like: β€œGet work item 1234” or β€œList my open pull requests”
- πŸ”„ Automatically fetch, create, update, delete, or comment on:
  - Work Items
  - Pipelines/Builds
  - Pull Requests
  - Boards & Sprints
- ⚑ Improve developer productivity without needing to leave VS Code

Copilot translates human language into tool calls β€” this server implements those tools.

---

## πŸ—‚οΈ Project Structure

azure-devops-mcp-server/ β”œβ”€β”€ index.js # Entry point for your MCP server β”œβ”€β”€ package.json # Node.js project config β”œβ”€β”€ setup-env.sh # Helper script to export environment variables β”œβ”€β”€ mcp.json # VS Code MCP config for tool discovery β”œβ”€β”€ README.md # This documentation file └── src/ β”œβ”€β”€ tools/ # All MCP tool implementations β”‚ β”œβ”€β”€ getWorkItem.js β”‚ β”œβ”€β”€ createWorkItem.js β”‚ β”œβ”€β”€ updateWorkItem.js β”‚ β”œβ”€β”€ deleteWorkItem.js β”‚ β”œβ”€β”€ listWorkItems.js β”‚ β”œβ”€β”€ getWorkItemHistory.js β”‚ β”œβ”€β”€ addWorkItemComment.js β”‚ β”œβ”€β”€ getBuildDefinitions.js β”‚ β”œβ”€β”€ queueBuild.js β”‚ β”œβ”€β”€ getRecentBuilds.js β”‚ β”œβ”€β”€ getBoards.js β”‚ β”œβ”€β”€ listPullRequests.js β”‚ β”œβ”€β”€ getPullRequestDetails.js β”‚ β”œβ”€β”€ createPullRequest.js β”‚ β”œβ”€β”€ approvePullRequest.js β”‚ β”œβ”€β”€ completePullRequest.js β”‚ └── commentOnPullRequest.js └── utils/ └── azureConnection.js # Shared logic to authenticate to Azure DevOps


---

## βš™οΈ Setup Instructions

### 1. βœ… Install dependencies

npm install


### 2. βœ… Configure environment variables

Create or update a `.env` file or export these in your shell:

export AZURE_DEVOPS_ORG_URL="https://dev.azure.com/yourorg" export AZURE_DEVOPS_PAT="your-personal-access-token" export AZURE_DEVOPS_PROJECT="your-project-name" export AZURE_DEVOPS_TEAM="your-team-name" # (required only for Boards)


TIP: You can use `setup-env.sh` and run:

source setup-env.sh


### 3. βœ… Configure Copilot Agent Mode (VS Code)

Create a `.vscode/mcp.json` like this:

{ "mcpServers": { "azure-devops": { "command": "node", "args": ["./index.js"], "env": { "AZURE_DEVOPS_ORG_URL": "https://dev.azure.com/yourorg", "AZURE_DEVOPS_PAT": "your-pat", "AZURE_DEVOPS_PROJECT": "your-project" } } } }


### 4. βœ… Run the MCP server

node index.js


Copilot Agent Mode will now auto-discover all tools from this server when opened.

---

## πŸ“š Tools Available

| Tool Name                  | Description                                          |
|----------------------------|------------------------------------------------------|
| `get_work_item`            | Get details for a work item by ID                   |
| `create_work_item`         | Create a new work item (bug, task, etc.)            |
| `update_work_item`         | Update fields of a work item                        |
| `delete_work_item`         | Permanently delete a work item                      |
| `list_work_items`          | Query work items by state or assigned user          |
| `add_work_item_comment`    | Add a comment to a work item                        |
| `get_work_item_history`    | View update history of a work item                  |
| `get_build_definitions`    | List build/pipeline definitions                     |
| `queue_build`              | Start a new build                                   |
| `get_recent_builds`        | Show recent builds                                  |
| `get_boards`               | List available boards for the project/team          |
| `list_pull_requests`       | Get open/closed PRs in a repo                       |
| `get_pull_request_details` | Get PR status, reviewers, and metadata              |
| `create_pull_request`      | Open a new pull request                             |
| `approve_pull_request`     | Approve a pull request                              |
| `complete_pull_request`    | Complete/merge a PR                                 |
| `comment_on_pull_request`  | Add a comment to a PR                               |

---

## πŸ’¬ Example Prompts for Copilot

Prompt these into GitHub Copilot Chat in Agent Mode:

Get details of work item 12345 List active bugs assigned to me Create a task called β€œSetup CI workflow” Mark task 12345 as Done Delete work item 12345 Comment β€œReviewed with QA” on work item 12345 List all build pipelines Trigger pipeline ID 8 Get last 5 builds for the project List open pull requests in my repo Approve PR #72 Merge PR #72 into main


---

## 🧠 NLP & Copilot Agent Mode

> Did we write our own NLP engine?  
**No.** NLP is provided by GitHub Copilot’s LLM:
- You write prompts in natural language
- Copilot understands the intent
- It selects the tool from your MCP server
- It provides the structured inputs from your prompt

Your job: expose reliable tools with clear inputs and descriptions.

---

## βœ… Test Your Server

Run manually to confirm it registers tools without error:

node index.js


You should see logs (optional) confirming tool setup. Then try using it directly inside VS Code with Agent Mode.

---

## πŸ“¦ Requirements

- Node.js v18+
- VS Code with Copilot Chat (Agent Mode)
- An Azure DevOps Personal Access Token (PAT) with:
  - Work Items: **Read & Write**
  - Build: **Read & Execute**
  - Git Repositories: **Read & Write**
  - Project & Teams: **Read**
  - Pull Requests: **Read & Contribute** (for PR lifecycle tools)

---

## πŸ“š References

- [GitHub Copilot Agent Mode](https://docs.github.com/en/copilot/how-tos/context/model-context-protocol)
- [Azure DevOps Node API](https://www.npmjs.com/package/azure-devops-node-api)
- [Azure DevOps REST Docs](https://learn.microsoft.com/en-us/rest/api/azure/devops/)
- [Model Context Protocol](https://modelcontextprotocol.org/)

---

## πŸ“ License

MIT β€” free to use, extend, and integrate into your own DevOps agent ✨

---

## πŸ™Œ Credits

Built using:
- Model Context Protocol SDK
- Azure DevOps Node API
- GitHub Copilot Agent Mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment