Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

get_user

Retrieve user details from ServiceNow by providing user ID, username, or email address to access specific user information.

Instructions

Get a specific user in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoUser ID or sys_id
user_nameNoUsername of the user
emailNoEmail address of the user

Implementation Reference

  • The core handler function for the 'get_user' tool. It constructs a query to the ServiceNow 'sys_user' table API endpoint using the provided user_id, user_name, or email, retrieves the user details, and returns a success dict with the user data or an error message.
    def get_user(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: GetUserParams,
    ) -> dict:
        """
        Get a user from ServiceNow.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for getting the user.
    
        Returns:
            Dictionary containing user details.
        """
        api_url = f"{config.api_url}/table/sys_user"
        query_params = {}
    
        # Build query parameters
        if params.user_id:
            query_params["sysparm_query"] = f"sys_id={params.user_id}"
        elif params.user_name:
            query_params["sysparm_query"] = f"user_name={params.user_name}"
        elif params.email:
            query_params["sysparm_query"] = f"email={params.email}"
        else:
            return {"success": False, "message": "At least one search parameter is required"}
    
        query_params["sysparm_limit"] = "1"
        query_params["sysparm_display_value"] = "true"
    
        # 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", [])
            if not result:
                return {"success": False, "message": "User not found"}
    
            return {"success": True, "message": "User found", "user": result[0]}
    
        except requests.RequestException as e:
            logger.error(f"Failed to get user: {e}")
            return {"success": False, "message": f"Failed to get user: {str(e)}"}
  • Pydantic BaseModel defining the input schema for the 'get_user' tool, with optional fields for user_id, user_name, or email.
    class GetUserParams(BaseModel):
        """Parameters for getting a user."""
    
        user_id: Optional[str] = Field(None, description="User ID or sys_id")
        user_name: Optional[str] = Field(None, description="Username of the user")
        email: Optional[str] = Field(None, description="Email address of the user")
  • Explicit registration of the 'get_user' tool in the central tool_definitions dictionary used by the MCP server. Maps the tool name to its aliased implementation (get_user_tool), input schema (GetUserParams), return type hint, description, and serialization method ('raw_dict').
    "get_user": (
        get_user_tool,
        GetUserParams,
        Dict[str, Any],  # Expects dict
        "Get a specific user in ServiceNow",
        "raw_dict",
    ),
  • Import of get_user from user_tools module into the tools package namespace, making it available for export and use in tool_utils.py.
    from servicenow_mcp.tools.user_tools import (
        create_user,
        update_user,
        get_user,
  • Inclusion of 'get_user' in the __all__ list, explicitly exporting it from the tools package for use by the server.
    "get_user",
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 but offers minimal information. It implies a read operation ('Get') but doesn't specify authentication requirements, rate limits, error handling, or return format. This leaves significant gaps for a tool that likely interacts with a user database.

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 no wasted words. It's front-loaded with the core purpose and appropriately sized for a simple retrieval tool.

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?

For a tool with no annotations and no output schema, the description is inadequate. It doesn't explain what information is returned about the user, how to handle multiple matching parameters, or error conditions. The context signals indicate complexity (3 parameters) that isn't addressed in the description.

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 input schema has 100% description coverage, clearly documenting all three parameters (user_id, user_name, email) with their purposes. The description adds no additional parameter information beyond what the schema provides, which is acceptable given the high schema coverage but doesn't enhance understanding.

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 action ('Get') and resource ('a specific user in ServiceNow'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'list_users' or 'create_user' beyond the basic verb, which prevents a perfect score.

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. It doesn't mention sibling tools like 'list_users' for multiple users or 'create_user' for new users, nor does it specify prerequisites or constraints for usage.

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