get_work_item
Retrieve detailed information about specific work items in Azure DevOps, including current state, assigned user, and custom fields, using IDs or multiple IDs.
Instructions
Retrieves detailed information about one or multiple work items.
Use this tool when you need to:
- View the complete details of a specific work item
- Examine the current state, assigned user, and other properties
- Get information about multiple work items at once
- Access the full description and custom fields of work items
Args:
id: The work item ID or a list of work item IDs
Returns:
Formatted string containing comprehensive information for the
requested work item(s), including all system and custom fields,
formatted as markdown with clear section headings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- Primary handler function for the 'get_work_item' MCP tool. It defines the tool interface, schema via type hints and docstring, and delegates to the implementation. Registered via @mcp.tool() decorator.@mcp.tool() def get_work_item(id: int | list[int]) -> str: """ Retrieves detailed information about one or multiple work items. Use this tool when you need to: - View the complete details of a specific work item - Examine the current state, assigned user, and other properties - Get information about multiple work items at once - Access the full description and custom fields of work items Args: id: The work item ID or a list of work item IDs Returns: Formatted string containing comprehensive information for the requested work item(s), including all system and custom fields, formatted as markdown with clear section headings """ try: wit_client = get_work_item_client() return _get_work_item_impl(id, wit_client) except AzureDevOpsClientError as e: return f"Error: {str(e)}"
- Core helper function implementing the retrieval of single or multiple work items from Azure DevOps, handling errors, and formatting output using format_work_item.def _get_work_item_impl(item_id: int | list[int], wit_client: WorkItemTrackingClient) -> str: """ Implementation of work item retrieval. Args: item_id: The work item ID or list of IDs wit_client: Work item tracking client Returns: Formatted string containing work item information """ try: if isinstance(item_id, int): # Handle single work item work_item = wit_client.get_work_item(item_id, expand="all") return format_work_item(work_item) else: # Handle list of work items work_items = wit_client.get_work_items(ids=item_id, error_policy="omit", expand="all") if not work_items: return "No work items found." formatted_results = [] for work_item in work_items: if work_item: # Skip None values (failed retrievals) formatted_results.append(format_work_item(work_item)) if not formatted_results: return "No valid work items found with the provided IDs." return "\n\n".join(formatted_results) except Exception as e: if isinstance(item_id, int): return f"Error retrieving work item {item_id}: {str(e)}" else: return f"Error retrieving work items {item_id}: {str(e)}"
- src/mcp_azure_devops/features/work_items/tools/read.py:56-88 (registration)The register_tools function in read.py that defines and registers the 'get_work_item' tool on the MCP server.def register_tools(mcp) -> None: """ Register work item read tools with the MCP server. Args: mcp: The FastMCP server instance """ @mcp.tool() def get_work_item(id: int | list[int]) -> str: """ Retrieves detailed information about one or multiple work items. Use this tool when you need to: - View the complete details of a specific work item - Examine the current state, assigned user, and other properties - Get information about multiple work items at once - Access the full description and custom fields of work items Args: id: The work item ID or a list of work item IDs Returns: Formatted string containing comprehensive information for the requested work item(s), including all system and custom fields, formatted as markdown with clear section headings """ try: wit_client = get_work_item_client() return _get_work_item_impl(id, wit_client) except AzureDevOpsClientError as e: return f"Error: {str(e)}"
- Intermediate registration point that calls read.register_tools(mcp), which registers 'get_work_item'.def register_tools(mcp) -> None: """ Register all work item tools with the MCP server. Args: mcp: The FastMCP server instance """ query.register_tools(mcp) read.register_tools(mcp) comments.register_tools(mcp) create.register_tools(mcp) types.register_tools(mcp) templates.register_tools(mcp) process.register_tools(mcp)
- src/mcp_azure_devops/features/work_items/__init__.py:5-13 (registration)Top-level registration for work items feature that calls tools.register_tools(mcp).def register(mcp): """ Register all work items components with the MCP server. Args: mcp: The FastMCP server instance """ tools.register_tools(mcp)