Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

get_script_include

Retrieve a specific script include from ServiceNow by providing its ID or name to access server-side logic and functionality.

Instructions

Get a specific script include from ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
script_include_idYesScript include ID or name

Implementation Reference

  • The core handler function that implements the logic to retrieve a specific Script Include from ServiceNow by sys_id or name using the REST API.
    def get_script_include(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: GetScriptIncludeParams,
    ) -> Dict[str, Any]:
        """Get a specific script include from ServiceNow.
        
        Args:
            config: The server configuration.
            auth_manager: The authentication manager.
            params: The parameters for the request.
            
        Returns:
            A dictionary containing the script include data.
        """
        try:
            # Build query parameters
            query_params = {
                "sysparm_display_value": "true",
                "sysparm_exclude_reference_link": "true",
                "sysparm_fields": "sys_id,name,script,description,api_name,client_callable,active,access,sys_created_on,sys_updated_on,sys_created_by,sys_updated_by"
            }
            
            # Determine if we're querying by sys_id or name
            if params.script_include_id.startswith("sys_id:"):
                sys_id = params.script_include_id.replace("sys_id:", "")
                url = f"{config.instance_url}/api/now/table/sys_script_include/{sys_id}"
            else:
                # Query by name
                url = f"{config.instance_url}/api/now/table/sys_script_include"
                query_params["sysparm_query"] = f"name={params.script_include_id}"
                
            # Make the request
            headers = auth_manager.get_headers()
            
            response = requests.get(
                url,
                params=query_params,
                headers=headers,
                timeout=30,
            )
            response.raise_for_status()
            
            # Parse the response
            data = response.json()
            
            if "result" not in data:
                return {
                    "success": False,
                    "message": f"Script include not found: {params.script_include_id}",
                }
                
            # Handle both single result and list of results
            result = data["result"]
            if isinstance(result, list):
                if not result:
                    return {
                        "success": False,
                        "message": f"Script include not found: {params.script_include_id}",
                    }
                item = result[0]
            else:
                item = result
                
            script_include = {
                "sys_id": item.get("sys_id"),
                "name": item.get("name"),
                "script": item.get("script"),
                "description": item.get("description"),
                "api_name": item.get("api_name"),
                "client_callable": item.get("client_callable") == "true",
                "active": item.get("active") == "true",
                "access": item.get("access"),
                "created_on": item.get("sys_created_on"),
                "updated_on": item.get("sys_updated_on"),
                "created_by": item.get("sys_created_by", {}).get("display_value"),
                "updated_by": item.get("sys_updated_by", {}).get("display_value"),
            }
            
            return {
                "success": True,
                "message": f"Found script include: {item.get('name')}",
                "script_include": script_include,
            }
            
        except Exception as e:
            logger.error(f"Error getting script include: {e}")
            return {
                "success": False,
                "message": f"Error getting script include: {str(e)}",
            }
  • Pydantic model defining the input schema for the get_script_include tool, requiring a script_include_id parameter.
    class GetScriptIncludeParams(BaseModel):
        """Parameters for getting a script include."""
        
        script_include_id: str = Field(..., description="Script include ID or name")
  • Registers the get_script_include tool in the central tool_definitions dictionary used by the MCP server, linking the handler, schema, description, and output handling.
    "get_script_include": (
        get_script_include_tool,
        GetScriptIncludeParams,
        Dict[str, Any],  # Expects dict
        "Get a specific script include from ServiceNow",
        "raw_dict",  # Tool returns raw dict
    ),
  • Imports the get_script_include function (among others) into the tools package namespace, making it available for registration.
    from servicenow_mcp.tools.script_include_tools import (
        create_script_include,
        delete_script_include,
        get_script_include,
        list_script_includes,
        update_script_include,
    )
  • Adds get_script_include to the __all__ list, explicitly exposing it from the tools package.
    "list_script_includes",
    "get_script_include",
    "create_script_include",
    "update_script_include",
    "delete_script_include",

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states 'Get' which implies a read-only operation, but doesn't clarify permissions required, error handling (e.g., if ID is invalid), response format, or whether it returns metadata or full content. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks context on usage, behavioral details, or output expectations. For a simple read tool, this might suffice, but it doesn't fully compensate for the absence of annotations or output schema.

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 the parameter 'script_include_id' clearly documented as 'Script include ID or name'. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or validation rules. With high schema coverage, the baseline score of 3 is appropriate.

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 ('Get') and resource ('a specific script include from ServiceNow'), making the purpose unambiguous. It distinguishes this as a retrieval operation for individual script includes rather than listing them (like list_script_includes). However, it doesn't explicitly contrast with sibling tools beyond the implied specificity versus listing.

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 a script include ID), contrast with list_script_includes for browsing, or specify use cases like retrieving details after listing. Without such context, the agent must infer usage from the name 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