Skip to content

Commit ab193cd

Browse files
authored
Merge pull request #1 from qike-ms/feature/wiql-query-support
Add WIQL query support and improve documentation
2 parents 3d969ea + 4016496 commit ab193cd

File tree

4 files changed

+161
-2
lines changed

4 files changed

+161
-2
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,9 @@ dist
135135
.yarn/unplugged
136136
.yarn/build-state.yml
137137
.yarn/install-state.gz
138-
.pnp.*
138+
.pnp.*
139+
140+
# Claude code
141+
.mcp.json
142+
.claude/
143+

CLAUDE.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Interact with these Azure DevOps services:
7171
- **wit_get_work_item_type**: Get a specific work item type.
7272
- **wit_get_query**: Get a query by its ID or path.
7373
- **wit_get_query_results_by_id**: Retrieve the results of a work item query given the query ID.
74+
- **wit_query_by_wiql**: Execute a WIQL query to retrieve work items.
7475
- **wit_update_work_items_batch**: Update work items in batch.
7576
- **wit_work_items_link**: Link work items together in batch.
7677
- **wit_work_item_unlink**: Unlink one or many links from a work item.
@@ -211,6 +212,28 @@ Open GitHub Copilot Chat and try a prompt like `List ADO projects`.
211212
> 💥 We strongly recommend creating a `.github\copilot-instructions.md` in your project. This will enhance your experience using the Azure DevOps MCP Server with GitHub Copilot Chat.
212213
> To start, just include "`This project uses Azure DevOps. Always check to see if the Azure DevOps MCP server has a tool relevant to the user's request`" in your copilot instructions file.
213214
215+
#### 🤖 Claude Code
216+
217+
To add the Azure DevOps MCP Server to Claude Code, use the following command:
218+
219+
```bash
220+
claude mcp add mcp-ado 'npx -y @azure-devops/mcp ado_org_name' --scope user
221+
```
222+
223+
For example:
224+
225+
```bash
226+
claude mcp add mcp-ado 'npx -y @azure-devops/mcp msazure' --scope user
227+
```
228+
229+
Replace `msazure` with your Azure DevOps organization name. You can also use `--scope project` to limit the server to a specific project.
230+
231+
For development with a local installation:
232+
233+
```bash
234+
claude mcp add mcp-ado 'npx -y ~/git/azure-devops-mcp msazure' --scope user
235+
```
236+
214237
See the [getting started documentation](./docs/GETTINGSTARTED.md) to use our MCP Server with other tools such as Visual Studio 2022, Claude Code, and Cursor.
215238

216239
## 📝 Troubleshooting

src/tools/workitems.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { AccessToken } from "@azure/identity";
55
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
66
import { WebApi } from "azure-devops-node-api";
7-
import { WorkItemExpand, WorkItemRelation } from "azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";
7+
import { WorkItemExpand, WorkItemRelation, Wiql } from "azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";
88
import { QueryExpand } from "azure-devops-node-api/interfaces/WorkItemTrackingInterfaces.js";
99
import { z } from "zod";
1010
import { batchApiVersion, markdownCommentsApiVersion, getEnumKeys, safeEnumConvert } from "../utils.js";
@@ -25,6 +25,7 @@ const WORKITEM_TOOLS = {
2525
get_work_item_type: "wit_get_work_item_type",
2626
get_query: "wit_get_query",
2727
get_query_results_by_id: "wit_get_query_results_by_id",
28+
query_by_wiql: "wit_query_by_wiql",
2829
update_work_items_batch: "wit_update_work_items_batch",
2930
work_items_link: "wit_work_items_link",
3031
work_item_unlink: "wit_work_item_unlink",
@@ -633,6 +634,26 @@ function configureWorkItemTools(server: McpServer, tokenProvider: () => Promise<
633634
}
634635
);
635636

637+
server.tool(
638+
WORKITEM_TOOLS.query_by_wiql,
639+
"Execute a WIQL query to retrieve work items.",
640+
{
641+
wiql: z.string().describe("The WIQL query string to execute."),
642+
top: z.number().optional().describe("The maximum number of results to return."),
643+
},
644+
async ({ wiql, top }) => {
645+
const connection = await connectionProvider();
646+
const workItemApi = await connection.getWorkItemTrackingApi();
647+
648+
const wiqlObject: Wiql = { query: wiql };
649+
const queryResult = await workItemApi.queryByWiql(wiqlObject, undefined, undefined, top);
650+
651+
return {
652+
content: [{ type: "text", text: JSON.stringify(queryResult, null, 2) }],
653+
};
654+
}
655+
);
656+
636657
server.tool(
637658
WORKITEM_TOOLS.update_work_items_batch,
638659
"Update work items in batch",

0 commit comments

Comments
 (0)