Skip to content

Add read-only Azure DevOps Server (on-prem) pull request review mode - #1658

Closed
jharperTBE wants to merge 1 commit into
microsoft:mainfrom
jharperTBE:jharpertbe-on-prem-pr-mcp-support
Closed

jharperTBE wants to merge 1 commit into
microsoft:mainfrom
jharperTBE:jharpertbe-on-prem-pr-mcp-support

Conversation

@jharperTBE

Copy link
Copy Markdown

The local server only supports Azure DevOps Services today, because several of the endpoints it uses (tenant discovery, Entra sign-in, and some cloud-only APIs) don't exist on-prem. This PR adds a narrow, opt-in mode so agents such as the GitHub Copilot CLI can review pull requests on Azure DevOps Server 2019+ using Windows integrated authentication.

Approach

  • Gated by --server-url. With the flag, the positional argument is the collection name. The server skips tenant discovery and Entra auth and registers only the new read-only tools. Without the flag, cloud startup is unchanged.
  • Collection-scoped REST client (src/onprem/client.ts, config.ts). The default api-version is 5.0 (Server 2019) and can be changed with --api-version. The client validates the URL and collection, only builds requests inside the configured collection URL, and never follows redirects.
  • Windows integrated auth (src/onprem/transport.ts). Node/undici can't do SSPI, so requests go through a persistent hidden PowerShell worker. The worker uses .NET HttpClient with UseDefaultCredentials (NTLM/Negotiate as the signed-in user), and Node never holds a secret. -a pat is also supported (PERSONAL_ACCESS_TOKEN, Basic).
  • Five read-only tools (src/tools/onprem-pull-requests.ts), all annotated read-only and wrapped with the existing content-safety spotlighting:
    • onprem_project_list
    • onprem_repository (list/get)
    • onprem_pull_request (list/get/commits/iterations/work_items)
    • onprem_pull_request_change (list/diff/content)
    • onprem_pull_request_thread
  • Local unified diff (src/onprem/diff.ts). The server has no text-diff REST API, so the tool fetches the base (merge base) and source blobs and computes an LCS diff locally. Very large inputs are size-capped.
  • Docs: new docs/ONPREM.md, plus links from docs/FAQ.md and docs/GETTINGSTARTED.md.

Areas for careful review

  • The PowerShell worker approach (spawned with -EncodedCommand). Constrained Language Mode or app control policies can block it, and in that case the error is returned to the caller.
  • windows is a new --authentication choice. The yargs default was removed so on-prem mode can default to windows. The effective cloud default (interactive) is unchanged.

GitHub issue number

N/A

Associated Risks

  • Cloud startup path was refactored slightly (createMcpServer() extracted, auth default computed after parsing). The full test suite passes.
  • On-prem compatibility depends on server REST behavior. This was verified on one server only (see below).
  • Windows integrated auth is Windows-only. Use pat on other platforms.

✅ PR Checklist

  • I have read the contribution guidelines
  • I have read the code of conduct guidelines
  • Title of the pull request is clear and informative.
  • 👌 Code hygiene
  • 🔭 Telemetry added, updated, or N/A
  • 📄 Documentation added, updated, or N/A
  • 🛡️ Automated tests added, or N/A

🧪 How did you test it?

  • npx jest: passed (26 suites, 1392 tests). New tests cover config validation, the diff algorithm, the client (URL guarding, errors), the transport (worker protocol, timeouts, restarts, PAT), the tools, and registration. The tool-annotation count was updated from 45 to 50.
  • npx tsc --noEmit, npm run build, npx eslint on changed files, npx prettier --check src test docs, npm run validate-tools: all passed.
  • Live, read-only, end-to-end MCP stdio smoke test against an on-prem Azure DevOps Server (reports REST API versions up to 7.2), using -a windows and the signed-in user's credentials:
    • The project list succeeded.
    • On a real PR, every action returned successfully: get, commits, iterations, work_items, change list, diff, content, and threads.
  • Not tested live: PAT auth on-prem, Azure DevOps Server 2019 itself, and Constrained Language Mode environments.

Gated behind --server-url. Adds a collection-scoped REST client, Windows
integrated authentication via a PowerShell HttpClient worker (SSPI), PAT
fallback, local unified diffs, and five read-only onprem_* tools for PR
metadata, changes, diffs, file content, and threads. Cloud behavior is
unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jharperTBE
jharperTBE requested a review from a team as a code owner October 1, 2026 19:20
@jharperTBE

Copy link
Copy Markdown
Author

Opened by mistake; closing.

@jharperTBE jharperTBE closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant