Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

list_script_includes

Retrieve and filter script includes from ServiceNow instances to manage custom server-side logic with pagination and status filtering.

Instructions

List script includes from ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of script includes to return
offsetNoOffset for pagination
activeNoFilter by active status
client_callableNoFilter by client callable status
queryNoSearch query for script includes

Implementation Reference

  • The main handler function that implements the 'list_script_includes' tool logic by querying the ServiceNow REST API for sys_script_include table.
    def list_script_includes(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: ListScriptIncludesParams,
    ) -> Dict[str, Any]:
        """List script includes from ServiceNow.
        
        Args:
            config: The server configuration.
            auth_manager: The authentication manager.
            params: The parameters for the request.
            
        Returns:
            A dictionary containing the list of script includes.
        """
        try:
            # Build the URL
            url = f"{config.instance_url}/api/now/table/sys_script_include"
            
            # Build query parameters
            query_params = {
                "sysparm_limit": params.limit,
                "sysparm_offset": params.offset,
                "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"
            }
            
            # Add filters if provided
            query_parts = []
            
            if params.active is not None:
                query_parts.append(f"active={str(params.active).lower()}")
                
            if params.client_callable is not None:
                query_parts.append(f"client_callable={str(params.client_callable).lower()}")
                
            if params.query:
                query_parts.append(f"nameLIKE{params.query}")
                
            if query_parts:
                query_params["sysparm_query"] = "^".join(query_parts)
                
            # 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()
            script_includes = []
            
            for item in data.get("result", []):
                script_include = {
                    "sys_id": item.get("sys_id"),
                    "name": item.get("name"),
                    "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"),
                }
                script_includes.append(script_include)
                
            return {
                "success": True,
                "message": f"Found {len(script_includes)} script includes",
                "script_includes": script_includes,
                "total": len(script_includes),
                "limit": params.limit,
                "offset": params.offset,
            }
            
        except Exception as e:
            logger.error(f"Error listing script includes: {e}")
            return {
                "success": False,
                "message": f"Error listing script includes: {str(e)}",
                "script_includes": [],
                "total": 0,
                "limit": params.limit,
                "offset": params.offset,
            }
  • Pydantic model defining the input parameters for the list_script_includes tool.
    class ListScriptIncludesParams(BaseModel):
        """Parameters for listing script includes."""
        
        limit: int = Field(10, description="Maximum number of script includes to return")
        offset: int = Field(0, description="Offset for pagination")
        active: Optional[bool] = Field(None, description="Filter by active status")
        client_callable: Optional[bool] = Field(None, description="Filter by client callable status")
        query: Optional[str] = Field(None, description="Search query for script includes")
  • Tool registration entry in get_tool_definitions() that maps the tool name to its implementation, params schema, description, and serialization method.
    "list_script_includes": (
        list_script_includes_tool,
        ListScriptIncludesParams,
        Dict[str, Any],  # Expects dict
        "List script includes from ServiceNow",
        "raw_dict",  # Tool returns raw dict
    ),
  • Import of the list_script_includes function into the tools package for exposure.
    from servicenow_mcp.tools.script_include_tools import (
        create_script_include,
        delete_script_include,
        get_script_include,
        list_script_includes,
        update_script_include,
    )
  • Inclusion of 'list_script_includes' in the __all__ list for public export.
    "list_script_includes",
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'lists' without disclosing behavioral traits. It doesn't mention whether this is a read-only operation, if it requires specific permissions, how results are ordered, what format they return, or any rate limits. For a listing tool with 5 parameters, 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 with zero waste. It's appropriately sized for a listing tool and front-loads the core purpose without unnecessary elaboration, making it easy 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?

Given the tool's complexity (5 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what script includes are, what fields are returned, how results are structured, or provide any context about ServiceNow-specific behavior. For a listing tool with filtering capabilities, more guidance is needed.

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 fully documents all 5 parameters (limit, offset, active, client_callable, query). The description adds no parameter information beyond what's already in the schema, meeting the baseline of 3 when schema does the heavy lifting but not compensating with additional context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'List script includes from ServiceNow' clearly states the verb ('List') and resource ('script includes'), but it's vague about scope and doesn't differentiate from sibling tools like 'get_script_include' (singular retrieval) or 'create_script_include'. It provides basic purpose but lacks specificity about what 'list' entails compared to alternatives.

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 offers no guidance on when to use this tool versus alternatives. With siblings like 'get_script_include' (for retrieving a specific script include) and 'create_script_include' (for creating new ones), there's no indication that this tool is for browsing/filtering multiple records rather than single retrieval or creation operations.

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

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/vparlapalli490/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server