Skip to main content
Glama

get_work_item_comments

Retrieve and paginate through comments for a specific Azure DevOps work item to track discussions and feedback.

Instructions

Gets comments for a specific work item with pagination support.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
work_item_idYesThe ID of the work item to get comments for.
projectNoThe name or ID of the project (optional if project context is set).
topNoMaximum number of comments to return (for pagination).
continuation_tokenNoToken for getting the next page of results.
include_deletedNoWhether to include deleted comments (default: false).
expandNoAdditional data retrieval options for work item comments.
orderNoOrder in which comments should be returned (e.g., 'created_date_asc', 'created_date_desc').

Implementation Reference

  • The main handler function that retrieves and formats comments for a given work item using the Azure DevOps API, supporting pagination, filtering, and detailed user information.
    def get_work_item_comments(self, work_item_id, project=None, top=None, continuation_token=None, include_deleted=False, expand=None, order=None):
        """
        Get comments for a specific work item.
        
        Args:
            work_item_id (int): The ID of the work item to get comments for
            project (str, optional): Project name or ID. If not provided, uses project_context
            top (int, optional): Maximum number of comments to return (pagination)
            continuation_token (str, optional): Token for getting next page of results
            include_deleted (bool): Whether to include deleted comments (default: False)
            expand (str, optional): Additional data retrieval options for work item comments
            order (str, optional): Order in which comments should be returned
            
        Returns:
            dict: Contains comments list and pagination info
        """
        # Use provided project or fallback to context
        project_name = project or self.project_context
        if not project_name:
            raise ValueError("Project must be specified either as parameter or set in project context")
        
        # Get comments from Azure DevOps API
        comment_list = self.work_item_tracking_client.get_comments(
            project=project_name,
            work_item_id=work_item_id,
            top=top,
            continuation_token=continuation_token,
            include_deleted=include_deleted,
            expand=expand,
            order=order
        )
        
        # Format the response
        result = {
            "total_count": comment_list.total_count if hasattr(comment_list, 'total_count') else None,
            "continuation_token": comment_list.continuation_token if hasattr(comment_list, 'continuation_token') else None,
            "comments": []
        }
        
        if comment_list.comments:
            for comment in comment_list.comments:
                formatted_comment = {
                    "id": comment.id,
                    "text": comment.text,
                    "created_by": {
                        "id": comment.created_by.id if comment.created_by else None,
                        "display_name": comment.created_by.display_name if comment.created_by else None,
                        "unique_name": comment.created_by.unique_name if comment.created_by else None,
                        "image_url": comment.created_by.image_url if comment.created_by else None
                    } if comment.created_by else None,
                    "created_date": comment.created_date.isoformat() if comment.created_date else None,
                    "modified_by": {
                        "id": comment.modified_by.id if comment.modified_by else None,
                        "display_name": comment.modified_by.display_name if comment.modified_by else None,
                        "unique_name": comment.modified_by.unique_name if comment.modified_by else None,
                        "image_url": comment.modified_by.image_url if comment.modified_by else None
                    } if comment.modified_by else None,
                    "modified_date": comment.modified_date.isoformat() if comment.modified_date else None,
                    "url": comment.url if hasattr(comment, 'url') else None,
                    "version": comment.version if hasattr(comment, 'version') else None
                }
                result["comments"].append(formatted_comment)
        
        return result
  • Defines the input schema and description for the get_work_item_comments tool, specifying parameters like work_item_id (required), project, top, etc.
    types.Tool(
        name="get_work_item_comments",
        description="Gets comments for a specific work item with pagination support.",
        inputSchema={
            "type": "object",
            "properties": {
                "work_item_id": {
                    "type": "integer", 
                    "description": "The ID of the work item to get comments for."
                },
                "project": {
                    "type": "string", 
                    "description": "The name or ID of the project (optional if project context is set)."
                },
                "top": {
                    "type": "integer", 
                    "description": "Maximum number of comments to return (for pagination)."
                },
                "continuation_token": {
                    "type": "string", 
                    "description": "Token for getting the next page of results."
                },
                "include_deleted": {
                    "type": "boolean", 
                    "description": "Whether to include deleted comments (default: false)."
                },
                "expand": {
                    "type": "string", 
                    "description": "Additional data retrieval options for work item comments."
                },
                "order": {
                    "type": "string", 
                    "description": "Order in which comments should be returned (e.g., 'created_date_asc', 'created_date_desc')."
                }
            },
            "required": ["work_item_id"],
            "additionalProperties": False
        }
    ),
  • Registers and dispatches the tool call to the client handler in the MCP server's _execute_tool method.
    elif name == "get_work_item_comments":
        return self.client.get_work_item_comments(**arguments)
Behavior2/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 mentions 'pagination support' which is useful, but doesn't describe authentication requirements, rate limits, error conditions, response format, or whether the operation is read-only or has side effects. For a tool with 7 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that states the core purpose and key feature (pagination) without unnecessary words. It's appropriately sized for the tool's complexity and gets straight to the point with zero wasted text.

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

Completeness2/5

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

For a tool with 7 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the response looks like, how comments are structured, what authentication is required, or how to handle errors. The mention of pagination is helpful but doesn't compensate for the significant gaps in behavioral and output context.

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

Parameters3/5

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

The description doesn't add any parameter-specific information beyond what's already in the schema (which has 100% coverage). It mentions 'pagination support' which relates to the 'top' and 'continuation_token' parameters, but doesn't provide additional context about how pagination works or best practices. With complete schema documentation, the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the verb ('Gets') and resource ('comments for a specific work item'), making the purpose understandable. It distinguishes itself from siblings like 'get_work_item' or 'search_work_items' by focusing specifically on comments. However, it doesn't explicitly differentiate from potential comment-related tools that might exist in other contexts, keeping it at 4 rather than 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. While it mentions 'pagination support,' it doesn't explain when pagination is needed or how to choose between this and other work item tools like 'get_work_item' or 'search_work_items.' There's no mention of prerequisites, performance considerations, or typical use cases.

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/xrmghost/mcp-azure-devops'

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