|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is an Azure DevOps MCP (Model Context Protocol) Server that provides access to Azure DevOps services through standardized tools. The server enables AI agents to interact with Azure DevOps APIs for managing projects, work items, builds, releases, repositories, and more. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Building and Development |
| 12 | + |
| 13 | +- `npm run build` - Compile TypeScript to JavaScript in `dist/` directory |
| 14 | +- `npm run watch` - Watch mode for continuous compilation during development |
| 15 | +- `npm run prepare` - Runs build automatically (used by npm lifecycle) |
| 16 | +- `npm run clean` - Remove the `dist/` directory |
| 17 | +- `npm run validate-tools` - Validate tool names and TypeScript compilation |
| 18 | + |
| 19 | +### Code Quality |
| 20 | + |
| 21 | +- `npm run eslint` - Run ESLint linter |
| 22 | +- `npm run eslint-fix` - Run ESLint with automatic fixes |
| 23 | +- `npm run format` - Format code with Prettier |
| 24 | +- `npm run format-check` - Check code formatting without making changes |
| 25 | + |
| 26 | +### Testing |
| 27 | + |
| 28 | +- `npm test` - Run Jest test suite |
| 29 | +- Coverage thresholds are set to 40% for branches, functions, lines, and statements |
| 30 | +- Test files are located in `test/` directory and follow the pattern `**/?(*.)+(spec|test).[jt]s?(x)` |
| 31 | + |
| 32 | +### Running the Server |
| 33 | + |
| 34 | +- `npm start` - Start the MCP server (requires Azure DevOps organization name as argument) |
| 35 | +- `npm run inspect` - Run the server with MCP inspector for debugging |
| 36 | + |
| 37 | +### Local Development Setup |
| 38 | + |
| 39 | +For source installation (development mode): |
| 40 | + |
| 41 | +1. Clone repository and run `npm install` |
| 42 | +2. Configure `.vscode/mcp.json` with local command: `"mcp-server-azuredevops"` |
| 43 | +3. The server requires an Azure DevOps organization name as the first argument |
| 44 | + |
| 45 | +## Architecture |
| 46 | + |
| 47 | +### Core Components |
| 48 | + |
| 49 | +- **Entry Point**: `src/index.ts` - Main server initialization, Azure authentication, and MCP server setup |
| 50 | +- **Tool Configuration**: `src/tools.ts` - Aggregates all tool modules and configures them with the MCP server |
| 51 | +- **Authentication**: Uses `@azure/identity` with `DefaultAzureCredential` for Azure DevOps API access |
| 52 | +- **Client Setup**: Creates Azure DevOps WebApi clients with proper user agent and authentication |
| 53 | + |
| 54 | +### Tool Organization |
| 55 | + |
| 56 | +Tools are organized by Azure DevOps service area in `src/tools/`: |
| 57 | + |
| 58 | +- `core.ts` - Projects and teams management |
| 59 | +- `work.ts` - Iterations and team work management |
| 60 | +- `workitems.ts` - Work item CRUD operations and queries |
| 61 | +- `repos.ts` - Repository and pull request management |
| 62 | +- `builds.ts` - Build pipelines and execution |
| 63 | +- `releases.ts` - Release management |
| 64 | +- `testplans.ts` - Test planning and execution |
| 65 | +- `wiki.ts` - Wiki content management |
| 66 | +- `search.ts` - Search across code, wiki, and work items |
| 67 | +- `advsec.ts` - Advanced Security alerts management |
| 68 | +- `auth.ts` - Authentication utilities |
| 69 | + |
| 70 | +### Key Patterns |
| 71 | + |
| 72 | +- Each tool module follows the pattern: `configure[ServiceName]Tools(server, tokenProvider, connectionProvider, ...)` |
| 73 | +- All tools use Zod schemas for input validation and JSON schema generation |
| 74 | +- Authentication is handled centrally through token and connection providers |
| 75 | +- User agent composition includes package version and MCP client information |
| 76 | + |
| 77 | +### Environment Variables |
| 78 | + |
| 79 | +- `ADO_MCP_AZURE_TOKEN_CREDENTIALS` - Optional override for Azure token credentials |
| 80 | +- Falls back to `AZURE_TOKEN_CREDENTIALS = "dev"` for development |
| 81 | + |
| 82 | +### Project Structure |
| 83 | + |
| 84 | +- `src/` - TypeScript source code |
| 85 | +- `dist/` - Compiled JavaScript output (created by build) |
| 86 | +- `test/` - Jest test files with mocks in `test/mocks/` |
| 87 | +- `docs/` - Documentation files (FAQ, HOWTO, TROUBLESHOOTING) |
| 88 | + |
| 89 | +## Important Notes |
| 90 | + |
| 91 | +### Adding New Tools |
| 92 | + |
| 93 | +- Follow existing patterns in tool modules under `src/tools/` |
| 94 | +- Use Azure DevOps TypeScript clients when available, fall back to direct API calls only when necessary |
| 95 | +- Add tool configuration to `configureAllTools()` in `src/tools.ts` |
| 96 | +- Include comprehensive input validation with Zod schemas |
| 97 | +- Follow the established naming convention: `[service]_[action]_[object]` |
| 98 | + |
| 99 | +### Testing |
| 100 | + |
| 101 | +- Mock Azure DevOps API responses in `test/mocks/` |
| 102 | +- Test files mirror the source structure in `test/src/` |
| 103 | +- Use Jest with ts-jest preset for TypeScript support |
| 104 | + |
| 105 | +### Code Quality Standards |
| 106 | + |
| 107 | +- TypeScript with strict mode enabled |
| 108 | +- ESLint configuration with Prettier integration |
| 109 | +- All files must include Microsoft copyright headers |
| 110 | +- Follow existing code patterns for consistency |
0 commit comments