create_changeset
Create a new changeset in ServiceNow to track and manage application modifications with specified name, description, and developer assignment.
Instructions
Create a new changeset in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the changeset | |
| description | No | Description of the changeset | |
| application | Yes | Application the changeset belongs to | |
| developer | No | Developer responsible for the changeset |
Implementation Reference
- The main handler function that implements the create_changeset tool logic, including parameter validation, API request to ServiceNow, and response handling.def create_changeset( auth_manager: AuthManager, server_config: ServerConfig, params: Union[Dict[str, Any], CreateChangesetParams], ) -> Dict[str, Any]: """ Create a new changeset in ServiceNow. Args: auth_manager: The authentication manager. server_config: The server configuration. params: The parameters for creating a changeset. Can be a dictionary or a CreateChangesetParams object. Returns: The created changeset. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, CreateChangesetParams, required_fields=["name", "application"] ) if not result["success"]: return result validated_params = result["params"] # Prepare the request data data = { "name": validated_params.name, "application": validated_params.application, } # Add optional fields if provided if validated_params.description: data["description"] = validated_params.description if validated_params.developer: data["developer"] = validated_params.developer # 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" try: response = requests.post(url, json=data, headers=headers) response.raise_for_status() result = response.json() return { "success": True, "message": "Changeset created successfully", "changeset": result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error creating changeset: {e}") return { "success": False, "message": f"Error creating changeset: {str(e)}", }
- Pydantic model defining the input parameters and validation schema for the create_changeset tool.class CreateChangesetParams(BaseModel): """Parameters for creating a changeset.""" name: str = Field(..., description="Name of the changeset") description: Optional[str] = Field(None, description="Description of the changeset") application: str = Field(..., description="Application the changeset belongs to") developer: Optional[str] = Field(None, description="Developer responsible for the changeset")
- src/servicenow_mcp/utils/tool_utils.py:635-641 (registration)Registration of the create_changeset tool in the central tool definitions dictionary, linking the handler, schema, description, and serialization details for MCP server integration."create_changeset": ( create_changeset_tool, CreateChangesetParams, str, # Expects JSON string "Create a new changeset in ServiceNow", "json_dict", # Tool returns Pydantic model ),
- src/servicenow_mcp/utils/tool_utils.py:105-106 (registration)Import alias for the create_changeset handler used in tool registration.create_changeset as create_changeset_tool, )
- src/servicenow_mcp/tools/__init__.py:36-36 (registration)Re-export of create_changeset from changeset_tools.py to make it available in the tools package.create_changeset,