Examples & Tutorials

Examples & Tutorials

Learn how to use the Azure DevOps MCP Server with practical examples and common workflows.

Basic Usage Examples

🔍

Exploring Your Organization

Start by getting familiar with your Azure DevOps organization and discover available projects and repositories.

Foundation
📋

Working with Work Items

Query and analyze work items, bugs, and user stories across your projects with powerful filtering capabilities.

Core Workflow

Exploring Your Organization

🔍

Discovery Workflow

Start by getting familiar with your Azure DevOps organization:

Step 1: List All Projects
list_projects
Step 2: Explore Project Repositories
list_repositories projectName="MyProject"
Step 3: Browse Repository Contents
list_repository_items projectName="MyProject" repositoryId="my-repo" path="/"

Working with Work Items

📋

Work Item Management

Query and analyze work items across your projects:

Query Active Bugs
list_work_items projectName="MyProject" workItemType="Bug" state="Active"
Get Work Item Details
get_work_item projectName="MyProject" workItemId=1234
Batch Operations
batch_get_work_items projectName="MyProject" workItemIds=[1234, 1235, 1236]

💡 Use batch operations for better performance when retrieving multiple items.


### Code Repository Analysis

Analyze your codebase and review processes:

Get file contents

get_file_content projectName=”MyProject” repositoryId=”my-repo” path=”/README.md”

Browse source code structure

list_repository_items projectName=”MyProject” repositoryId=”my-repo” path=”/src”

Check multiple repositories at once

batch_get_repositories projectName=”MyProject” repositoryIds=[“repo1”, “repo2”, “repo3”]


---

## Advanced Workflows

<div class="text-center mb-12">
  <p class="text-xl text-gray-600 max-w-3xl mx-auto">Discover advanced patterns and workflows for complex Azure DevOps operations, from comprehensive testing to security audits.</p>
</div>

### Test Plan Analysis Workflow

<div class="bg-white border border-gray-200 rounded-lg p-6 mb-8">
  <div class="flex items-center mb-4">
    <span class="text-xl mr-2">🧪</span>
    <h4 class="text-lg font-semibold text-gray-900">Comprehensive Test Management</h4>
  </div>

  <p class="text-gray-700 mb-6">Systematic approach to test plan analysis and quality assurance:</p>

1. Get all test plans for a project

get_test_plans projectName=”MyProject”

2. Dive into a specific test plan

get_test_plan projectName=”MyProject” planId=123

3. Analyze test suites and cases

get_test_suites projectName=”MyProject” planId=123

4. Review recent test runs

get_test_runs projectName=”MyProject” planId=123

5. Get detailed results for a test run

get_test_run projectName=”MyProject” runId=456 get_test_results projectName=”MyProject” runId=456


### Code Review and PR Management

Streamline your pull request workflow:

1. Review repository structure

list_repositories projectName=”MyProject”

2. Check specific files before creating PR

get_file_content projectName=”MyProject” repositoryId=”my-repo” path=”/src/main.cs”

3. Create a draft pull request (requires write permissions)

create_draft_pull_request projectName=”MyProject” repositoryId=”my-repo” sourceBranch=”feature/new-feature” targetBranch=”main” title=”Add new authentication feature” description=”This PR implements JWT-based authentication” confirm=true

4. Add review comments (requires write permissions)

add_pull_request_comment projectName=”MyProject” repositoryId=”my-repo” pullRequestId=123 comment=”Great implementation! Just one suggestion on error handling.” confirm=true

</div>

---

### Work Item Management

<div class="bg-white border border-gray-200 rounded-lg p-6 mb-8">
  <div class="flex items-center mb-4">
    <span class="text-xl mr-2">📋</span>
    <h4 class="text-lg font-semibold text-gray-900">Comprehensive Work Item Operations</h4>
  </div>

  <p class="text-gray-700 mb-6">Organize and track work items effectively with advanced querying and management capabilities:</p>

1. Query work items by different criteria

list_work_items projectName=”MyProject” workItemType=”User Story” state=”Active” list_work_items projectName=”MyProject” assignedTo=”john.doe@company.com”

2. Get detailed work item information

get_work_item projectName=”MyProject” workItemId=1234

3. Update work item tags (requires write permissions)

update_work_item_tags projectName=”MyProject” workItemId=1234 tagsToAdd=[“priority-1”, “security”] tagsToRemove=[“needs-triage”] confirm=true

4. Batch process multiple work items

batch_get_work_items projectName=”MyProject” workItemIds=[1234, 1235, 1236, 1237]


## Common Use Cases

### Project Health Dashboard

Create a comprehensive project overview:

```bash
# Get project overview
list_projects

# For each project, get:
# - Repository count and details
list_repositories projectName="ProjectA"

# - Active work item count by type
list_work_items projectName="ProjectA" workItemType="Bug" state="Active"
list_work_items projectName="ProjectA" workItemType="Task" state="Active"
list_work_items projectName="ProjectA" workItemType="User Story" state="Active"

# - Test coverage and results
get_test_plans projectName="ProjectA"
get_test_runs projectName="ProjectA"

# - Performance metrics
get_performance_metrics
get_cache_statistics

Release Planning

Plan and track releases across multiple repositories:

# 1. Identify all repositories in the project
list_repositories projectName="MyProject"

# 2. Check current state of each repository
batch_get_repositories projectName="MyProject" repositoryIds=["api", "frontend", "mobile"]

# 3. Review release-related work items
list_work_items projectName="MyProject" workItemType="User Story" state="Resolved"
list_work_items projectName="MyProject" workItemType="Bug" state="Closed"

# 4. Analyze test readiness
get_test_plans projectName="MyProject"
get_test_runs projectName="MyProject"

# 5. Review recent changes in key files
get_file_content projectName="MyProject" repositoryId="api" path="/CHANGELOG.md"
get_file_content projectName="MyProject" repositoryId="frontend" path="/package.json"

Security and Compliance Audit

Audit your projects for security and compliance:

# 1. Get all projects and repositories
list_projects
list_repositories projectName="MyProject"

# 2. Check security-related files
get_file_content projectName="MyProject" repositoryId="my-repo" path="/SECURITY.md"
get_file_content projectName="MyProject" repositoryId="my-repo" path="/.github/dependabot.yml"

# 3. Review security-tagged work items
list_work_items projectName="MyProject" workItemType="Bug"
# (then filter results by security tags)

# 4. Check test coverage for security features
get_test_plans projectName="MyProject"
get_test_suites projectName="MyProject" planId=123

# 5. Add security tags to relevant work items
update_work_item_tags
  projectName="MyProject"
  workItemId=1234
  tagsToAdd=["security-review", "compliance"]
  confirm=true

Performance Optimization Tips

Batch Operations

Use batch operations for better performance:

# Instead of multiple individual calls:
# get_work_item projectName="MyProject" workItemId=1234
# get_work_item projectName="MyProject" workItemId=1235
# get_work_item projectName="MyProject" workItemId=1236

# Use batch operation:
batch_get_work_items projectName="MyProject" workItemIds=[1234, 1235, 1236]

# Same for repositories:
batch_get_repositories projectName="MyProject" repositoryIds=["repo1", "repo2", "repo3"]

Cache Management

Monitor and manage caching for optimal performance:

# Check cache performance
get_cache_statistics

# Get performance metrics
get_performance_metrics

# Clear cache when you need fresh data
clear_cache confirm=true

Monitoring System Performance

Keep track of system performance:

# Regular performance monitoring
get_performance_metrics

# Check for:
# - Slow operations (>1000ms threshold)
# - High API call counts
# - Low cache hit rates
# - Memory usage patterns

# Monitor cache effectiveness
get_cache_statistics

# Look for:
# - Hit rate >80% (good)
# - Low eviction counts
# - Reasonable memory usage

Integration Patterns

Claude Desktop Workflows

Common patterns when using with Claude Desktop:

Project Analysis:

“Can you analyze the current state of MyProject? Show me the active work items, recent test runs, and any security-related issues.”

Code Review Assistance:

“Help me review the pull requests in MyProject. Check the recent changes and suggest areas that need attention.”

Release Planning:

“What’s the status of the next release for MyProject? Show me completed features, outstanding bugs, and test coverage.”

VS Code Integration

Use with VS Code MCP extensions for enhanced development workflow:

  1. Contextual Work Item Creation: Create work items based on TODO comments
  2. Automated PR Comments: Add comments based on code analysis
  3. Test Plan Updates: Update test plans when adding new features
  4. Performance Monitoring: Track API usage and performance in development

Error Handling Examples

Handle common errors gracefully:

# Authentication issues
# Error: AUTHENTICATION_FAILED - Check your PAT token

# Permission issues
# Error: AUTHORIZATION_DENIED - Verify PAT permissions

# Write operation not enabled
# Error: OPERATION_NOT_ENABLED - Enable in configuration

# Rate limiting
# Error: RATE_LIMIT_EXCEEDED - Wait and retry, or use batch operations

# Missing confirmation
# Error: CONFIRMATION_REQUIRED - Add confirm=true parameter

Configuration Examples

Basic Read-Only Setup

{
  "AzureDevOps": {
    "OrganizationUrl": "https://dev.azure.com/myorg",
    "PersonalAccessToken": "your-pat-here"
  }
}

Write Operations Enabled

{
  "AzureDevOps": {
    "OrganizationUrl": "https://dev.azure.com/myorg",
    "PersonalAccessToken": "your-pat-here",
    "EnabledWriteOperations": [
      "PullRequestComments",
      "CreateDraftPullRequest",
      "UpdateWorkItemTags"
    ],
    "RequireConfirmation": true,
    "EnableAuditLogging": true
  }
}

Production Configuration

{
  "AzureDevOps": {
    "OrganizationUrl": "https://dev.azure.com/myorg",
    "EnabledWriteOperations": ["PullRequestComments"],
    "RequireConfirmation": true,
    "EnableAuditLogging": true
  },
  "Caching": {
    "EnableMemoryCache": true,
    "MaxMemoryCacheSizeMB": 100,
    "DefaultCacheDurationMinutes": 15
  },
  "Performance": {
    "SlowOperationThresholdMs": 1000,
    "EnableCircuitBreaker": true,
    "EnableMonitoring": true
  },
  "Security": {
    "EnableKeyVault": true,
    "KeyVaultUrl": "https://your-keyvault.vault.azure.net/"
  },
  "RateLimiting": {
    "EnableRateLimiting": true,
    "RequestsPerMinute": 60,
    "RequestsPerHour": 1000
  }
}

Best Practices

Security

  • 🔒 Use minimal required PAT permissions
  • 🔐 Enable audit logging for write operations
  • 🛡️ Use Azure Key Vault in production
  • ⚠️ Always require confirmation for write operations

Performance

  • ⚡ Use batch operations when processing multiple items
  • 💾 Monitor cache hit rates and performance metrics
  • 🎯 Set appropriate cache durations for your use case
  • 📊 Use performance monitoring to identify bottlenecks

Operations

  • 📝 Enable audit logging for compliance
  • 🔄 Implement proper error handling in your workflows
  • 📈 Monitor rate limits and adjust batch sizes accordingly
  • 🛠️ Use draft PRs for safer code review processes

Need Help?