get_work_item
Retrieve detailed information about a specific work item in Azure DevOps by providing the project name and work item ID.
Instructions
Get details of a specific work item
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the work item | |
| project | Yes | Name of the Azure DevOps project |
Input Schema (JSON Schema)
{
"properties": {
"id": {
"description": "ID of the work item",
"type": "number"
},
"project": {
"description": "Name of the Azure DevOps project",
"type": "string"
}
},
"required": [
"project",
"id"
],
"type": "object"
}
Implementation Reference
- src/tools/workItems.ts:82-114 (handler)The handler function that implements the core logic of the 'get_work_item' tool: parses input with Zod, fetches WIT client, retrieves work item by ID from Azure DevOps, and returns formatted JSON response.export async function getWorkItem(rawParams: any) { // Parse arguments with defaults from environment variables const params = getWorkItemSchema.parse({ project: rawParams.project || DEFAULT_PROJECT, id: rawParams.id, }); console.error("[API] Getting work item details:", params); try { // Get the Work Item Tracking API client const witClient = await getWorkItemClient(); // Get work item details const workItem = await witClient.getWorkItem( params.id, undefined, undefined ); return { content: [ { type: "text", text: JSON.stringify(workItem, null, 2), }, ], }; } catch (error) { logError("Error getting work item", error); throw error; } }
- src/schemas/workItems.ts:18-23 (schema)Zod schema for input validation and TypeScript type definition used in the getWorkItem handler.export const getWorkItemSchema = z.object({ project: z.string(), id: z.number(), }); export type GetWorkItemParams = z.infer<typeof getWorkItemSchema>;
- src/tools/workItems.ts:247-264 (registration)Tool registration metadata including name, description, and input schema definition within the workItemTools array exported for use in MCP server.{ name: "get_work_item", description: "Get details of a specific work item", inputSchema: { type: "object", properties: { project: { type: "string", description: "Name of the Azure DevOps project", }, id: { type: "number", description: "ID of the work item", }, }, required: ["project", "id"], }, },
- src/index.ts:71-72 (registration)Dispatch logic in the MCP server's CallToolRequest handler that routes 'get_work_item' calls to the getWorkItem implementation.case "get_work_item": return await getWorkItem(request.params.arguments || {});