Skip to content

Commit

Permalink
feat: Complete Azure DevOps MCP Server implementation
Browse files Browse the repository at this point in the history
- Add comprehensive tests
- Add integration tests
- Add examples
- Add documentation
- Add GitHub Actions workflow
- Add CHANGELOG
- Configure package properly
- Add JSDoc comments
  • Loading branch information
ZubeidHendricks committed Dec 27, 2024
1 parent 0c03d30 commit e537c75
Show file tree
Hide file tree
Showing 13 changed files with 821 additions and 48 deletions.
19 changes: 19 additions & 0 deletions src/azure-devops/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
rules: {
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
}
}
46 changes: 46 additions & 0 deletions src/azure-devops/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
paths:
- 'src/azure-devops/**'
pull_request:
paths:
- 'src/azure-devops/**'

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
working-directory: ./src/azure-devops
run: npm ci

- name: Lint
working-directory: ./src/azure-devops
run: npm run lint

- name: Build
working-directory: ./src/azure-devops
run: npm run build

- name: Test
working-directory: ./src/azure-devops
run: npm test

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
directory: ./src/azure-devops/coverage
25 changes: 25 additions & 0 deletions src/azure-devops/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

All notable changes to the Azure DevOps MCP Server will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2024-12-27

### Added
- Initial release
- Work Item Management API
- Create work items
- Get work item by ID
- Update work items
- Project Management API
- List projects
- Get project details
- Create/delete projects
- Repository Management API
- List repositories
- Create/delete repositories
- Get repository branches

[0.1.0]: https://github.com/modelcontextprotocol/servers/releases/tag/azure-devops-v0.1.0
181 changes: 181 additions & 0 deletions src/azure-devops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Azure DevOps MCP Server

A Model Context Protocol (MCP) server implementation for Azure DevOps, enabling AI language models to interact with Azure DevOps services through a standardized interface.

## Features

### Work Item Management
- Create, read, and update work items
- Track bugs, tasks, and user stories
- Manage work item states

### Project Management
- List and view projects
- Create new projects
- Delete existing projects

### Repository Management
- List repositories in projects
- Create and delete repositories
- Manage repository branches

## Installation

```bash
npm install @modelcontextprotocol/server-azure-devops
```

## Configuration

Set the following environment variables:
- `AZURE_DEVOPS_ORG_URL`: Your Azure DevOps organization URL (e.g., https://dev.azure.com/yourorg)
- `AZURE_PERSONAL_ACCESS_TOKEN`: Your Azure DevOps Personal Access Token

## Using with MCP Client

Add this to your MCP client configuration (e.g. Claude Desktop):

```json
{
"mcpServers": {
"azure": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-azure-devops"],
"env": {
"AZURE_DEVOPS_ORG_URL": "https://dev.azure.com/yourorg",
"AZURE_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
```

## API Documentation

### Work Items

#### Get Work Item
```typescript
getWorkItem({ id: number }): Promise<WorkItem>
```
Retrieves a work item by its ID.

#### Create Work Item
```typescript
createWorkItem({
project: string,
type: string,
title: string,
description?: string
}): Promise<WorkItem>
```
Creates a new work item in the specified project.

#### Update Work Item
```typescript
updateWorkItem({
id: number,
title?: string,
state?: string,
description?: string
}): Promise<WorkItem>
```
Updates an existing work item.

### Projects

#### List Projects
```typescript
listProjects(): Promise<Project[]>
```
Lists all accessible projects.

#### Get Project
```typescript
getProject({ name: string }): Promise<Project>
```
Gets details of a specific project.

### Repositories

#### List Repositories
```typescript
listRepositories({ project: string }): Promise<Repository[]>
```
Lists all repositories in a project.

#### Create Repository
```typescript
createRepository({
project: string,
name: string
}): Promise<Repository>
```
Creates a new repository in the specified project.

## Examples

### Managing Work Items
```typescript
// Get a work item
const workItem = await azure.getWorkItem({ id: 123 });

// Create a new task
const newTask = await azure.createWorkItem({
project: 'MyProject',
type: 'Task',
title: 'Implement feature X',
description: 'Implementation details...'
});

// Update work item state
const updatedItem = await azure.updateWorkItem({
id: 123,
state: 'Active'
});
```

### Managing Projects
```typescript
// List all projects
const projects = await azure.listProjects();

// Get specific project
const project = await azure.getProject({ name: 'MyProject' });
```

### Managing Repositories
```typescript
// List repositories
const repos = await azure.listRepositories({ project: 'MyProject' });

// Create new repository
const newRepo = await azure.createRepository({
project: 'MyProject',
name: 'new-service'
});
```

## Development

```bash
# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

# Lint
npm run lint
```

## Contributing

See [CONTRIBUTING.md](../../CONTRIBUTING.md) for information about contributing to this repository.

## License

This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
35 changes: 35 additions & 0 deletions src/azure-devops/examples/basic-usage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { AzureDevOpsMCPServer } from '../index';

async function main() {
// Initialize the server
const server = new AzureDevOpsMCPServer();

try {
// List all projects
const projects = await server.projects.listProjects();
console.log('Projects:', projects);

// Create a work item
const workItem = await server.workItems.createWorkItem({
project: 'Your Project Name',
type: 'Task',
title: 'Example Task',
description: 'This is an example task created through the MCP server'
});
console.log('Created Work Item:', workItem);

// List repositories
const repos = await server.repositories.listRepositories({
project: 'Your Project Name'
});
console.log('Repositories:', repos);

} catch (error) {
console.error('Error:', error.message);
}
}

// Run the example if this script is executed directly
if (require.main === module) {
main().catch(console.error);
}
Loading

0 comments on commit e537c75

Please sign in to comment.