create_script_include
Create custom server-side scripts in ServiceNow to automate processes, extend functionality, or integrate with other systems.
Instructions
Create a new script include in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the script include | |
| script | Yes | Script content | |
| description | No | Description of the script include | |
| api_name | No | API name of the script include | |
| client_callable | No | Whether the script include is client callable | |
| active | No | Whether the script include is active | |
| access | No | Access level of the script include | package_private |
Implementation Reference
- The core handler function implementing the create_script_include tool. It constructs a POST request to the ServiceNow sys_script_include table API with the provided parameters and returns a ScriptIncludeResponse.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 BaseModel defining the input schema/parameters for the create_script_include tool, including required fields like name and script.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")
- src/servicenow_mcp/utils/tool_utils.py:639-645 (registration)Registration of the create_script_include tool in the central tool_definitions dictionary used by the MCP server, specifying the handler alias, params 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 ),
- src/servicenow_mcp/utils/tool_utils.py:188-189 (registration)Import of the create_script_include handler aliased as create_script_include_tool for use in tool registration.create_script_include as create_script_include_tool, )
- src/servicenow_mcp/tools/__init__.py:60-66 (registration)Export/import of script include tools including create_script_include in the tools package __init__ for broader accessibility.from servicenow_mcp.tools.script_include_tools import ( create_script_include, delete_script_include, get_script_include, list_script_includes, update_script_include, )