Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

create_catalog_item_variable

Add a custom variable to a ServiceNow catalog item to capture user input during service requests, defining properties like type, label, and validation rules.

Instructions

Create a new catalog item variable

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalog_item_idYesThe sys_id of the catalog item
default_valueNoDefault value for the variable
descriptionNoDescription of the variable
help_textNoHelp text to display with the variable
labelYesThe display label for the variable
mandatoryNoWhether the variable is required
maxNoMaximum value for numeric fields
max_lengthNoMaximum length for string fields
minNoMinimum value for numeric fields
nameYesThe name of the variable (internal name)
orderNoDisplay order of the variable
reference_qualifierNoFor reference fields, the query to filter reference options
reference_tableNoFor reference fields, the table to reference
typeYesThe type of variable (e.g., string, integer, boolean, reference)

Implementation Reference

  • The handler function that implements the core logic for creating a catalog item variable by constructing a payload and POSTing to ServiceNow's item_option_new table API endpoint.
    def create_catalog_item_variable(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: CreateCatalogItemVariableParams,
    ) -> CatalogItemVariableResponse:
        """
        Create a new variable (form field) for a catalog item.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for creating a catalog item variable.
    
        Returns:
            Response with information about the created variable.
        """
        api_url = f"{config.instance_url}/api/now/table/item_option_new"
    
        # Build request data
        data = {
            "cat_item": params.catalog_item_id,
            "name": params.name,
            "type": params.type,
            "question_text": params.label,
            "mandatory": str(params.mandatory).lower(),  # ServiceNow expects "true"/"false" strings
        }
    
        if params.help_text:
            data["help_text"] = params.help_text
        if params.default_value:
            data["default_value"] = params.default_value
        if params.description:
            data["description"] = params.description
        if params.order is not None:
            data["order"] = params.order
        if params.reference_table:
            data["reference"] = params.reference_table
        if params.reference_qualifier:
            data["reference_qual"] = params.reference_qualifier
        if params.max_length:
            data["max_length"] = params.max_length
        if params.min is not None:
            data["min"] = params.min
        if params.max is not None:
            data["max"] = params.max
    
        # Make request
        try:
            response = requests.post(
                api_url,
                json=data,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", {})
    
            return CatalogItemVariableResponse(
                success=True,
                message="Catalog item variable created successfully",
                variable_id=result.get("sys_id"),
                details=result,
            )
    
        except requests.RequestException as e:
            logger.error(f"Failed to create catalog item variable: {e}")
            return CatalogItemVariableResponse(
                success=False,
                message=f"Failed to create catalog item variable: {str(e)}",
            )
  • Pydantic model defining the input parameters for the create_catalog_item_variable tool.
    class CreateCatalogItemVariableParams(BaseModel):
        """Parameters for creating a catalog item variable."""
    
        catalog_item_id: str = Field(..., description="The sys_id of the catalog item")
        name: str = Field(..., description="The name of the variable (internal name)")
        type: str = Field(..., description="The type of variable (e.g., string, integer, boolean, reference)")
        label: str = Field(..., description="The display label for the variable")
        mandatory: bool = Field(False, description="Whether the variable is required")
        help_text: Optional[str] = Field(None, description="Help text to display with the variable")
        default_value: Optional[str] = Field(None, description="Default value for the variable")
        description: Optional[str] = Field(None, description="Description of the variable")
        order: Optional[int] = Field(None, description="Display order of the variable")
        reference_table: Optional[str] = Field(None, description="For reference fields, the table to reference")
        reference_qualifier: Optional[str] = Field(None, description="For reference fields, the query to filter reference options")
        max_length: Optional[int] = Field(None, description="Maximum length for string fields")
        min: Optional[int] = Field(None, description="Minimum value for numeric fields")
        max: Optional[int] = Field(None, description="Maximum value for numeric fields")
  • Tool registration in the central tool_definitions dictionary returned by get_tool_definitions, mapping the tool name to its handler, schema, return type, description, and serialization method.
    "create_catalog_item_variable": (
        create_catalog_item_variable_tool,
        CreateCatalogItemVariableParams,
        Dict[str, Any],  # Expects dict
        "Create a new catalog item variable",
        "dict",  # Tool returns Pydantic model
    ),
  • Import and aliasing of the handler function for use in tool registration.
    create_catalog_item_variable as create_catalog_item_variable_tool,
  • Import of the create_catalog_item_variable function into the tools package namespace.
    from servicenow_mcp.tools.catalog_variables import (
        create_catalog_item_variable,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'Create a new catalog item variable', implying a write operation, but doesn't cover permissions required, side effects, error handling, or response format. For a tool with 14 parameters and no output schema, this lack of behavioral context is a significant gap, though it doesn't contradict annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence: 'Create a new catalog item variable'. It is front-loaded and wastes no words, making it efficient. However, it may be overly concise given the tool's complexity, potentially sacrificing clarity for brevity.

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 (14 parameters, no output schema, no annotations), the description is incomplete. It lacks details on behavioral aspects, usage context, and output expectations. While the schema covers parameters, the description fails to provide necessary context for effective tool invocation, leaving gaps in understanding the tool's role and effects.

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%, meaning all parameters are documented in the input schema. The description adds no additional parameter semantics beyond the schema, such as examples or usage notes. According to the rules, with high schema coverage, the baseline score is 3, as the description doesn't need to compensate but also doesn't enhance understanding.

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

Purpose2/5

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

The description 'Create a new catalog item variable' restates the tool name with minimal elaboration. It specifies the verb 'create' and resource 'catalog item variable', but lacks detail on what a catalog item variable is or its purpose, making it vague. It doesn't differentiate from siblings like 'update_catalog_item_variable' or 'list_catalog_item_variables', leaving the agent to infer distinctions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, such as needing an existing catalog item, or contrast it with sibling tools like 'update_catalog_item_variable' for modifications or 'list_catalog_item_variables' for viewing. This absence leaves the agent without context for appropriate tool selection.

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

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