Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

remove_group_members

Remove users from ServiceNow groups to manage access permissions and maintain accurate team membership records.

Instructions

Remove members from an existing group in ServiceNow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_idYesGroup ID or sys_id
membersYesList of user sys_ids or usernames to remove as members

Implementation Reference

  • The core handler function that executes the tool: resolves usernames to sys_ids, queries sys_user_grmember table for memberships, and deletes the records to remove members from the group.
    def remove_group_members(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: RemoveGroupMembersParams,
    ) -> GroupResponse:
        """
        Remove members from a group in ServiceNow.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for removing members from the group.
    
        Returns:
            Response with the result of the operation.
        """
        success = True
        failed_members = []
    
        for member in params.members:
            # Get user ID if username is provided
            user_id = member
            if not member.startswith("sys_id:"):
                user = get_user(config, auth_manager, GetUserParams(user_name=member))
                if not user.get("success"):
                    user = get_user(config, auth_manager, GetUserParams(email=member))
    
                if user.get("success"):
                    user_id = user.get("user", {}).get("sys_id")
                else:
                    success = False
                    failed_members.append(member)
                    continue
    
            # Find and delete the group membership
            api_url = f"{config.api_url}/table/sys_user_grmember"
            query_params = {
                "sysparm_query": f"group={params.group_id}^user={user_id}",
                "sysparm_limit": "1",
            }
    
            try:
                # First find the membership record
                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:
                    success = False
                    failed_members.append(member)
                    continue
    
                # Then delete the membership record
                membership_id = result[0].get("sys_id")
                delete_url = f"{api_url}/{membership_id}"
    
                response = requests.delete(
                    delete_url,
                    headers=auth_manager.get_headers(),
                    timeout=config.timeout,
                )
                response.raise_for_status()
    
            except requests.RequestException as e:
                logger.error(f"Failed to remove member '{member}' from group: {e}")
                success = False
                failed_members.append(member)
    
        if failed_members:
            message = f"Some members could not be removed from the group: {', '.join(failed_members)}"
        else:
            message = "All members removed from the group successfully"
    
        return GroupResponse(
            success=success,
            message=message,
            group_id=params.group_id,
        )
  • Pydantic BaseModel defining the input schema for the tool parameters: group_id (str) and members (list of str).
    class RemoveGroupMembersParams(BaseModel):
        """Parameters for removing members from a group."""
    
        group_id: str = Field(..., description="Group ID or sys_id")
        members: List[str] = Field(
            ..., description="List of user sys_ids or usernames to remove as members"
        )
  • Registration of the tool in the MCP server's tool definitions dictionary, mapping name to (handler function alias, params schema, return type, description, serialization method).
    "remove_group_members": (
        remove_group_members_tool,
        RemoveGroupMembersParams,
        Dict[str, Any],  # Expects dict
        "Remove members from an existing group in ServiceNow",
        "raw_dict",
    ),
  • Export/import of the remove_group_members handler function into the tools package namespace for use in MCP registration.
    from servicenow_mcp.tools.user_tools import (
        create_user,
        update_user,
        get_user,
        list_users,
        create_group,
        update_group,
        add_group_members,
        remove_group_members,
        list_groups,
    )
  • Import alias of the handler function as remove_group_members_tool for use in tool registration.
        remove_group_members as remove_group_members_tool,
    )
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. While 'Remove' implies a destructive mutation, the description doesn't address important behavioral aspects: whether this operation is reversible, what permissions are required, whether it validates member existence before removal, what happens with invalid member IDs, or what the response looks like. This is inadequate for a mutation tool with zero annotation coverage.

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 straightforward operation and front-loads the essential information (action + target). Every word earns its place in this concise formulation.

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 destructive mutation tool with no annotations and no output schema, the description is incomplete. It doesn't address behavioral implications, error conditions, permissions, or response format. While the schema covers parameters adequately, the overall context for safe and effective tool invocation is insufficient given the tool's complexity and potential impact.

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%, with both parameters well-documented in the schema itself (group_id as 'Group ID or sys_id', members as 'List of user sys_ids or usernames to remove'). The description adds no additional parameter information beyond what's already in the structured schema, so the baseline score of 3 is appropriate when the schema does the heavy lifting.

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 ('Remove members') and target resource ('from an existing group in ServiceNow'), providing specific verb+resource information. However, it doesn't explicitly distinguish this tool from its sibling 'add_group_members' beyond the obvious verb difference, missing an opportunity to clarify the relationship between these complementary operations.

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 prerequisites (e.g., group must exist, members must be current members), doesn't reference the sibling 'add_group_members' tool, and offers no context about appropriate use cases or constraints beyond the basic operation stated.

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/vparlapalli490/MCP'

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