Skip to main content
Glama
echelon-ai-labs

ServiceNow MCP Server

list_users

Retrieve and filter user data from ServiceNow instances. Filter by active status, department, or search query, and manage results with pagination limits and offsets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The handler function that implements the list_users tool logic, querying the sys_user table with pagination, filters for active, department, and search query.
    def list_users(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: ListUsersParams,
    ) -> dict:
        """
        List users from ServiceNow.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for listing users.
    
        Returns:
            Dictionary containing list of users.
        """
        api_url = f"{config.api_url}/table/sys_user"
        query_params = {
            "sysparm_limit": str(params.limit),
            "sysparm_offset": str(params.offset),
            "sysparm_display_value": "true",
        }
    
        # Build query
        query_parts = []
        if params.active is not None:
            query_parts.append(f"active={str(params.active).lower()}")
        if params.department:
            query_parts.append(f"department={params.department}")
        if params.query:
            query_parts.append(
                f"^nameLIKE{params.query}^ORuser_nameLIKE{params.query}^ORemailLIKE{params.query}"
            )
    
        if query_parts:
            query_params["sysparm_query"] = "^".join(query_parts)
    
        # 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 {
                "success": True,
                "message": f"Found {len(result)} users",
                "users": result,
                "count": len(result),
            }
    
        except requests.RequestException as e:
            logger.error(f"Failed to list users: {e}")
            return {"success": False, "message": f"Failed to list users: {str(e)}"}
  • Pydantic BaseModel defining the input parameters for the list_users tool.
    class ListUsersParams(BaseModel):
        """Parameters for listing users."""
    
        limit: int = Field(10, description="Maximum number of users to return")
        offset: int = Field(0, description="Offset for pagination")
        active: Optional[bool] = Field(None, description="Filter by active status")
        department: Optional[str] = Field(None, description="Filter by department")
        query: Optional[str] = Field(
            None,
            description="Case-insensitive search term that matches against name, username, or email fields. Uses ServiceNow's LIKE operator for partial matching.",
        )
  • Registration of the list_users tool in the tool definitions dictionary, mapping name to function, params model, return type, description, and serialization method.
    "list_users": (
        list_users_tool,
        ListUsersParams,
        Dict[str, Any],  # Expects dict
        "List users in ServiceNow",
        "raw_dict",
    ),
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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?

Tool has no description.

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

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/echelon-ai-labs/servicenow-mcp'

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