Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

create_script_include

Add custom server-side scripts to ServiceNow for extending platform functionality, automating processes, or creating reusable code components.

Instructions

Create a new script include in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the script include
scriptYesScript content
descriptionNoDescription of the script include
api_nameNoAPI name of the script include
client_callableNoWhether the script include is client callable
activeNoWhether the script include is active
accessNoAccess level of the script includepackage_private

Implementation Reference

  • The handler function that implements the core logic for creating a script include by making a POST request to the ServiceNow sys_script_include table API endpoint.
    def create_script_include(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: CreateScriptIncludeParams,
    ) -> ScriptIncludeResponse:
        """Create a new script include in ServiceNow.
        
        Args:
            config: The server configuration.
            auth_manager: The authentication manager.
            params: The parameters for the request.
            
        Returns:
            A response indicating the result of the operation.
        """
        # Build the URL
        url = f"{config.instance_url}/api/now/table/sys_script_include"
        
        # Build the request body
        body = {
            "name": params.name,
            "script": params.script,
            "active": str(params.active).lower(),
            "client_callable": str(params.client_callable).lower(),
            "access": params.access,
        }
        
        if params.description:
            body["description"] = params.description
            
        if params.api_name:
            body["api_name"] = params.api_name
            
        # Make the request
        headers = auth_manager.get_headers()
        
        try:
            response = requests.post(
                url,
                json=body,
                headers=headers,
                timeout=30,
            )
            response.raise_for_status()
            
            # Parse the response
            data = response.json()
            
            if "result" not in data:
                return ScriptIncludeResponse(
                    success=False,
                    message="Failed to create script include",
                )
                
            result = data["result"]
            
            return ScriptIncludeResponse(
                success=True,
                message=f"Created script include: {result.get('name')}",
                script_include_id=result.get("sys_id"),
                script_include_name=result.get("name"),
            )
            
        except Exception as e:
            logger.error(f"Error creating script include: {e}")
            return ScriptIncludeResponse(
                success=False,
                message=f"Error creating script include: {str(e)}",
            )
  • Pydantic model defining the input parameters for the create_script_include tool.
    class CreateScriptIncludeParams(BaseModel):
        """Parameters for creating a script include."""
        
        name: str = Field(..., description="Name of the script include")
        script: str = Field(..., description="Script content")
        description: Optional[str] = Field(None, description="Description of the script include")
        api_name: Optional[str] = Field(None, description="API name of the script include")
        client_callable: bool = Field(False, description="Whether the script include is client callable")
        active: bool = Field(True, description="Whether the script include is active")
        access: str = Field("package_private", description="Access level of the script include")
  • Registration of the create_script_include tool in the central tool definitions dictionary used by the MCP server, including the handler, schema, description, and serialization method.
    "create_script_include": (
        create_script_include_tool,
        CreateScriptIncludeParams,
        ScriptIncludeResponse,  # Expects Pydantic model
        "Create a new script include in ServiceNow",
        "raw_pydantic",  # Tool returns Pydantic model
    ),
  • Pydantic model for the response returned by the create_script_include handler.
    class ScriptIncludeResponse(BaseModel):
        """Response from script include operations."""
        
        success: bool = Field(..., description="Whether the operation was successful")
        message: str = Field(..., description="Message describing the result")
        script_include_id: Optional[str] = Field(None, description="ID of the affected script include")
        script_include_name: Optional[str] = Field(None, description="Name of the affected script include")
  • Re-export of the create_script_include function from script_include_tools.py in the tools package __init__.
    from servicenow_mcp.tools.script_include_tools import (
        create_script_include,
        delete_script_include,
        get_script_include,
        list_script_includes,
        update_script_include,
    )

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
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. It states 'Create' implying a write/mutation operation, but doesn't mention permissions required, side effects, error conditions, or what happens on success/failure. For a creation tool with zero annotation coverage, this is a significant gap in transparency.

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 appropriately sized and front-loaded with the core purpose, making it easy for an agent to parse 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?

For a creation tool with 7 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what a script include is, what happens after creation, error handling, or return values. The context signals indicate significant complexity that the description doesn't address.

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%, so the schema already documents all 7 parameters thoroughly. The description adds no parameter information beyond what's in the schema, maintaining the baseline score of 3 for high schema coverage.

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 ('Create') and resource ('new script include in ServiceNow'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'update_script_include' or 'delete_script_include' beyond the basic action, missing explicit sibling 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?

The description provides no guidance on when to use this tool versus alternatives like 'update_script_include' or 'get_script_include', nor does it mention prerequisites or context for creation. It lacks any usage context, leaving the agent to infer from tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools