Skip to main content
Glama
echelon-ai-labs

ServiceNow MCP Server

add_comment

Add comments or work notes to incidents in ServiceNow using incident ID, enabling clear communication and updates within the platform.

Instructions

Add a comment to an incident in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The handler function that executes the 'add_comment' tool logic: resolves incident ID if necessary, adds comment or work note via ServiceNow API PUT request, returns IncidentResponse.
    def add_comment(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: AddCommentParams,
    ) -> IncidentResponse:
        """
        Add a comment to an incident in ServiceNow.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for adding the comment.
    
        Returns:
            Response with the result of the operation.
        """
        # Determine if incident_id is a number or sys_id
        incident_id = params.incident_id
        if len(incident_id) == 32 and all(c in "0123456789abcdef" for c in incident_id):
            # This is likely a sys_id
            api_url = f"{config.api_url}/table/incident/{incident_id}"
        else:
            # This is likely an incident number
            # First, we need to get the sys_id
            try:
                query_url = f"{config.api_url}/table/incident"
                query_params = {
                    "sysparm_query": f"number={incident_id}",
                    "sysparm_limit": 1,
                }
    
                response = requests.get(
                    query_url,
                    params=query_params,
                    headers=auth_manager.get_headers(),
                    timeout=config.timeout,
                )
                response.raise_for_status()
    
                result = response.json().get("result", [])
                if not result:
                    return IncidentResponse(
                        success=False,
                        message=f"Incident not found: {incident_id}",
                    )
    
                incident_id = result[0].get("sys_id")
                api_url = f"{config.api_url}/table/incident/{incident_id}"
    
            except requests.RequestException as e:
                logger.error(f"Failed to find incident: {e}")
                return IncidentResponse(
                    success=False,
                    message=f"Failed to find incident: {str(e)}",
                )
    
        # Build request data
        data = {}
    
        if params.is_work_note:
            data["work_notes"] = params.comment
        else:
            data["comments"] = params.comment
    
        # Make request
        try:
            response = requests.put(
                api_url,
                json=data,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", {})
    
            return IncidentResponse(
                success=True,
                message="Comment added successfully",
                incident_id=result.get("sys_id"),
                incident_number=result.get("number"),
            )
    
        except requests.RequestException as e:
            logger.error(f"Failed to add comment: {e}")
            return IncidentResponse(
                success=False,
                message=f"Failed to add comment: {str(e)}",
            )
  • Pydantic schema/model defining input parameters for the add_comment tool: incident_id, comment, is_work_note.
    class AddCommentParams(BaseModel):
        """Parameters for adding a comment to an incident."""
    
        incident_id: str = Field(..., description="Incident ID or sys_id")
        comment: str = Field(..., description="Comment to add to the incident")
        is_work_note: bool = Field(False, description="Whether the comment is a work note")
  • Registration of the 'add_comment' tool in the central tool_definitions dictionary used for MCP server: maps name to (handler, schema, return_type, description, serialization).
    "add_comment": (
        add_comment_tool,
        AddCommentParams,
        str,
        "Add a comment to an incident in ServiceNow",
        "str",
    ),
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without behavioral details. It doesn't disclose permissions needed, whether the operation is idempotent, rate limits, or what happens on success/failure (e.g., comment visibility). This leaves significant gaps for a mutation tool.

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, clear sentence with zero wasted words—front-loaded with the core action and resource. It's appropriately sized for the tool's apparent simplicity, making it easy to scan and understand quickly.

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?

Given no annotations, no output schema, and a mutation tool with implicit parameters, the description is incomplete. It lacks behavioral context (e.g., side effects, error handling), doesn't explain return values, and misses parameter details like 'is_work_note'. For a tool that modifies data, this is insufficient.

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

Parameters4/5

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

The description doesn't explicitly mention parameters, but with 0% schema description coverage and 1 parameter (a nested object with 3 sub-parameters), it implicitly suggests 'incident_id' and 'comment' through context. However, it misses 'is_work_note' entirely. Since 0 parameters are directly documented, baseline is 4, but it's not a 5 due to the missing boolean parameter nuance.

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 action ('Add a comment') and target resource ('to an incident in ServiceNow'), providing a specific verb+resource combination. However, it doesn't differentiate from potential sibling tools like 'resolve_incident' or 'update_incident' that might also involve incident modification, missing explicit distinction.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., incident must exist), exclusions, or comparisons to other comment-related tools (none in the sibling list, but context for incident modification isn't clarified).

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

Related 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/echelon-ai-labs/servicenow-mcp'

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