OkAdministration2514 details how they built a dynamic MCP server that empowers Claude Code users to seamlessly switch Azure DevOps contexts by project directory, offering robust DevOps automation for multi-client work.

Dynamic Azure DevOps MCP Server for Seamless Context Switching in Claude Code

Author: OkAdministration2514

TL;DR

Created a custom MCP server enabling Claude Code users to work across multiple Azure DevOps projects without manual re-authentication. The tool leverages smart directory detection and local config files to auto-switch contexts, significantly improving multi-client DevOps workflows.

The Problem

When using Claude Code with Azure DevOps, developers working on multiple projects encounter static authentication limitations—typically restricted to a single Azure DevOps org or project at a time due to environment variable settings. Switching between projects requires restarts and config changes, causing workflow interruptions.

The Solution: Dynamic Context Switching

The solution is u/wangkanai/devops-mcp, an MCP server that:

  • Detects the active project directory automatically
  • Uses project-specific .azure-devops.json files to store organization and PAT credentials
  • Switches Azure DevOps authentication contexts instantly as you move directories, with no manual config edits or restarts required

Key Features

  • Zero-Configuration Directory Switching:
    • Simply changing directories updates your Azure DevOps context automatically
  • Comprehensive DevOps Tooling (8 total):
    • Work item management (create/query with full metadata)
    • Repository and build management
    • Pipeline triggering/monitoring
    • Pull request operations
    • Dynamic context reporting
  • Security Focus:
    • PAT tokens stored locally only
    • Credentials never committed to git
    • Credential isolation per project
    • Compliant with GitHub secret scanning policies

How It Works

  1. Each project directory contains a .azure-devops.json file with organization-specific credentials and metadata.
  2. The MCP server detects directory changes and loads context from the respective config file.
  3. Authentication is switched on-the-fly without restarts, maintaining a seamless workflow across multiple clients or projects.

Example Directory Usage

cd ~/projects/company-a   # Switches to Company A's Azure DevOps context
cd ~/projects/company-b   # Switches to Company B's Azure DevOps context

Example Config File (.azure-devops.json)

{
  "organizationUrl": "https://dev.azure.com/your-org",
  "project": "YourProject",
  "pat": "your-pat-token",
  "description": "Project-specific Azure DevOps config"
}

Installation

Quick setup via Claude Code:

claude mcp add devops-mcp -- npx u/wangkanai/devops-mcp

Add a .azure-devops.json for each project as shown above.

Real-World Impact

  • 90% Time Reduction in context switching
  • Zero Authentication Errors when moving between projects
  • Simplified Consulting and Multi-client Workflows
  • Enhanced Security: Credential isolation, local-only storage

Tech Stack & Metrics

  • Node.js + TypeScript with MCP SDK
  • >95% Test Coverage
  • Sub-200ms Context Switching Overhead
  • Production Ready: Robust error handling & fallbacks

Why This Matters for DevOps

This approach removes one of the main productivity bottlenecks in multi-organizational DevOps work, making context switching transparent and secure. Especially valuable for consultants and developers managing numerous client projects.

Questions or need implementation help? Comment below!

This post appeared first on “Reddit Azure DevOps”. Read the entire article here