wit_get_work_item
Retrieve a specific work item by ID from Azure DevOps with optional field selection, historical state, or expanded relations using PAT authentication.
Instructions
Get a single work item by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asOf | No | Optional date string to retrieve the work item as of a specific time. If not provided, the current state will be returned. | |
| expand | No | Expand options include 'all', 'fields', 'links', 'none', and 'relations'. Relations can be used to get child workitems. Defaults to 'none'. | |
| fields | No | Optional list of fields to include in the response. If not provided, all fields will be returned. | |
| id | Yes | The ID of the work item to retrieve. | |
| project | Yes | The name or ID of the Azure DevOps project. |
Implementation Reference
- src/tools/workitems.ts:193-200 (handler)Executes the tool logic by fetching the specified work item using the Azure DevOps WorkItemTrackingApi and returning it as JSON.async ({ id, project, fields, asOf, expand }) => { const connection = await connectionProvider(); const workItemApi = await connection.getWorkItemTrackingApi(); const workItem = await workItemApi.getWorkItem(id, fields, asOf, expand as unknown as WorkItemExpand, project); return { content: [{ type: "text", text: JSON.stringify(workItem, null, 2) }], }; }
- src/tools/workitems.ts:183-192 (schema)Zod schema defining input parameters for the tool: id (required), project, optional fields, asOf date, and expand options.id: z.number().describe("The ID of the work item to retrieve."), project: z.string().describe("The name or ID of the Azure DevOps project."), fields: z.array(z.string()).optional().describe("Optional list of fields to include in the response. If not provided, all fields will be returned."), asOf: z.coerce.date().optional().describe("Optional date string to retrieve the work item as of a specific time. If not provided, the current state will be returned."), expand: z .enum(["all", "fields", "links", "none", "relations"]) .describe("Optional expand parameter to include additional details in the response.") .optional() .describe("Expand options include 'all', 'fields', 'links', 'none', and 'relations'. Relations can be used to get child workitems. Defaults to 'none'."), },
- src/tools/workitems.ts:179-201 (registration)Direct registration of the 'wit_get_work_item' tool on the McpServer using server.tool() with name from WORKITEM_TOOLS.get_work_item.server.tool( WORKITEM_TOOLS.get_work_item, "Get a single work item by ID.", { id: z.number().describe("The ID of the work item to retrieve."), project: z.string().describe("The name or ID of the Azure DevOps project."), fields: z.array(z.string()).optional().describe("Optional list of fields to include in the response. If not provided, all fields will be returned."), asOf: z.coerce.date().optional().describe("Optional date string to retrieve the work item as of a specific time. If not provided, the current state will be returned."), expand: z .enum(["all", "fields", "links", "none", "relations"]) .describe("Optional expand parameter to include additional details in the response.") .optional() .describe("Expand options include 'all', 'fields', 'links', 'none', and 'relations'. Relations can be used to get child workitems. Defaults to 'none'."), }, async ({ id, project, fields, asOf, expand }) => { const connection = await connectionProvider(); const workItemApi = await connection.getWorkItemTrackingApi(); const workItem = await workItemApi.getWorkItem(id, fields, asOf, expand as unknown as WorkItemExpand, project); return { content: [{ type: "text", text: JSON.stringify(workItem, null, 2) }], }; } );
- src/tools/workitems.ts:12-32 (helper)Constant object mapping internal tool keys (e.g., get_work_item) to external MCP tool names (e.g., 'wit_get_work_item').const WORKITEM_TOOLS = { my_work_items: "wit_my_work_items", list_backlogs: "wit_list_backlogs", list_backlog_work_items: "wit_list_backlog_work_items", get_work_item: "wit_get_work_item", get_work_items_batch_by_ids: "wit_get_work_items_batch_by_ids", update_work_item: "wit_update_work_item", create_work_item: "wit_create_work_item", list_work_item_comments: "wit_list_work_item_comments", get_work_items_for_iteration: "wit_get_work_items_for_iteration", add_work_item_comment: "wit_add_work_item_comment", add_child_work_items: "wit_add_child_work_items", link_work_item_to_pull_request: "wit_link_work_item_to_pull_request", get_work_item_type: "wit_get_work_item_type", get_query: "wit_get_query", get_query_results_by_id: "wit_get_query_results_by_id", update_work_items_batch: "wit_update_work_items_batch", work_items_link: "wit_work_items_link", work_item_unlink: "wit_work_item_unlink", add_artifact_link: "wit_add_artifact_link", };
- src/tools.ts:24-24 (registration)High-level call to configureWorkItemTools within configureAllTools, which ultimately registers the wit_get_work_item tool.configureWorkItemTools(server, tokenProvider, connectionProvider, userAgentProvider);