This document provides instructions on how to register new tools in the Azure DevOps MCP integration.
To register a new tool, you need to add it to the index.ts file in the main source directory.
Here's the basic template for registering a tool:
server.tool("toolName",
"Tool description",
{
// Parameters schema using zod
paramName: z.string().describe("Parameter description"),
optionalParam: z.number().optional().describe("Optional parameter description")
},
async (params, extra) => {
// Call the appropriate tool method
const result = await toolsInstance.toolMethod(params);
return {
content: result.content,
rawData: result.rawData,
isError: result.isError
};
}
);server.tool("updateWorkItemState",
"Update the state of a work item",
{
id: z.number().describe("ID of the work item"),
state: z.string().describe("New state for the work item"),
comment: z.string().optional().describe("Comment explaining the state change")
},
async (params, extra) => {
const result = await workItemTools.updateWorkItemState(params);
return {
content: result.content,
rawData: result.rawData,
isError: result.isError
};
}
);The MCP server initializes four main tool instances, each handling different aspects of Azure DevOps:
workItemTools- For work item management operationsboardsSprintsTools- For board and sprint management operationsprojectTools- For project management operationsgitTools- For Git repository operationstestingCapabilitiesTools- For testing capabilities operationsdevSecOpsTools- For DevSecOps operationsartifactManagementTools- For artifact management operationsaiAssistedDevelopmentTools- For AI-assisted development operations
Use the Zod library to define parameter types and validations:
z.string()- String parameterz.number()- Number parameterz.boolean()- Boolean parameterz.array(z.string())- Array of stringsz.record(z.any())- Object with any valuesz.enum(['option1', 'option2'])- Enumerated values- Add
.optional()for optional parameters - Add
.describe("Description")to describe the parameter
When registering tools, always match the parameter types with the interface definitions in the Interfaces directory. For enum parameters, make sure to use z.enum() with the exact values expected by the interface. This ensures type safety and prevents TypeScript errors during build.
Example:
server.tool("createProject",
"Create a new project",
{
name: z.string().describe("Name of the project"),
description: z.string().optional().describe("Description of the project"),
// Use z.enum() with the exact values expected by CreateProjectParams
visibility: z.enum(['private', 'public']).optional().describe("Visibility of the project"),
capabilities: z.record(z.any()).optional().describe("Project capabilities")
},
async (params, extra) => {
const result = await projectTools.createProject(params);
return {
content: result.content,
rawData: result.rawData,
isError: result.isError
};
}
);Here are some common enum values used in the Azure DevOps APIs:
- Project state filter:
['all', 'createPending', 'deleted', 'deleting', 'new', 'unchanged', 'wellFormed'] - Project visibility:
['private', 'public'] - Pull request merge strategy:
['noFastForward', 'rebase', 'rebaseMerge', 'squash'] - Pull request status:
['abandoned', 'active', 'completed', 'notSet']
Here's a list of all the tools mentioned in the README.md file:
listWorkItemsgetWorkItemByIdsearchWorkItemsgetRecentlyUpdatedWorkItemsgetMyWorkItemscreateWorkItemupdateWorkItemaddWorkItemCommentupdateWorkItemStateassignWorkItemcreateLinkbulkCreateWorkItems
getBoardsgetBoardColumnsgetBoardItemsmoveCardOnBoardgetSprintsgetCurrentSprintgetSprintWorkItemsgetSprintCapacitygetTeamMembers
listProjectsgetProjectDetailscreateProjectgetAreasgetIterationscreateAreacreateIterationgetProcessesgetWorkItemTypesgetWorkItemTypeFields
listRepositoriesgetRepositorycreateRepositorylistBranchessearchCodebrowseRepositorygetFileContentgetCommitHistorylistPullRequestscreatePullRequestgetPullRequestgetPullRequestCommentsapprovePullRequestmergePullRequest
If you need to add more tools, make sure to implement them in the appropriate tools class first, and then register them in the index.ts file following the pattern shown above.