Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

create_script_include

Create a new script include in ServiceNow by providing a name, script content, and optional configuration settings for client callable status, access level, and activation.

Instructions

Create a new script include in ServiceNow

Input Schema

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

Implementation Reference

  • The handler function that executes the tool logic: sends a POST request to ServiceNow's sys_script_include table API with the provided parameters to create a new script include.
    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)}", )
  • Input schema using Pydantic BaseModel for validating tool parameters.
    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")
  • Tool registration in the get_tool_definitions() function, associating the tool name with its handler (aliased), input schema, return type, 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 ),
  • Output schema using Pydantic BaseModel for the tool response.
    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")

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/javerthl/servicenow-mcp'

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