Skip to main content
Glama
dstreefkerk

ms-sentinel-mcp-server

by dstreefkerk

entra_id_get_user

Retrieve user information from Entra ID (Azure AD) using object ID, UPN, or email address to support identity management and security operations.

Instructions

Get a user from Entra ID (Azure AD) by object ID, UPN, or email address.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Implementation Reference

  • The EntraIDGetUserTool class provides the core handler logic for the 'entra_id_get_user' tool. It checks permissions, resolves user by UPN/email if needed, and fetches user details via Microsoft Graph API.
    class EntraIDGetUserTool(EntraIDToolBase):
        """
        Tool to get a user by object ID, UPN, or email address from Entra ID (Azure AD).
        Accepts any of: user_id, upn, or email.
        If user_id is not provided, resolves upn/email to user_id.
        """
    
        name = "entra_id_get_user"
        description = (
            "Get a user from Entra ID (Azure AD) by object ID, UPN, or email address."
        )
    
        async def run(self, ctx: Context, **kwargs):
            self.check_graph_permissions()
            client = GraphApiClient()
            user_id = self._extract_param(kwargs, "user_id")
            upn = self._extract_param(kwargs, "upn")
            email = self._extract_param(kwargs, "email")
    
            if not user_id:
                filter_str = None
                if upn:
                    filter_str = f"userPrincipalName eq '{upn}'"
                elif email:
                    filter_str = f"mail eq '{email}'"
                if filter_str:
                    url = f"{GRAPH_API_BASE}/users?$filter={filter_str}"
                    try:
                        # Use a unique name for this fetch to avoid duplicate function definition
                        def fetch_user_by_filter():
                            for page in client.call_azure_rest_api("GET", url):
                                users = page.get("value", [])
                                if users:
                                    return users[0]
                                return None
    
                        user = await run_in_thread(
                            fetch_user_by_filter, name="entra_id_get_user_lookup"
                        )
                        if user and user.get("id"):
                            user_id = user["id"]
                        else:
                            logger.error("No user found for filter: %s", filter_str)
                            raise Exception(f"No user found for filter: {filter_str}")
                    except requests.HTTPError as e:
                        logger.error("Graph API error during user lookup: %s", e)
                        if e.response.status_code == 403:
                            raise Exception(
                                "Permission denied: User.Read.All is required."
                            ) from e
                        raise
                else:
                    logger.error("Missing required parameter: user_id, upn, or email")
                    raise Exception("Missing required parameter: user_id, upn, or email")
    
            url = f"{GRAPH_API_BASE}/users/{user_id}"
            try:
    
                def fetch():
                    for page in client.call_azure_rest_api("GET", url):
                        return page
    
                return await run_in_thread(fetch, name="entra_id_get_user")
            except requests.HTTPError as e:
                logger.error("Graph API error during user fetch: %s", e)
                if e.response.status_code == 403:
                    raise Exception("Permission denied: User.Read.All is required.") from e
                raise
  • The register_tools function registers the EntraIDGetUserTool to the MCP server instance.
    def register_tools(mcp):
        """
        Register all Entra ID tools with the MCP server instance.
    
        Args:
            mcp: The MCP server instance.
        """
        EntraIDListUsersTool.register(mcp)
        EntraIDGetUserTool.register(mcp)
        EntraIDListGroupsTool.register(mcp)
        EntraIDGetGroupTool.register(mcp)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves a user but doesn't mention authentication requirements, rate limits, error handling (e.g., if the user isn't found), or what the output looks like (e.g., user details). For a read operation with zero annotation coverage, this is a significant gap in transparency.

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 that front-loads the core purpose ('Get a user from Entra ID') and adds necessary detail ('by object ID, UPN, or email address'). There is no wasted verbiage, making it highly concise and well-structured for quick understanding.

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?

Given the tool's complexity (a user lookup in Entra ID), lack of annotations, no output schema, and poor parameter documentation (0% schema coverage with minimal description help), the description is incomplete. It doesn't cover authentication, output format, error cases, or parameter usage, leaving critical gaps for an AI agent to use it effectively.

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?

The input schema has 1 parameter ('kwargs') with 0% description coverage, meaning the schema provides no details about what this parameter should contain. The description mentions lookup methods ('by object ID, UPN, or email address') but doesn't explain how to specify these in 'kwargs' (e.g., format, syntax, or examples). This fails to compensate for the schema's lack of documentation.

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 ('Get') and resource ('a user from Entra ID (Azure AD)'), specifying the action and target. It distinguishes from siblings like 'entra_id_list_users' by focusing on retrieving a single user rather than listing multiple. However, it doesn't explicitly differentiate from 'entra_id_get_group' 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 like 'entra_id_list_users' for multiple users or other lookup methods. It mentions lookup methods ('by object ID, UPN, or email address') but doesn't specify when to choose one over another or any prerequisites. This leaves the agent without clear usage context.

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/dstreefkerk/ms-sentinel-mcp-server'

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