Skip to main content
Glama
echelon-ai-labs

ServiceNow MCP Server

add_file_to_changeset

Add a file to a ServiceNow changeset by specifying the changeset ID, file path, and content. Facilitates updates to changeset configurations efficiently.

Instructions

Add a file to a changeset in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The core handler function that executes the tool logic: validates params, makes POST request to ServiceNow's sys_update_xml table to add the file to the specified changeset.
    def add_file_to_changeset(
        auth_manager: AuthManager,
        server_config: ServerConfig,
        params: Union[Dict[str, Any], AddFileToChangesetParams],
    ) -> Dict[str, Any]:
        """
        Add a file to a changeset in ServiceNow.
    
        Args:
            auth_manager: The authentication manager.
            server_config: The server configuration.
            params: The parameters for adding a file to a changeset. Can be a dictionary or a AddFileToChangesetParams object.
    
        Returns:
            The result of the add file operation.
        """
        # Unwrap and validate parameters
        result = _unwrap_and_validate_params(
            params, 
            AddFileToChangesetParams, 
            required_fields=["changeset_id", "file_path", "file_content"]
        )
        
        if not result["success"]:
            return result
        
        validated_params = result["params"]
        
        # 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"
        
        # Prepare the request data for adding a file
        data = {
            "update_set": validated_params.changeset_id,
            "name": validated_params.file_path,
            "payload": validated_params.file_content,
            "type": "file",
        }
        
        # Make the API request
        url = f"{instance_url}/api/now/table/sys_update_xml"
        
        try:
            response = requests.post(url, json=data, headers=headers)
            response.raise_for_status()
            
            result = response.json()
            
            return {
                "success": True,
                "message": "File added to changeset successfully",
                "file": result["result"],
            }
        except requests.exceptions.RequestException as e:
            logger.error(f"Error adding file to changeset: {e}")
            return {
                "success": False,
                "message": f"Error adding file to changeset: {str(e)}",
            } 
  • Pydantic BaseModel defining the input schema (parameters) for the add_file_to_changeset tool.
    class AddFileToChangesetParams(BaseModel):
        """Parameters for adding a file to a changeset."""
    
        changeset_id: str = Field(..., description="Changeset ID or sys_id")
        file_path: str = Field(..., description="Path of the file to add")
        file_content: str = Field(..., description="Content of the file")
  • Tool registration entry in get_tool_definitions() dictionary, mapping name to (handler, schema, return_type, description, serialization). This is used by the MCP server to expose the tool.
    "add_file_to_changeset": (
        add_file_to_changeset_tool,
        AddFileToChangesetParams,
        str,
        "Add a file to a changeset in ServiceNow",
        "str",  # Tool returns simple message
    ),
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but provides minimal information. 'Add a file to a changeset' implies a write/mutation operation, but the description doesn't disclose permission requirements, whether this action is reversible, what happens if the file already exists, rate limits, or what the response looks like. For a mutation tool with zero annotation coverage, this is inadequate.

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 maximally concise with a single clear sentence: 'Add a file to a changeset in ServiceNow.' Every word earns its place - 'Add' (action), 'a file' (object), 'to a changeset' (target), 'in ServiceNow' (context). There's zero waste or redundancy.

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 mutation tool with 3 parameters, 0% schema description coverage, no annotations, and no output schema, the description is severely incomplete. It states what the tool does at a high level but provides no information about parameters, behavioral characteristics, error conditions, or expected outcomes. The agent would struggle to use this tool correctly without additional context.

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

Parameters2/5

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

Schema description coverage is 0%, meaning none of the 3 parameters have descriptions in the schema. The tool description provides no parameter information whatsoever - it doesn't mention changeset_id, file_path, or file_content. The description fails to compensate for the complete lack of schema documentation, leaving all parameters semantically undefined.

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 file') and target resource ('to a changeset in ServiceNow'), providing specific verb+resource pairing. It distinguishes from sibling tools like 'create_changeset' or 'commit_changeset' by focusing on file addition rather than changeset creation or finalization. However, it doesn't explicitly differentiate from potential file-related operations that might exist in other contexts.

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. It doesn't mention prerequisites (e.g., needing an existing changeset), when not to use it, or what alternatives exist for similar operations. The agent must infer usage from the tool name alone without contextual guidance.

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