Azure DevOps Remote MCP Server
by freitit
README.md
[ **English** | [Tiếng Việt](README.vi.md) ]
<p align="center">
<img src="assets/logo.jpg" alt="Azure DevOps MCP Server Logo" width="160" style="border-radius: 20px;" />
</p>
# Azure DevOps Remote MCP Server on Cloudflare Workers
> This project is ported and enhanced from Microsoft's official repository: [microsoft/azure-devops-mcp](https://github.com/microsoft/azure-devops-mcp), redesigned to run as a lightweight, serverless edge service on **Cloudflare Workers**.
The server implements the standard **Model Context Protocol (MCP)** specification (supporting both **Streamable HTTP** and **Server-Sent Events - SSE**). It is fully compatible with **Gemini Web**, Claude Desktop, Cursor, etc., connecting directly to **Azure DevOps Services** via a **Personal Access Token (PAT)** without being restricted by Microsoft Entra ID (Azure AD) tenant policies.
---
## ⚡ Key Highlights & Enhancements over the Original
1. **Serverless Edge on Cloudflare Workers:**
- Free tier includes **100,000 requests/day** (~3 million requests/month).
- **Zero Cold Start (0ms)** with V8 Isolates; eliminates heavy Docker containers and cloud registry storage costs.
2. **Human-in-the-Loop (HITL) Approvals via Telegram & Cloudflare D1:**
- Safe write operations: All mutating tools (`*_write`) transition into a `Hold` state, persisted into a **Cloudflare D1 SQLite database**, and instantly notify you on **Telegram** with interactive buttons: `[✅ Approve]` and `[❌ Reject]`.
- Polling mechanism (`action_get_status`) prevents AI agents from timing out while awaiting user authorization.
3. **Dual-Tier Security for Telegram Webhook:**
- Header authentication via Telegram's `X-Telegram-Bot-Api-Secret-Token`.
- Caller verification ensures only the authorized user (`TELEGRAM_CHAT_ID`) can approve or reject actions.
4. **Full Gemini Web & OAuth 2.1 Compatibility:**
- Built-in **OAuth 2.1** and **HTTP Basic Authentication** endpoints guard the server against unauthorized public access.
5. **Runtime Auto-Provisioning for Database Tables:**
- Cloudflare D1 tables and indexes are created automatically at runtime (`CREATE TABLE IF NOT EXISTS`), eliminating manual SQL migrations.
---
## 📋 Environment Variables & Secrets Reference
The project combines non-sensitive configurations in `wrangler.jsonc` with encrypted Cloudflare Secrets:
| Variable Name | Type | Purpose | Configuration Method |
| :------------------------ | :----------------: | :----------------------------------------------------------------------- | :-------------------------------------------------- |
| `AZURE_DEVOPS_ORG` | Plaintext (`vars`) | Your Azure DevOps organization name (e.g., `example-org`). | Set in `wrangler.jsonc` |
| `MCP_ENABLED_TOOLSETS` | Plaintext (`vars`) | Enabled toolset domains (default: `repos,wit,core,pipelines`). | Set in `wrangler.jsonc` |
| `CLIENT_ID` | Plaintext (`vars`) | Client identifier for Gemini Web OAuth (e.g., `my-client`). | Set in `wrangler.jsonc` |
| `TELEGRAM_CHAT_ID` | Plaintext (`vars`) | Your private Telegram User ID for approval alerts. | Set in `wrangler.jsonc` |
| `PERSONAL_ACCESS_TOKEN` | **Secret** 🔒 | Azure DevOps PAT with read/write access to Repos, Boards, and Pipelines. | `npx wrangler secret put PERSONAL_ACCESS_TOKEN` |
| `CLIENT_SECRET` | **Secret** 🔒 | Secret password for OAuth authentication between Gemini Web and Worker. | `npx wrangler secret put CLIENT_SECRET` |
| `TELEGRAM_BOT_TOKEN` | **Secret** 🔒 | Telegram Bot token received from `@BotFather`. | `npx wrangler secret put TELEGRAM_BOT_TOKEN` |
| `TELEGRAM_WEBHOOK_SECRET` | **Secret** 🔒 | Anti-forgery secret token for the Telegram Webhook callback. | `npx wrangler secret put TELEGRAM_WEBHOOK_SECRET` |
| `DB` | **D1 Binding** | Binding to the Cloudflare D1 Database storing approval action records. | Configured under `d1_databases` in `wrangler.jsonc` |
---
## 🛠️ MCP Tools Catalog
| Domain | Tool Name | Description & Supported Actions |
| :------------ | :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------ |
| **Repos** | `repo_pull_request` | Fetch Pull Request details (title, author, status, source/target branches, review votes). |
| **Repos** | `repo_file` | Read file contents directly from Azure DevOps Git repositories. |
| **Repos** | `repo_pull_request_thread` | Read all review comments and discussion threads within a Pull Request. |
| **Repos** | `repo_pull_request_thread_write` | Manage PR review threads: create (`create`), reply (`reply`), edit comment (`update`), or change status (`update_status`) (HITL Protected). |
| **Repos** | `repo_pull_request_write` | Create (`create`) or update (`update`) Pull Requests (status, title, description) (HITL Protected). |
| **Boards** | `wit_work_item` | Retrieve User Stories, Tasks, Bugs, or Epics by ID or list of IDs. |
| **Boards** | `wit_work_item_write` | Create (`create`) or update (`update`) Work Items (title, state, fields, assignedTo) (HITL Protected). |
| **Boards** | `wit_work_item_comment_write` | Post discussion comments to Work Items (HITL Protected). |
| **Boards** | `wit_query` | Query work items using WIQL (Work Item Query Language). |
| **HITL** | `action_get_status` | Poll approval status and execution outcome using an action's `tracingToken`. |
| **Core** | `core_list_projects` | List all projects within the Azure DevOps organization. |
| **Core** | `core_list_project_teams` | List teams belonging to a specific project. |
| **Pipelines** | `pipelines_build` | Check execution status and history of Build / CI Pipelines. |
| **Pipelines** | `pipelines_build_log` | Retrieve raw build step logs. |
---
## 🚀 Quick Deployment Guide
### Step 1: Create the Cloudflare D1 Database
> 💡 Database tables are provisioned automatically on first request. You only need to create the database instance once:
- **Option A (Via Cloudflare Dashboard - Recommended):**
Navigate to Dashboard -> **Workers & Pages** -> select Worker `azure-devops-mcp-worker` -> **Settings** -> **Bindings** -> Click **Add** -> **D1 Database**:
- Variable name: `DB`
- D1 database: Click **Create new database**, name it `azure-devops-mcp-db` -> **Save & Deploy**.
- **Option B (Via CLI):**
```bash
npx wrangler d1 create azure-devops-mcp-db
```
Paste the returned `database_id` UUID into `wrangler.jsonc`.
### Step 2: Configure Telegram Bot & Store Secrets
1. In Telegram, chat with `@BotFather` and send `/newbot` to create your bot and obtain `TELEGRAM_BOT_TOKEN`.
2. Chat with `@userinfobot` to retrieve your personal numerical ID and set it as `TELEGRAM_CHAT_ID` in `wrangler.jsonc`.
3. Store sensitive secrets on Cloudflare:
```bash
npx wrangler secret put PERSONAL_ACCESS_TOKEN
# Paste your Azure DevOps Personal Access Token
npx wrangler secret put CLIENT_SECRET
# Enter your custom client secret for Gemini Web authentication
npx wrangler secret put TELEGRAM_BOT_TOKEN
# Paste your Telegram Bot token
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET
# Enter a random secret token to secure webhook callbacks
```
4. Register the Webhook with Telegram:
```bash
curl -X POST "https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/setWebhook" \
-H "Content-Type: application/json" \
-d '{
"url": "https://<your-worker-domain>/telegram/webhook",
"secret_token": "<TELEGRAM_WEBHOOK_SECRET>"
}'
```
### Step 3: Deploy to Cloudflare Workers
```bash
npm run deploy
```
---
## 🤖 Connecting to Gemini Web
In Gemini Web, open **Settings** -> **Connected Apps** -> **Connect to an MCP Server**:
- **MCP server URL:** `https://<your-worker-domain>/mcp`
- **Client ID:** Enter the `CLIENT_ID` defined in `wrangler.jsonc` (e.g., `my-client`).
- **Client secret:** Enter the secret value you provided to `npx wrangler secret put CLIENT_SECRET`.
- Click **Next** to complete the connection!
---
## 📄 License
This project is licensed under the open-source **[MIT License](LICENSE)**.