Azure DevOps 集成
STDIO无缝访问Azure DevOps的集成服务
无缝访问Azure DevOps的集成服务
A powerful integration for Azure DevOps that provides seamless access to work items, repositories, projects, boards, and sprints through the Model Context Protocol (MCP) server.
This server provides a convenient API for interacting with Azure DevOps services, enabling AI assistants and other tools to manage work items, code repositories, boards, sprints, and more. Built with the Model Context Protocol, it provides a standardized interface for communicating with Azure DevOps.
The integration is organized into eight main tool categories:
To install azuredevops-mcp for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @RyanCardin15/azuredevops-mcp --client claude
Clone the repository:
git clone <repository-url> cd AzureDevOps
Install dependencies:
npm install
Configure environment variables (create a .env
file or set them directly):
For Azure DevOps Services (cloud):
AZURE_DEVOPS_ORG_URL=https://dev.azure.com/your-organization
AZURE_DEVOPS_PROJECT=your-default-project
AZURE_DEVOPS_IS_ON_PREMISES=false
AZURE_DEVOPS_AUTH_TYPE=pat # or 'entra'
AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN=your-personal-access-token
For Azure DevOps Server (on-premises):
AZURE_DEVOPS_ORG_URL=https://your-server/tfs
AZURE_DEVOPS_PROJECT=your-default-project
AZURE_DEVOPS_IS_ON_PREMISES=true
AZURE_DEVOPS_COLLECTION=your-collection
AZURE_DEVOPS_API_VERSION=6.0 # Adjust based on your server version
# Authentication (choose one):
# For PAT authentication:
AZURE_DEVOPS_AUTH_TYPE=pat
AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN=your-personal-access-token
# For NTLM authentication:
AZURE_DEVOPS_AUTH_TYPE=ntlm
AZURE_DEVOPS_USERNAME=your-username
AZURE_DEVOPS_PASSWORD=your-password
AZURE_DEVOPS_DOMAIN=your-domain
# For Basic authentication:
AZURE_DEVOPS_AUTH_TYPE=basic
AZURE_DEVOPS_USERNAME=your-username
AZURE_DEVOPS_PASSWORD=your-password
Build the project:
npm run build
If you encounter TypeScript errors but want to proceed anyway:
npm run build:ignore-errors
Start the server:
npm run start
For Azure DevOps Services (cloud), you'll need to create a Personal Access Token with appropriate permissions:
For Azure DevOps Server (on-premises), you have three authentication options:
Personal Access Token (PAT):
AZURE_DEVOPS_AUTH_TYPE=pat
NTLM Authentication:
AZURE_DEVOPS_AUTH_TYPE=ntlm
Basic Authentication:
AZURE_DEVOPS_AUTH_TYPE=basic
This integration supports both cloud-hosted Azure DevOps Services and on-premises Azure DevOps Server:
https://dev.azure.com/your-organization
.env.cloud.example
https://your-server/tfs
.env.on-premises.example
Feature | Azure DevOps Services | Azure DevOps Server |
---|---|---|
URL Format | https://dev.azure.com/org | https://server/tfs |
Collection | Not required | Required |
Auth Methods | PAT, Entra ID (DefaultAzureCredential) | PAT, NTLM, Basic |
API Version | Latest (automatic) | May need specification |
Connection | Always internet | Can be air-gapped |
Ensure you have az cli installed and it is authenticated. azd and AZ Powershell modules should also work, as long as you're authenticated.
Copy either .env.cloud.example
or .env.on-premises.example
to .env
and update the values as needed.
The server can be configured using the following environment variables:
Variable | Description | Required | Default |
---|---|---|---|
AZURE_DEVOPS_ORG_URL | URL of your Azure DevOps organization or server | Yes | - |
AZURE_DEVOPS_PROJECT | Default project to use | Yes | - |
AZURE_DEVOPS_IS_ON_PREMISES | Whether using Azure DevOps Server | No | false |
AZURE_DEVOPS_COLLECTION | Collection name for on-premises | No* | - |
AZURE_DEVOPS_API_VERSION | API version for on-premises | No | - |
AZURE_DEVOPS_AUTH_TYPE | Authentication type (pat/ntlm/basic/entra) | No | pat |
AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN | Personal access token (for 'pat' auth) | No** | - |
AZURE_DEVOPS_USERNAME | Username for NTLM/Basic auth | No** | - |
AZURE_DEVOPS_PASSWORD | Password for NTLM/Basic auth | No** | - |
AZURE_DEVOPS_DOMAIN | Domain for NTLM auth | No | - |
ALLOWED_TOOLS | Comma-separated list of tool methods to enable | No | All tools |
* Required if AZURE_DEVOPS_IS_ON_PREMISES=true
** Required based on chosen authentication type
The ALLOWED_TOOLS
environment variable allows you to restrict which tool methods are available. This is completely optional - if not specified, all tools will be enabled.
Format: Comma-separated list of method names with no spaces.
Example:
ALLOWED_TOOLS=listWorkItems,getWorkItemById,searchWorkItems,createWorkItem
This would only enable the specified work item methods while disabling all others.
Once the server is running, you can interact with it using the MCP protocol. The server exposes several tools for different Azure DevOps functionalities.
Note: By default, only a subset of tools are registered in the
index.ts
file to keep the initial implementation simple. See the Tool Registration section for information on how to register additional tools.
{ "tool": "listWorkItems", "params": { "query": "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.State] = 'Active' ORDER BY [System.CreatedDate] DESC" } }
{ "tool": "createWorkItem", "params": { "workItemType": "User Story", "title": "Implement new feature", "description": "As a user, I want to be able to export reports to PDF.", "assignedTo": "[email protected]" } }
{ "tool": "listRepositories", "params": { "projectId": "MyProject" } }
{ "tool": "createPullRequest", "params": { "repositoryId": "repo-guid", "sourceRefName": "refs/heads/feature-branch", "targetRefName": "refs/heads/main", "title": "Add new feature", "description": "This PR adds the export to PDF feature" } }
The project is structured as follows:
src/
Interfaces/
: Type definitions for parameters and responsesServices/
: Service classes for interacting with Azure DevOps APIsTools/
: Tool implementations that expose functionality to clientsindex.ts
: Main entry point that registers tools and starts the serverconfig.ts
: Configuration handlingThe service layer handles direct communication with the Azure DevOps API:
WorkItemService
: Work item operationsBoardsSprintsService
: Boards and sprints operationsProjectService
: Project management operationsGitService
: Git repository operationsTestingCapabilitiesService
: Testing capabilities operationsDevSecOpsService
: DevSecOps operationsArtifactManagementService
: Artifact management operationsAIAssistedDevelopmentService
: AI-assisted development operationsThe tools layer wraps the services and provides a consistent interface for the MCP protocol:
WorkItemTools
: Tools for work item operationsBoardsSprintsTools
: Tools for boards and sprints operationsProjectTools
: Tools for project management operationsGitTools
: Tools for Git operationsTestingCapabilitiesTools
: Tools for testing capabilities operationsDevSecOpsTools
: Tools for DevSecOps operationsArtifactManagementTools
: Tools for artifact management operationsAIAssistedDevelopmentTools
: Tools for AI-assisted development operationsThe MCP server requires tools to be explicitly registered in the index.ts
file. By default, only a subset of all possible tools are registered to keep the initial implementation manageable.
To register more tools:
src/index.ts
fileA comprehensive guide to tool registration is available in the TOOL_REGISTRATION.md
file in the repository.
Note: When registering tools, be careful to use the correct parameter types, especially for enum values. The type definitions in the
Interfaces
directory define the expected types for each parameter. Using the wrong type (e.g., usingz.string()
instead ofz.enum()
for enumerated values) will result in TypeScript errors during build.
Example of registering a new tool:
server.tool("searchCode", "Search for code in repositories", { searchText: z.string().describe("Text to search for"), repositoryId: z.string().optional().describe("ID of the repository") }, async (params, extra) => { const result = await gitTools.searchCode(params); return { content: result.content, rawData: result.rawData, isError: result.isError }; } );
npm run build:ignore-errors
to bypass TypeScript errorsContributions are welcome! Here's how you can contribute:
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)Please ensure your code passes linting and includes appropriate tests.