commit_changeset
Commit a ServiceNow changeset by specifying its ID and optional message. This tool facilitates tracking and deploying updates within the ServiceNow MCP Server.
Instructions
Commit a changeset in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| changeset_id | Yes | Changeset ID or sys_id | |
| commit_message | No | Commit message |
Implementation Reference
- Main implementation of the commit_changeset tool handler. Validates parameters, prepares PATCH request to set changeset state to 'complete', 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 model defining the input schema for the commit_changeset tool, including 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")
- src/servicenow_mcp/utils/tool_utils.py:603-609 (registration)Tool registration in get_tool_definitions() dictionary, mapping 'commit_changeset' to its handler function, params schema, return type, description, and serialization method."commit_changeset": ( commit_changeset_tool, CommitChangesetParams, str, "Commit a changeset in ServiceNow", "str", # Tool returns simple message ),
- src/servicenow_mcp/tools/changeset_tools.py:35-35 (registration)No, wrong. Wait, this is import in tools/__init__.py"""Parameters for getting changeset details."""
- src/servicenow_mcp/tools/__init__.py:35-35 (registration)Import of commit_changeset function into the tools package namespace, exposing it for use in tool_utils.py and elsewhere.commit_changeset,