Skip to main content
Glama
Vortiago
by Vortiago

get_work_item

Retrieve detailed information about Azure DevOps work items, including current state, assigned users, and custom fields, by specifying one 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
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • The MCP tool 'get_work_item' handler, decorated with @mcp.tool() for registration and execution. It obtains the client and calls the implementation helper.
    @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 logic to retrieve single or multiple work items via Azure DevOps API and handle formatting or errors.
    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)}"
  • Helper function to format retrieved work item data into readable markdown output, handling fields, relations, and special field types.
    def format_work_item(work_item: WorkItem) -> str:
        """
        Format work item information for display.
        
        Args:
            work_item: Work item object to format
            
        Returns:
            String with formatted work item details
        """
        fields = work_item.fields or {}
        details = [f"# Work Item {work_item.id}"]
        
        # List all fields alphabetically for consistent output
        for field_name in sorted(fields.keys()):
            field_value = fields[field_name]
            formatted_value = _format_field_value(field_value)
            details.append(f"- **{field_name}**: {formatted_value}")
        
        # Add related items if available
        if hasattr(work_item, 'relations') and work_item.relations:
            details.append("\n## Related Items")
            for link in work_item.relations:
                details.append(f"- {link.rel} URL: {link.url}")
                if hasattr(link, 'attributes') and link.attributes:
                    details.append(f"  :: Attributes: {link.attributes}")
        
        return "\n".join(details)
  • Helper function to create and return the Azure DevOps WorkItemTrackingClient used by the tool.
    def get_work_item_client() -> WorkItemTrackingClient:
        """
        Get the work item tracking client.
        
        Returns:
            WorkItemTrackingClient instance
            
        Raises:
            AzureDevOpsClientError: If connection or client creation fails
        """
        # Get connection to Azure DevOps
        connection = get_connection()
        
        if not connection:
            raise AzureDevOpsClientError(
                "Azure DevOps PAT or organization URL not found in "
                "environment variables."
            )
        
        # Get the work item tracking client
        wit_client = connection.clients.get_work_item_tracking_client()
        
        if wit_client is None:
            raise AzureDevOpsClientError(
                "Failed to get work item tracking client.")
        
        return wit_client
  • Feature-level registration that triggers tool registrations including get_work_item by calling 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)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the return format ('formatted string... as markdown') and scope ('comprehensive information... all system and custom fields'), which is helpful. However, it doesn't mention potential limitations like pagination, rate limits, authentication requirements, or error conditions for invalid IDs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and efficiently organized: purpose statement, usage guidelines bullet points, parameter explanation, and return format description. Every sentence adds value with zero redundant information, and the most important information (purpose and usage) is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read operation with no output schema, the description provides excellent context: clear purpose, usage guidelines, parameter semantics, and return format details. The only minor gap is the lack of behavioral constraints (rate limits, auth needs) which would make it fully complete for a tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage (no parameter descriptions in schema), so the description must fully compensate. It provides a clear 'Args' section explaining that 'id' can be either a single integer or a list of integers, adding crucial semantic meaning about single vs. batch retrieval that the schema alone doesn't convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('retrieves detailed information') and resources ('work items'), distinguishing it from siblings like query_work_items (which likely searches/filters) or get_work_item_comments (which focuses on comments). The opening sentence provides a precise, standalone purpose statement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides four bullet points detailing when to use this tool ('Use this tool when you need to...'), covering specific scenarios like viewing complete details, examining state/properties, handling multiple items, and accessing descriptions/custom fields. This gives clear contextual guidance without needing to reference alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vortiago/mcp-azure-devops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server