本指南聚焦于Azure DevOps MCP服务器,借助MCP(机器类协议)与Azure DevOps服务交互,可自动化并管理各类开发任务,提升开发效率。
要连接到Azure DevOps,身份验证配置必不可少,支持以下两种方法:
az devops login --organization https://dev.azure.com/your-org --username your-username --password your-pat
在项目配置文件中明确指定目标组织:
export const config = {
organization: 'your-org',
project: 'your-project',
// 其他配置...
};
本部分主要涉及身份验证和组织连接的配置,按上述快速开始部分的步骤操作即可完成项目的初步配置。
以下是WorkItemService类的基础使用示例,用于获取工作项:
// src/Services/WorkItemService.ts
export class WorkItemService {
private client: WorkItemHttpClient;
constructor() {
this.client = new WorkItemHttpClient();
}
public async getWorkItems(query: string): Promise<WorkItem[]> {
return await this.client.queryWorkItems(query);
}
}
项目主要分为以下几个部分:
src/
Interfaces/:负责定义参数和响应的类型。Services/:处理与Azure DevOps API的通信。Tools/:提供MCP协议接口的功能实现。index.ts:服务器启动的入口点。config.ts:进行配置管理。listRepositories、getBranches等。queueBuild、getBuildStatus等。项目配置存储在config.ts文件中:
export const config = {
organizationUrl: 'https://dev.azure.com/your-org',
projectId: 'your-project-id',
authentication: {
type: 'pat', // 可选:'oauth2'
token: 'your-personal-access-token'
}
};
const authProvider = new AzureAuthProvider(config.authentication);
async function getAccessToken(): Promise<string> {
return await authProvider.getAccessToken();
}
WorkItemHttpClient与Azure DevOps的工作项API进行交互,实现工作项的创建、更新和查询等操作。项目遵循MIT许可证,具体内容可查看LICENSE文件。
npm run build:ignore-errors跳过类型检查。欢迎大家为项目贡献力量,按以下步骤操作:
git checkout -b feature/amazing-feature
git add .
git commit -m "添加新功能"
git push origin feature/amazing-feature
通过以上指南,您能够成功配置和使用Azure DevOps MCP服务器,实现开发流程的自动化管理。