search_work_items
Search for work items in Azure DevOps projects using WIQL queries to filter and retrieve specific tasks, bugs, or issues.
Instructions
Searches for work items using a WIQL (Work Item Query Language) query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | The name or ID of the project. | |
| wiql_query | Yes | The Work Item Query Language (WIQL) query. |
Implementation Reference
- Core implementation of the search_work_items tool: executes WIQL query on Azure DevOps work item tracking client, filters by project if needed, retrieves matching work items, and formats results with id, title, state, and url.def search_work_items(self, project, wiql_query): # Add project filter to the WIQL query if not already present if "[System.TeamProject]" not in wiql_query and "WHERE" in wiql_query.upper(): # Insert project filter into existing WHERE clause wiql_query = wiql_query.replace(" WHERE ", f" WHERE [System.TeamProject] = '{project}' AND ") elif "[System.TeamProject]" not in wiql_query: # Add WHERE clause with project filter wiql_query += f" WHERE [System.TeamProject] = '{project}'" wiql = Wiql(query=wiql_query) # Call query_by_wiql without the project parameter query_result = self.work_item_tracking_client.query_by_wiql(wiql) if query_result.work_items: work_item_ids = [item.id for item in query_result.work_items] work_items = self.work_item_tracking_client.get_work_items(ids=work_item_ids) return [ { "id": wi.id, "title": wi.fields.get("System.Title"), "state": wi.fields.get("System.State"), "url": wi.url, } for wi in work_items ] else: return []
- mcp_azure_devops/server.py:176-194 (registration)Registers the search_work_items tool with the MCP server by defining it in the tools list returned by list_tools(), including name, description, and input schema.types.Tool( name="search_work_items", description="Searches for work items using a WIQL (Work Item Query Language) query.", inputSchema={ "type": "object", "properties": { "project": { "type": "string", "description": "The name or ID of the project." }, "wiql_query": { "type": "string", "description": "The Work Item Query Language (WIQL) query." }, }, "required": ["project", "wiql_query"], "additionalProperties": False } ),
- mcp_azure_devops/server.py:927-928 (handler)Dispatches the search_work_items tool call to the AzureDevOpsClient instance by passing arguments to client.search_work_items() within the _execute_tool method.elif name == "search_work_items": return self.client.search_work_items(**arguments)
- mcp_azure_devops/server.py:181-192 (schema)Input schema definition for search_work_items tool, specifying required project and wiql_query parameters with types and descriptions."properties": { "project": { "type": "string", "description": "The name or ID of the project." }, "wiql_query": { "type": "string", "description": "The Work Item Query Language (WIQL) query." }, }, "required": ["project", "wiql_query"], "additionalProperties": False