Skip to main content
Glama
Vortiago
by Vortiago

query_work_items

Search Azure DevOps work items using WIQL queries to find tasks, bugs, or reports based on specific criteria like status, assignee, or project attributes.

Instructions

    Searches for work items using Work Item Query Language (WIQL).
    
    Use this tool when you need to:
    - Find work items matching specific criteria
    - Search across projects for related tasks or bugs
    - Create dynamic reports based on work item attributes
    - Identify work items assigned to specific team members
    
    IMPORTANT: WIQL syntax is similar to SQL and allows you to query
    work items based on their fields. The query must follow Azure DevOps
    WIQL syntax rules, with proper SELECT, FROM, and WHERE clauses.
    
    Args:
        query: The WIQL query string (e.g., "SELECT * FROM workitems 
            WHERE [System.State] = 'Active'")
        top: Maximum number of results to return (default: 30)
            
    Returns:
        Formatted string containing detailed information for each matching
        work item, with all fields and values formatted as markdown
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
topNo

Implementation Reference

  • The main handler function for the 'query_work_items' tool, decorated with @mcp.tool(). It handles input parameters, retrieves the work item client, calls the core implementation, and manages errors.
    def query_work_items(query: str, top: Optional[int] = None) -> str:
        """
        Searches for work items using Work Item Query Language (WIQL).
        
        Use this tool when you need to:
        - Find work items matching specific criteria
        - Search across projects for related tasks or bugs
        - Create dynamic reports based on work item attributes
        - Identify work items assigned to specific team members
        
        IMPORTANT: WIQL syntax is similar to SQL and allows you to query
        work items based on their fields. The query must follow Azure DevOps
        WIQL syntax rules, with proper SELECT, FROM, and WHERE clauses.
        
        Args:
            query: The WIQL query string (e.g., "SELECT * FROM workitems 
                WHERE [System.State] = 'Active'")
            top: Maximum number of results to return (default: 30)
                
        Returns:
            Formatted string containing detailed information for each matching
            work item, with all fields and values formatted as markdown
        """
        try:
            wit_client = get_work_item_client()
            return _query_work_items_impl(query, top or 30, wit_client)
        except AzureDevOpsClientError as e:
            return f"Error: {str(e)}"
  • Core helper function implementing the WIQL query execution, work item retrieval, and formatting logic.
    def _query_work_items_impl(query: str, top: int, 
                               wit_client: WorkItemTrackingClient) -> str:
        """
        Implementation of query_work_items that operates with a client.
        
        Args:
            query: The WIQL query string
            top: Maximum number of results to return
            wit_client: Work item tracking client
                
        Returns:
            Formatted string containing work item details
        """
        
        # Create the WIQL query
        wiql = Wiql(query=query)
        
        # Execute the query
        wiql_results = wit_client.query_by_wiql(wiql, top=top).work_items
        
        if not wiql_results:
            return "No work items found matching the query."
        
        # Get the work items from the results
        work_item_ids = [int(res.id) for res in wiql_results]
        work_items = wit_client.get_work_items(ids=work_item_ids,
                                               expand="all",
                                               error_policy="omit")
        
        # Use the standard formatting for all work items
        formatted_results = []
        for work_item in work_items:
            if work_item:
                formatted_results.append(format_work_item(work_item))
        
        return "\n\n".join(formatted_results)
  • Specific registration call for the query tools module within the work items tools package init.
    query.register_tools(mcp)
  • Package-level registration that triggers registration of all work items tools, including query_work_items.
    tools.register_tools(mcp)
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool returns 'detailed information for each matching work item' as a 'formatted string... as markdown,' which adds behavioral context. However, it lacks details on permissions, rate limits, error handling, or pagination beyond the 'top' parameter, leaving gaps for a search tool.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, usage guidelines, important notes, args, returns) and uses bullet points for readability. It is appropriately sized, though the 'IMPORTANT' section could be more concise. Every sentence adds value, such as explaining WIQL syntax and return format.

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?

Given the tool's complexity (search with WIQL syntax), no annotations, and no output schema, the description does a good job by covering purpose, usage, parameters, and return format. However, it misses some contextual details like authentication requirements, error cases, or how results are ordered, which could enhance completeness for a search tool.

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?

Schema description coverage is 0%, so the description must compensate. It fully explains both parameters: 'query' as 'The WIQL query string' with an example, and 'top' as 'Maximum number of results to return (default: 30).' This adds essential meaning beyond the bare schema, covering syntax, purpose, and defaults effectively.

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: 'Searches for work items using Work Item Query Language (WIQL).' It specifies the verb ('searches'), resource ('work items'), and method ('using WIQL'), distinguishing it from siblings like 'get_work_item' (single item retrieval) or 'get_work_item_comments' (comments-focused).

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 provides explicit usage scenarios in a bulleted list: 'Find work items matching specific criteria,' 'Search across projects for related tasks or bugs,' etc. It also includes an 'IMPORTANT' section detailing when to use WIQL syntax, though it doesn't explicitly contrast with alternatives like 'get_work_item' (for single items) or 'update_work_item' (for modifications).

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