Skip to main content
Glama
javerthl

ServiceNow MCP Server

by javerthl

list_catalog_item_variables

Retrieve variables associated with a ServiceNow catalog item to understand required inputs and configuration options for service requests.

Instructions

List catalog item variables

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalog_item_idYesThe sys_id of the catalog item
include_detailsNoWhether to include detailed information about each variable
limitNoMaximum number of variables to return
offsetNoOffset for pagination

Implementation Reference

  • The handler function that executes the tool: queries ServiceNow's item_option_new table API for variables of the given catalog item sys_id, applies ORDERBYorder, optional pagination (sysparm_limit/offset), conditional field selection or full details, and returns a structured response.
    def list_catalog_item_variables(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: ListCatalogItemVariablesParams,
    ) -> ListCatalogItemVariablesResponse:
        """
        List all variables (form fields) for a catalog item.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for listing catalog item variables.
    
        Returns:
            Response with a list of variables for the catalog item.
        """
        # Build query parameters
        query_params = {
            "sysparm_query": f"cat_item={params.catalog_item_id}^ORDERBYorder",
        }
        
        if params.limit:
            query_params["sysparm_limit"] = params.limit
        if params.offset:
            query_params["sysparm_offset"] = params.offset
        
        # Include all fields if detailed info is requested
        if params.include_details:
            query_params["sysparm_display_value"] = "true"
            query_params["sysparm_exclude_reference_link"] = "false"
        else:
            query_params["sysparm_fields"] = "sys_id,name,type,question_text,order,mandatory"
    
        api_url = f"{config.instance_url}/api/now/table/item_option_new"
    
        # Make request
        try:
            response = requests.get(
                api_url,
                params=query_params,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", [])
            
            return ListCatalogItemVariablesResponse(
                success=True,
                message=f"Retrieved {len(result)} variables for catalog item",
                variables=result,
                count=len(result),
            )
    
        except requests.RequestException as e:
            logger.error(f"Failed to list catalog item variables: {e}")
            return ListCatalogItemVariablesResponse(
                success=False,
                message=f"Failed to list catalog item variables: {str(e)}",
            )
  • Explicit registration of the tool in get_tool_definitions(): maps tool name to the imported handler alias, input Pydantic model (ListCatalogItemVariablesParams), expected return type hint, description, and serialization strategy ('dict'). This dict is loaded by the MCP server for tool listing and calling.
    "list_catalog_item_variables": (
        list_catalog_item_variables_tool,
        ListCatalogItemVariablesParams,
        Dict[str, Any],  # Expects dict
        "List catalog item variables",
        "dict",  # Tool returns Pydantic model
    ),
  • Input schema: Pydantic model validating tool arguments. Requires catalog_item_id (sys_id string); optional include_details (bool, default True for full fields), limit/offset (int) for pagination.
    class ListCatalogItemVariablesParams(BaseModel):
        """Parameters for listing catalog item variables."""
    
        catalog_item_id: str = Field(..., description="The sys_id of the catalog item")
        include_details: bool = Field(True, description="Whether to include detailed information about each variable")
        limit: Optional[int] = Field(None, description="Maximum number of variables to return")
        offset: Optional[int] = Field(None, description="Offset for pagination")
  • Output schema: Pydantic model structuring the tool response with success flag, result message, variables list (from API), and count.
    class ListCatalogItemVariablesResponse(BaseModel):
        """Response from listing catalog item variables."""
    
        success: bool = Field(..., description="Whether the operation was successful")
        message: str = Field(..., description="Message describing the result")
        variables: List[Dict[str, Any]] = Field([], description="List of variables")
        count: int = Field(0, description="Total number of variables found")
  • Imports the handler function (along with related catalog variable tools) into the top-level tools namespace, enabling its use in tool_utils.py and server.py.
    from servicenow_mcp.tools.catalog_variables import (
        create_catalog_item_variable,
        list_catalog_item_variables,
        update_catalog_item_variable,
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states the action ('list') without revealing any behavioral traits such as whether this is a read-only operation, what permissions might be required, whether results are paginated (though parameters suggest pagination), what format the output takes, or any rate limits. For a tool with no annotation coverage, this minimal description leaves significant behavioral questions unanswered.

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 extremely concise at just three words, with zero wasted language. It's front-loaded with the core action and resource. While this conciseness comes at the cost of completeness, the description itself is perfectly structured for its minimal content.

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 (4 parameters, no annotations, no output schema), the description is insufficiently complete. It doesn't explain what catalog item variables are, how they relate to other catalog tools, what the output format looks like, or any behavioral considerations. The agent would need to rely heavily on the parameter schema alone, which is inadequate for proper tool selection and invocation.

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?

The schema description coverage is 100%, with all parameters well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline score is 3 even with no parameter information in the description, which applies here.

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 'List catalog item variables' is a tautology that essentially restates the tool name. It specifies the verb 'list' and resource 'catalog item variables' but provides no additional context about what catalog items or variables are, or how this differs from sibling tools like 'list_catalog_items' or 'get_catalog_item'. The purpose is clear at a basic level but lacks differentiation from related tools.

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?

The description provides no guidance on when to use this tool versus alternatives. There are multiple sibling tools for catalog items (e.g., 'list_catalog_items', 'get_catalog_item', 'create_catalog_item_variable', 'update_catalog_item_variable'), but the description offers no indication of when this specific listing tool is appropriate versus those other operations. No prerequisites, exclusions, or alternatives are mentioned.

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