Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

add_group_members

Add multiple users to a ServiceNow group by specifying the group ID and list of user sys_ids or usernames. Streamline group management through the ServiceNow MCP Server.

Instructions

Add members to an existing group in ServiceNow

Input Schema

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

Implementation Reference

  • Implements the core logic for adding members to a ServiceNow group by creating entries in the sys_user_grmember table, resolving usernames to sys_ids using get_user.
    def add_group_members( config: ServerConfig, auth_manager: AuthManager, params: AddGroupMembersParams, ) -> GroupResponse: """ Add members to a group in ServiceNow. Args: config: Server configuration. auth_manager: Authentication manager. params: Parameters for adding members to the group. Returns: Response with the result of the operation. """ api_url = f"{config.api_url}/table/sys_user_grmember" 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 # Create group membership data = { "group": params.group_id, "user": user_id, } try: response = requests.post( api_url, json=data, headers=auth_manager.get_headers(), timeout=config.timeout, ) response.raise_for_status() except requests.RequestException as e: logger.error(f"Failed to add member '{member}' to group: {e}") success = False failed_members.append(member) if failed_members: message = f"Some members could not be added to the group: {', '.join(failed_members)}" else: message = "All members added to the group successfully" return GroupResponse( success=success, message=message, group_id=params.group_id, )
  • Pydantic model defining the input parameters for the add_group_members tool: group_id and list of members.
    class AddGroupMembersParams(BaseModel): """Parameters for adding members to 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 add as members" )
  • Registers the add_group_members tool in the central tool_definitions dictionary used by the MCP server, mapping name to function, params model, description, etc.
    "add_group_members": ( add_group_members_tool, AddGroupMembersParams, Dict[str, Any], # Expects dict "Add members to an existing group in ServiceNow", "raw_dict", ),
  • Re-exports the add_group_members function from user_tools for convenient access across the tools module.
    add_group_members,

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