Skip to main content
Glama

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)

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