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 as a dual-protocol, stateless serverless edge service on **Cloudflare Workers**.
The server implements the **Model Context Protocol (MCP)** over **Stateless Streamable HTTP** (`POST /mcp`) supporting both **[MCP `2026-07-28`](docs/2026-07-28/README.md)** and **[MCP `2025-11-25`](docs/2025-11-25/README.md)** concurrently. It connects directly to **Azure DevOps Services** via a server-managed **Personal Access Token (PAT)** without being blocked by Microsoft Entra ID tenant policies.
---
## ⚡ Key Highlights & Architecture
1. **Dual-Protocol Stateless Edge (`2026-07-28` + `2025-11-25`):**
- Single canonical `POST /mcp` endpoint (`GET /mcp` and `DELETE /mcp` return `405 Method Not Allowed`; no `Mcp-Session-Id`, no legacy `/sse`, no JSON-RPC batching).
- Era-isolated `McpServer` instances: `2026-07-28` serves `server/discover`, `_meta` envelopes, `CacheableResult`, and `Mcp-Param-*` headers; `2025-11-25` serves `initialize`, `notifications/initialized`, `ping`, `tools/list`, and `tools/call`.
2. **Two-Worker OAuth 2.1 & OpenID Connect Discovery 1.0:**
- **Authorization Server Worker (`azure-devops-mcp-auth`)**: Serves **RFC 8414** (`/.well-known/oauth-authorization-server`), dedicated **OpenID Connect Discovery 1.0** (`/.well-known/openid-configuration*` including path-insertion/path-appending + `/.well-known/jwks.json`), **Client ID Metadata Documents (CIMD)** (`SEP-991`, RFC 7591 `/oauth/register` disabled), **PKCE `S256`**, CSRF/anti-framing `/oauth/authorize` consent UI, and Service Binding `validateToken` RPC.
- **MCP Resource Server Worker (`azure-devops-mcp-worker`)**: Serves **RFC 9728** (`/.well-known/oauth-protected-resource/mcp`), enforces `Origin`/`Host`/non-wildcard CORS guards, and performs **step-up `403 insufficient_scope`** authorization (`mcp:read` vs `mcp:write`).
3. **Human-in-the-Loop (HITL) Approvals via Telegram & Cloudflare D1:**
- All mutating tools (`*_write`) stage a `Hold` action record (15-minute TTL) in **Cloudflare D1** keyed by `owner_user_id` and an opaque `act_<16-hex>` handle, notifying **Telegram** with interactive `[✅ Approve]` and `[❌ Reject]` buttons.
- Agents poll `action_get_status` safely without HTTP timeouts.
4. **Dual-Tier Telegram Webhook & Output Security:**
- Constant-time verification of `X-Telegram-Bot-Api-Secret-Token` (`TELEGRAM_WEBHOOK_SECRET`), authorized sender check (`TELEGRAM_CHAT_ID`), atomic `Hold -> Executing -> Approved` claiming, and Spotlight delimiter wrapping on untrusted Azure DevOps payloads.
5. **Dynamic Skills over MCP (`SEP-2640`) & Google-Authenticated Admin Console:**
- Serves dynamic skills from **Cloudflare D1** via **`io.modelcontextprotocol/skills`** (`skills/list`, `skills/get`), **`skill://` Resources** (`resources/list`, `resources/read`), and **MCP Prompts** (`prompts/list`, `prompts/get`) on both `2026-07-28` and `2025-11-25` lanes without hardcoding skill text in source code.
- Manage, upload `.md` files, or import JSON bundles live at **`/admin/skills`** protected by **Cloudflare Zero Trust Access** (Google Account Login) with cryptographic RS256 JWKS verification.
---
## 📚 Protocol Documentation (Separated by Version)
- **Documentation Hub**: [docs/README.md](docs/README.md)
- **MCP `2026-07-28`**: [docs/2026-07-28/README.md](docs/2026-07-28/README.md)
- **MCP `2025-11-25`**: [docs/2025-11-25/README.md](docs/2025-11-25/README.md)
---
## 📋 Environment Variables, Secrets & Bindings
### Authorization Server Worker (`wrangler.auth.jsonc`)
| Name | Type | Purpose |
| :-------------------- | :----------------: | :------------------------------------------------------------------------------------------------ |
| `OAUTH_ISSUER` | Plaintext (`vars`) | Canonical OAuth 2.1 issuer origin URL (e.g., `http://localhost:8788` or `https://<auth-domain>`). |
| `MCP_RESOURCE_URL` | Plaintext (`vars`) | Canonical MCP Resource URL bound as token audience (e.g., `http://localhost:8787/mcp`). |
| `OAUTH_ACCESS_SECRET` | **Secret** 🔒 | Optional shared passphrase protecting the `/oauth/authorize` consent UI (`wrangler secret put`). |
| `OAUTH_KV` | **KV Binding** | Cloudflare KV namespace storing OAuth grants, consent transactions, tokens, and CIMD cache. |
### MCP Resource Server Worker (`wrangler.jsonc`)
| Name | Type | Purpose |
| :----------------------------- | :-----------------: | :------------------------------------------------------------------------------------------ |
| `AZURE_DEVOPS_ORG` | Plaintext (`vars`) | Azure DevOps organization name (e.g., `example-org`). |
| `MCP_ENABLED_TOOLSETS` | Plaintext (`vars`) | Enabled toolsets: `"repos,wit,core,pipelines"` or `"all"`. |
| `TELEGRAM_CHAT_ID` | Plaintext (`vars`) | Authorized Telegram user/chat ID permitted to approve or reject staged actions. |
| `OAUTH_ISSUER` | Plaintext (`vars`) | Authorization Server issuer URL advertised in RFC 9728 Protected Resource Metadata. |
| `MCP_RESOURCE_URL` | Plaintext (`vars`) | Canonical `/mcp` Resource URL used for RFC 9728 metadata and audience validation. |
| `MCP_ALLOWED_HOSTNAMES` | Plaintext (`vars`) | Comma-separated allowed HTTP `Host` header hostnames for `/mcp`. |
| `MCP_ALLOWED_ORIGIN_HOSTNAMES` | Plaintext (`vars`) | Comma-separated allowed `Origin` hostnames for `/mcp` (wildcards `*` are rejected). |
| `MCP_CORS_ORIGIN` | Plaintext (`vars`) | Explicit non-wildcard CORS `Access-Control-Allow-Origin` value(s) for `/mcp`. |
| `CF_ACCESS_TEAM_DOMAIN` | Plaintext (`vars`) | Cloudflare Access team domain (e.g., `https://<team>.cloudflareaccess.com`) for `/admin/*`. |
| `CF_ACCESS_AUD` | Plaintext (`vars`) | Cloudflare Access Application Audience (AUD) tag protecting `/admin/skills`. |
| `CF_ACCESS_ALLOWED_EMAILS` | Plaintext (`vars`) | Optional comma-separated allowlist of authorized Google emails for `/admin/skills`. |
| `ADMIN_LOCAL_DEV_EMAIL` | Plaintext (`vars`) | Optional local-only bypass email honored strictly on loopback when Access is unset. |
| `PERSONAL_ACCESS_TOKEN` | **Secret** 🔒 | Azure DevOps PAT with read/write access to Repos, Boards, and Pipelines. |
| `TELEGRAM_BOT_TOKEN` | **Secret** 🔒 | Telegram Bot token from `@BotFather`. |
| `TELEGRAM_WEBHOOK_SECRET` | **Secret** 🔒 | Secret token verified against `X-Telegram-Bot-Api-Secret-Token`. |
| `AUTH_SERVER` | **Service Binding** | Private RPC binding to `azure-devops-mcp-auth` (`validateToken`). |
| `DB` | **D1 Binding** | Cloudflare D1 database storing `actions`, `skills`, and `skill_files` (`migrations/`). |
---
## 🛠️ MCP Tools Catalog
| Domain | Tool Name | Scope | Description & Supported Actions |
| :------------ | :------------------------------- | :---------: | :------------------------------------------------------------------------------------------------------------- |
| **Repos** | `repo_pull_request` | `mcp:read` | `get` PR details, `list` PRs, or `get_changes` (server-side `filediffs` + unified diffs for remote PR review). |
| **Repos** | `repo_file` | `mcp:read` | Read file contents directly from Azure DevOps Git repositories. |
| **Repos** | `repo_pull_request_thread` | `mcp:read` | Read review comments and discussion threads within a Pull Request. |
| **Repos** | `repo_pull_request_thread_write` | `mcp:write` | Manage PR review threads: `create`, `reply`, `update`, or `update_status` (HITL Protected, 15-minute TTL). |
| **Repos** | `repo_pull_request_write` | `mcp:write` | `create` or `update` Pull Requests (HITL Protected, 15-minute TTL). |
| **Boards** | `wit_work_item` | `mcp:read` | Retrieve User Stories, Tasks, Bugs, or Epics by ID or list of IDs. |
| **Boards** | `wit_work_item_write` | `mcp:write` | `create` or `update` Work Items (title, state, fields, assignedTo) (HITL Protected, 15-minute TTL). |
| **Boards** | `wit_work_item_comment_write` | `mcp:write` | Post discussion comments to Work Items (HITL Protected, 15-minute TTL). |
| **Boards** | `wit_query` | `mcp:read` | Query work items using WIQL (Work Item Query Language). |
| **HITL** | `action_get_status` | `mcp:read` | Poll approval status and execution outcome using an action's `tracingToken` (`act_*`, 15-minute TTL). |
| **Core** | `core_list_projects` | `mcp:read` | List all projects within the Azure DevOps organization. |
| **Core** | `core_list_project_teams` | `mcp:read` | List teams belonging to a specific project. |
| **Pipelines** | `pipelines_build` | `mcp:read` | Check execution status and history of Build / CI Pipelines. |
| **Pipelines** | `pipelines_build_log` | `mcp:read` | Retrieve raw build step logs. |
---
## 🚀 Quick Deployment & Local Development
1. **Provision Cloudflare KV & D1**:
- Create `OAUTH_KV` and update `wrangler.auth.jsonc`.
- Create `azure-devops-mcp-db` (`npx wrangler d1 create azure-devops-mcp-db`), apply `migrations/` (or let runtime auto-provision), and update `wrangler.jsonc`.
2. **Set Secrets**:
```bash
npx wrangler secret put OAUTH_ACCESS_SECRET --config wrangler.auth.jsonc
npx wrangler secret put PERSONAL_ACCESS_TOKEN --config wrangler.jsonc
npx wrangler secret put TELEGRAM_BOT_TOKEN --config wrangler.jsonc
npx wrangler secret put TELEGRAM_WEBHOOK_SECRET --config wrangler.jsonc
```
3. **Deploy Both Workers**:
```bash
npm run deploy
```
4. **Local Development**:
```bash
npm run dev:auth
npm run dev:mcp
```
5. **Verification**:
```bash
npm run lint && npm run format:check && npm run typecheck && npm test
```
---
## 🧩 Dynamic Skills Admin Console (Google Login via Cloudflare Access)
1. **Configure Cloudflare Zero Trust Access**:
- In Cloudflare Zero Trust Dashboard, add **Google** under _Settings > Authentication > Login methods_.
- Create a Self-Hosted **Access Application** protecting `<your-worker-domain>/admin*` and `<your-worker-domain>/api/admin*` with an Allow policy for your Google email(s).
- Set `CF_ACCESS_TEAM_DOMAIN`, `CF_ACCESS_AUD`, and optionally `CF_ACCESS_ALLOWED_EMAILS` in `wrangler.jsonc`.
- For local `wrangler dev` on `http://localhost:8787`, you can set `ADMIN_LOCAL_DEV_EMAIL=you@gmail.com` (never active on non-loopback hosts).
2. **Import the Remote PR Reviewer Skill**:
- Open `/admin/skills`, sign in with Google, click **Import JSON Bundle**, select [`examples/skills/azure-devops-pr-reviewer.bundle.json`](examples/skills/azure-devops-pr-reviewer.bundle.json), and click **Save Skill to D1**.
- Connected MCP clients immediately discover `azure-devops-pr-reviewer` via `skills/list`, `resources/list` (`skill://azure-devops-pr-reviewer/SKILL.md`), and `prompts/list` (`review_pull_request`) for 100% remote PR reviews.
---
## 📄 License
This project is licensed under the open-source **[MIT License](LICENSE)**.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues