Skip to main content
Glama

get_work_item_comments

Retrieve and format all comments for a specific work item in Azure DevOps, including author names, timestamps, and content, to review discussion history, feedback, and context evolution.

Instructions

Retrieves all comments associated with a specific work item. Use this tool when you need to: - Review discussion history about a work item - See feedback or notes left by team members - Check if specific questions have been answered - Understand the context and evolution of a work item Args: id: The work item ID project: Optional project name. If not provided, will be determined from the work item. Returns: Formatted string containing all comments on the work item, including author names, timestamps, and content, organized chronologically and formatted as markdown

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
projectNo

Implementation Reference

  • The handler function for the 'get_work_item_comments' tool. It is decorated with @mcp.tool() which registers it with the MCP server. The function retrieves the work item client and delegates to the implementation helper.
    @mcp.tool() def get_work_item_comments( id: int, project: Optional[str] = None ) -> str: """ Retrieves all comments associated with a specific work item. Use this tool when you need to: - Review discussion history about a work item - See feedback or notes left by team members - Check if specific questions have been answered - Understand the context and evolution of a work item Args: id: The work item ID project: Optional project name. If not provided, will be determined from the work item. Returns: Formatted string containing all comments on the work item, including author names, timestamps, and content, organized chronologically and formatted as markdown """ try: wit_client = get_work_item_client() return _get_work_item_comments_impl(id, wit_client, project) except AzureDevOpsClientError as e: return f"Error: {str(e)}"
  • Core implementation logic that retrieves comments from Azure DevOps using the WorkItemTrackingClient, determines project if needed, formats comments with author and date, and returns markdown-formatted string.
    def _get_work_item_comments_impl( item_id: int, wit_client: WorkItemTrackingClient, project: Optional[str] = None ) -> str: """ Implementation of work item comments retrieval. Args: item_id: The work item ID wit_client: Work item tracking client project: Optional project name Returns: Formatted string containing work item comments """ # If project is not provided, try to get it from the work item if not project: project = _get_project_for_work_item(item_id, wit_client) if not project: return f"Error retrieving work item {item_id} to determine project" # Get comments using the project if available comments = wit_client.get_comments(project=project, work_item_id=item_id) # Format the comments formatted_comments = [ _format_comment(comment) for comment in comments.comments ] if not formatted_comments: return "No comments found for this work item." return "\n\n".join(formatted_comments)
  • Utility function to format individual comment objects into readable markdown strings including author, date, and text.
    def _format_comment(comment) -> str: """ Format a work item comment for display. Args: comment: Comment object to format Returns: Formatted string representation of the comment """ # Format the date if available created_date = "" if hasattr(comment, 'created_date') and comment.created_date: created_date = f" on {comment.created_date}" # Format the author if available author = "Unknown" if hasattr(comment, 'created_by') and comment.created_by: if (hasattr(comment.created_by, 'display_name') and comment.created_by.display_name): author = comment.created_by.display_name # Format the comment text text = "No text" if hasattr(comment, 'text') and comment.text: text = comment.text return f"## Comment by {author}{created_date}:\n{text}"
  • Aggregates and calls register_tools from individual tool modules, including comments, to register all work item tools.
    comments.register_tools(mcp)
  • Module-level registration function that defines and registers the get_work_item_comments tool (and add_work_item_comment) using @mcp.tool() decorators.
    def register_tools(mcp) -> None: """ Register work item comment tools with the MCP server. Args: mcp: The FastMCP server instance """ @mcp.tool() def get_work_item_comments( id: int, project: Optional[str] = None ) -> str: """ Retrieves all comments associated with a specific work item. Use this tool when you need to: - Review discussion history about a work item - See feedback or notes left by team members - Check if specific questions have been answered - Understand the context and evolution of a work item Args: id: The work item ID project: Optional project name. If not provided, will be determined from the work item. Returns: Formatted string containing all comments on the work item, including author names, timestamps, and content, organized chronologically and formatted as markdown """ try: wit_client = get_work_item_client() return _get_work_item_comments_impl(id, wit_client, project) except AzureDevOpsClientError as e: return f"Error: {str(e)}" @mcp.tool() def add_work_item_comment( id: int, text: str, project: Optional[str] = None ) -> str: """ Adds a new comment to a work item. Use this tool when you need to: - Provide feedback or clarification on a work item - Document decisions made about the work - Add context without changing the work item's fields - Communicate with team members about specific tasks IMPORTANT: Comments in Azure DevOps become part of the permanent work item history and cannot be edited or deleted after they are added. The comment will be attributed to the user associated with the Personal Access Token used for authentication. Args: id: The work item ID text: The text of the comment (supports markdown formatting) project: Optional project name. If not provided, will be determined from the work item. Returns: Formatted string containing confirmation and the added comment with author information and timestamp """ try: wit_client = get_work_item_client() return _add_work_item_comment_impl(id, text, wit_client, project) except AzureDevOpsClientError as e: return f"Error: {str(e)}"

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