Skip to main content
Glama
dstreefkerk

ms-sentinel-mcp-server

by dstreefkerk

sentinel_analytics_rule_list

List all analytics rules with key fields from Microsoft Sentinel to monitor and manage security detection logic.

Instructions

List all analytics rules with key fields

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Implementation Reference

  • The handler implementation for the 'sentinel_analytics_rule_list' tool. This is the MCPToolBase subclass containing the 'run' method that lists all Microsoft Sentinel analytics rules using the Azure SDK, extracts key fields like id, name, kind, displayName, severity, and enabled status, and returns a list of summaries or errors.
    class SentinelAnalyticsRuleListTool(MCPToolBase):
        """
        Tool to list all Microsoft Sentinel analytics rules with key fields.
    
        Returns a list of dictionaries, each containing rule summary fields or error
        details.
        """
    
        name = "sentinel_analytics_rule_list"
        description = "List all analytics rules with key fields"
    
        async def run(self, ctx: Context, **kwargs):
            """
            List all analytics rules with key fields.
    
            Supports both MCP server and direct (test) invocation.
    
            Args:
                ctx (Context): MCP context object.
                **kwargs: Additional keyword arguments (unused).
    
            Returns:
                list[dict]: List of rule summaries or error details.
            """
            logger = self.logger
            workspace, resource_group, subscription_id = self.get_azure_context(ctx)
            if not (workspace and resource_group and subscription_id):
                logger.error("Missing Azure Sentinel context for analytics rule listing.")
                return [{"error": "Missing Azure Sentinel context."}]
            rule_summaries = []
            errors = []
            try:
                client = self.get_securityinsight_client(subscription_id)
                rules = client.alert_rules.list(
                    resource_group_name=resource_group,
                    workspace_name=workspace,
                )
            except (HttpResponseError, ResourceNotFoundError) as e:
                logger.error("Azure SDK error listing analytics rules: %s", e)
                return [{"error": f"Azure SDK error: {str(e)}"}]
            except Exception as e:
                logger.error("Unexpected error listing analytics rules: %s", e)
                return [{"error": f"Unexpected error: {str(e)}"}]
    
            logged_first = False
            for rule in rules:
                try:
                    if not hasattr(rule, "name") or not hasattr(rule, "id"):
                        raise ValueError("Rule object missing required attributes")
                    name = getattr(rule, "name", None)
                    id_ = getattr(rule, "id", None)
                    kind = getattr(rule, "kind", None)
                    display_name = getattr(rule, "display_name", None) or getattr(
                        rule, "displayName", None
                    )
                    severity = getattr(rule, "severity", None)
                    enabled = getattr(rule, "enabled", None)
                    summary = {
                        "id": id_,
                        "name": name,
                        "kind": kind,
                        "displayName": display_name,
                        "severity": severity,
                        "enabled": enabled,
                    }
                    rule_summaries.append(summary)
                    if not logged_first:
                        logger.debug("First rule object: %s", rule)
                        logger.debug(
                            "First rule as_dict: %s",
                            getattr(rule, "as_dict", lambda: None)(),
                        )
                        logged_first = True
                except Exception as rule_exc:
                    logger.warning("Failed to process rule: %s", rule_exc)
                    errors.append(str(rule_exc))
                    continue
            if errors:
                rule_summaries.append(
                    {
                        "warning": f"{len(errors)} rules could not be processed",
                        "details": errors,
                    }
                )
            logger.info(
                "Retrieved %d analytics rule summaries (with %d errors).",
                len(rule_summaries),
                len(errors),
            )
            return rule_summaries
  • The registration function 'register_tools' that calls SentinelAnalyticsRuleListTool.register(mcp) at line 615 to register the tool with the MCP server.
    def register_tools(mcp):
        """
        Register all analytics tools with the given MCP server instance.
    
        Args:
            mcp: The MCP server instance to register tools with.
        """
        SentinelAnalyticsRuleListTool.register(mcp)
        SentinelAnalyticsRuleGetTool.register(mcp)
        SentinelAnalyticsRuleTemplatesListTool.register(mcp)
        SentinelAnalyticsRuleTemplateGetTool.register(mcp)
        SentinelAnalyticsRulesCountByTacticTool.register(mcp)
        SentinelAnalyticsRuleTemplatesCountByTacticTool.register(mcp)
        SentinelAnalyticsRulesCountByTechniqueTool.register(mcp)
        SentinelAnalyticsRuleTemplatesCountByTechniqueTool.register(mcp)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'key fields' but doesn't specify what those are, whether the list is paginated, if there are rate limits, or what permissions are required. This leaves significant gaps in understanding how the tool behaves beyond a simple list operation.

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 extremely concise with a single sentence that directly states the tool's purpose. It is front-loaded with no wasted words, making it easy to parse quickly, though this brevity contributes to gaps in other dimensions.

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 lack of annotations, 0% schema description coverage, no output schema, and multiple sibling tools, the description is insufficient. It doesn't explain parameters, return values, behavioral constraints, or differentiation from alternatives, leaving the agent with inadequate context for proper tool selection and invocation.

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, and the tool description provides no information about parameters. This leaves the parameter completely undocumented, failing to compensate for the lack of schema details and making it unclear how to use the tool effectively.

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 ('List all analytics rules') and specifies the scope ('with key fields'), which distinguishes it from generic list operations. However, it doesn't explicitly differentiate from sibling tools like 'sentinel_analytics_rule_templates_list' or 'sentinel_analytics_rule_get', leaving some ambiguity about when to use this specific tool versus alternatives.

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, such as 'sentinel_analytics_rule_get' for single rules or 'sentinel_analytics_rule_templates_list' for templates. It lacks context about prerequisites, filtering options, or typical use cases, offering only a basic statement of functionality.

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