Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

commit_changeset

Commit a changeset in ServiceNow to finalize configuration changes with an optional message.

Instructions

Commit a changeset in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
changeset_idYesChangeset ID or sys_id
commit_messageNoCommit message

Implementation Reference

  • Main execution logic for the 'commit_changeset' tool: validates input parameters, prepares a PATCH request to update the changeset state to 'complete' in ServiceNow's sys_update_set table, optionally sets description as commit message, and returns success/error response.
    def commit_changeset(
        auth_manager: AuthManager,
        server_config: ServerConfig,
        params: Union[Dict[str, Any], CommitChangesetParams],
    ) -> Dict[str, Any]:
        """
        Commit a changeset in ServiceNow.
    
        Args:
            auth_manager: The authentication manager.
            server_config: The server configuration.
            params: The parameters for committing a changeset. Can be a dictionary or a CommitChangesetParams object.
    
        Returns:
            The committed changeset.
        """
        # Unwrap and validate parameters
        result = _unwrap_and_validate_params(
            params, 
            CommitChangesetParams, 
            required_fields=["changeset_id"]
        )
        
        if not result["success"]:
            return result
        
        validated_params = result["params"]
        
        # Prepare the request data
        data = {
            "state": "complete",
        }
        
        # Add commit message if provided
        if validated_params.commit_message:
            data["description"] = validated_params.commit_message
        
        # Get the instance URL
        instance_url = _get_instance_url(auth_manager, server_config)
        if not instance_url:
            return {
                "success": False,
                "message": "Cannot find instance_url in either server_config or auth_manager",
            }
        
        # Get the headers
        headers = _get_headers(auth_manager, server_config)
        if not headers:
            return {
                "success": False,
                "message": "Cannot find get_headers method in either auth_manager or server_config",
            }
        
        # Add Content-Type header
        headers["Content-Type"] = "application/json"
        
        # Make the API request
        url = f"{instance_url}/api/now/table/sys_update_set/{validated_params.changeset_id}"
        
        try:
            response = requests.patch(url, json=data, headers=headers)
            response.raise_for_status()
            
            result = response.json()
            
            return {
                "success": True,
                "message": "Changeset committed successfully",
                "changeset": result["result"],
            }
        except requests.exceptions.RequestException as e:
            logger.error(f"Error committing changeset: {e}")
            return {
                "success": False,
                "message": f"Error committing changeset: {str(e)}",
            }
  • Pydantic BaseModel defining the input schema for the commit_changeset tool, with required 'changeset_id' and optional 'commit_message'.
    class CommitChangesetParams(BaseModel):
        """Parameters for committing a changeset."""
    
        changeset_id: str = Field(..., description="Changeset ID or sys_id")
        commit_message: Optional[str] = Field(None, description="Commit message")
  • MCP tool registration in get_tool_definitions(): maps 'commit_changeset' to its handler function (commit_changeset_tool), input schema (CommitChangesetParams), return type hint (str), description, and serialization method.
    "commit_changeset": (
        commit_changeset_tool,
        CommitChangesetParams,
        str,
        "Commit a changeset in ServiceNow",
        "str",  # Tool returns simple message
    ),
  • Import and alias of the commit_changeset handler as commit_changeset_tool for use in tool registration.
    commit_changeset as commit_changeset_tool,
  • Shared helper function used by commit_changeset (and other tools) to validate and unwrap input parameters against the Pydantic schema, checking required fields.
    def _unwrap_and_validate_params(
        params: Union[Dict[str, Any], BaseModel], 
        model_class: Type[T], 
        required_fields: Optional[List[str]] = None
    ) -> Dict[str, Any]:
        """
        Unwrap and validate parameters.
    
        Args:
            params: The parameters to unwrap and validate. Can be a dictionary or a Pydantic model.
            model_class: The Pydantic model class to validate against.
            required_fields: List of fields that must be present.
    
        Returns:
            A dictionary with success status and validated parameters or error message.
        """
        try:
            # Handle case where params is already a Pydantic model
            if isinstance(params, BaseModel):
                # If it's already the correct model class, use it directly
                if isinstance(params, model_class):
                    model_instance = params
                # Otherwise, convert to dict and create new instance
                else:
                    model_instance = model_class(**params.dict())
            # Handle dictionary case
            else:
                # Create model instance
                model_instance = model_class(**params)
            
            # Check required fields
            if required_fields:
                missing_fields = []
                for field in required_fields:
                    if getattr(model_instance, field, None) is None:
                        missing_fields.append(field)
                
                if missing_fields:
                    return {
                        "success": False,
                        "message": f"Missing required fields: {', '.join(missing_fields)}",
                    }
            
            return {
                "success": True,
                "params": model_instance,
            }
        except Exception as e:
            return {
                "success": False,
                "message": f"Invalid parameters: {str(e)}",
            }
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 states the action ('commit') but doesn't explain what committing does (e.g., whether it's a write operation, requires permissions, has side effects like locking the changeset, or affects workflow states). For a mutation tool in a change management context, this lack of detail is a significant gap, though it doesn't contradict any annotations.

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 with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by conveying the essential purpose without redundancy or unnecessary elaboration.

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 the complexity of a commit operation in ServiceNow (likely a mutation with potential side effects), no annotations, and no output schema, the description is incomplete. It doesn't explain what happens after committing (e.g., success/failure states, return values, or impact on related entities), leaving the agent with insufficient context to use the tool effectively beyond basic invocation.

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?

Schema description coverage is 100%, with clear parameter descriptions in the schema (e.g., 'changeset_id' as 'Changeset ID or sys_id'). The tool description adds no additional parameter semantics beyond what the schema provides, such as format examples or usage context. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the documentation burden adequately.

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

Purpose3/5

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

The description 'Commit a changeset in ServiceNow' states the basic action (commit) and resource (changeset) but lacks specificity about what committing entails (e.g., finalizing, applying, or saving changes). It distinguishes from siblings like 'create_changeset' and 'publish_changeset' by focusing on the commit step, but doesn't clarify the exact difference from 'publish_changeset' or the relationship to other change management tools.

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 like 'publish_changeset' or 'update_changeset', nor does it mention prerequisites (e.g., needing an existing changeset). The description implies usage after changeset creation, but this is not explicitly stated, leaving the agent to infer context from sibling tool names alone.

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/vparlapalli490/MCP'

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