Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

list_catalog_item_variables

Retrieve and manage variables associated with a specific ServiceNow catalog item, including details and pagination options, to streamline catalog item configuration and automation.

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 logic: queries ServiceNow API for variables on a catalog item with optional pagination and details.
    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)}", )
  • Pydantic model defining the input schema/parameters for the tool.
    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")
  • Pydantic model defining the output/response schema for the tool.
    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")
  • Tool registration in the central get_tool_definitions() function mapping name to handler, input model, description for MCP server.
    "list_catalog_item_variables": ( list_catalog_item_variables_tool, ListCatalogItemVariablesParams, Dict[str, Any], # Expects dict "List catalog item variables", "dict", # Tool returns Pydantic model ),
  • Imports the tool functions into the tools package namespace for exposure to the server.
    from servicenow_mcp.tools.catalog_variables import ( create_catalog_item_variable, list_catalog_item_variables, update_catalog_item_variable, )

Other Tools

Related 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