Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

list_changesets

Retrieve and filter changesets from ServiceNow to track application updates, development progress, and deployment history with customizable parameters.

Instructions

List changesets from ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of records to return
offsetNoOffset to start from
stateNoFilter by state
applicationNoFilter by application
developerNoFilter by developer
timeframeNoFilter by timeframe (recent, last_week, last_month)
queryNoAdditional query string

Implementation Reference

  • The handler function that executes the tool logic: validates params, builds query for ServiceNow sys_update_set table, makes GET request, returns changesets list.
    def list_changesets(
        auth_manager: AuthManager,
        server_config: ServerConfig,
        params: Union[Dict[str, Any], ListChangesetsParams],
    ) -> Dict[str, Any]:
        """
        List changesets from ServiceNow.
    
        Args:
            auth_manager: The authentication manager.
            server_config: The server configuration.
            params: The parameters for listing changesets. Can be a dictionary or a ListChangesetsParams object.
    
        Returns:
            A list of changesets.
        """
        # Unwrap and validate parameters
        result = _unwrap_and_validate_params(params, ListChangesetsParams)
        
        if not result["success"]:
            return result
        
        validated_params = result["params"]
        
        # Get the instance URL
        instance_url = _get_instance_url(auth_manager, server_config)
        if not instance_url:
            return {
                "success": False,
                "message": "Cannot find instance_url in either server_config or auth_manager",
            }
        
        # Get the headers
        headers = _get_headers(auth_manager, server_config)
        if not headers:
            return {
                "success": False,
                "message": "Cannot find get_headers method in either auth_manager or server_config",
            }
        
        # Build query parameters
        query_params = {
            "sysparm_limit": validated_params.limit,
            "sysparm_offset": validated_params.offset,
        }
        
        # Build sysparm_query
        query_parts = []
        
        if validated_params.state:
            query_parts.append(f"state={validated_params.state}")
        
        if validated_params.application:
            query_parts.append(f"application={validated_params.application}")
        
        if validated_params.developer:
            query_parts.append(f"developer={validated_params.developer}")
        
        if validated_params.timeframe:
            if validated_params.timeframe == "recent":
                query_parts.append("sys_created_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfToday()")
            elif validated_params.timeframe == "last_week":
                query_parts.append("sys_created_onONLast week@javascript:gs.beginningOfLastWeek()@javascript:gs.endOfLastWeek()")
            elif validated_params.timeframe == "last_month":
                query_parts.append("sys_created_onONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()")
        
        if validated_params.query:
            query_parts.append(validated_params.query)
        
        if query_parts:
            query_params["sysparm_query"] = "^".join(query_parts)
        
        # Make the API request
        url = f"{instance_url}/api/now/table/sys_update_set"
        
        try:
            response = requests.get(url, params=query_params, headers=headers)
            response.raise_for_status()
            
            result = response.json()
            
            return {
                "success": True,
                "changesets": result.get("result", []),
                "count": len(result.get("result", [])),
            }
        except requests.exceptions.RequestException as e:
            logger.error(f"Error listing changesets: {e}")
            return {
                "success": False,
                "message": f"Error listing changesets: {str(e)}",
            }
  • Pydantic model for input schema/validation of list_changesets parameters.
    class ListChangesetsParams(BaseModel):
        """Parameters for listing changesets."""
    
        limit: Optional[int] = Field(10, description="Maximum number of records to return")
        offset: Optional[int] = Field(0, description="Offset to start from")
        state: Optional[str] = Field(None, description="Filter by state")
        application: Optional[str] = Field(None, description="Filter by application")
        developer: Optional[str] = Field(None, description="Filter by developer")
        timeframe: Optional[str] = Field(None, description="Filter by timeframe (recent, last_week, last_month)")
        query: Optional[str] = Field(None, description="Additional query string")
  • Registration of the tool in the central tool_definitions dictionary used by the MCP server, linking name to handler, schema, description, and serialization hint.
    "list_changesets": (
        list_changesets_tool,
        ListChangesetsParams,
        str,  # Expects JSON string
        "List changesets from ServiceNow",
        "json",  # Tool returns list/dict
    ),
  • Helper function used by the handler to validate and normalize input parameters against the Pydantic schema.
    def _unwrap_and_validate_params(
        params: Union[Dict[str, Any], BaseModel], 
        model_class: Type[T], 
        required_fields: Optional[List[str]] = None
    ) -> Dict[str, Any]:
        """
        Unwrap and validate parameters.
    
        Args:
            params: The parameters to unwrap and validate. Can be a dictionary or a Pydantic model.
            model_class: The Pydantic model class to validate against.
            required_fields: List of fields that must be present.
    
        Returns:
            A dictionary with success status and validated parameters or error message.
        """
        try:
            # Handle case where params is already a Pydantic model
            if isinstance(params, BaseModel):
                # If it's already the correct model class, use it directly
                if isinstance(params, model_class):
                    model_instance = params
                # Otherwise, convert to dict and create new instance
                else:
                    model_instance = model_class(**params.dict())
            # Handle dictionary case
            else:
                # Create model instance
                model_instance = model_class(**params)
            
            # Check required fields
            if required_fields:
                missing_fields = []
                for field in required_fields:
                    if getattr(model_instance, field, None) is None:
                        missing_fields.append(field)
                
                if missing_fields:
                    return {
                        "success": False,
                        "message": f"Missing required fields: {', '.join(missing_fields)}",
                    }
            
            return {
                "success": True,
                "params": model_instance,
            }
        except Exception as e:
            return {
                "success": False,
                "message": f"Invalid parameters: {str(e)}",
            }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'List changesets' implies a read-only operation, but the description doesn't mention pagination behavior (though parameters suggest it), authentication requirements, rate limits, or what format the results will be in. For a 7-parameter tool with no annotation coverage, this is insufficient behavioral context.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a list operation and front-loads the essential information. Every word earns its place in conveying the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a list operation with 7 well-documented parameters but no output schema and no annotations, the description is minimally adequate. It identifies the resource type but doesn't provide context about what changesets are, what fields they contain, or how results are structured. With no output schema, the description should ideally provide more return value context.

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%, so the schema fully documents all 7 parameters with clear descriptions. The description adds no parameter information beyond what's already in the structured schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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

Purpose4/5

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

The description clearly states the verb ('List') and resource ('changesets from ServiceNow'), making the purpose immediately understandable. It distinguishes this as a retrieval operation rather than creation or modification. However, it doesn't specifically differentiate from sibling tools like 'list_change_requests' or 'list_workflows' beyond the resource type.

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

Usage Guidelines2/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. With many sibling list tools (list_change_requests, list_workflows, etc.), there's no indication of when changesets specifically should be listed versus other ServiceNow entities. No prerequisites, exclusions, or complementary tools 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/JLKmach/servicenow-mcp'

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