Skip to main content
Glama
dstreefkerk

ms-sentinel-mcp-server

by dstreefkerk

sentinel_analytics_rule_templates_count_by_technique

Count Microsoft Sentinel analytics rule templates organized by MITRE ATT&CK techniques to identify security coverage gaps and prioritize threat detection development.

Instructions

Count Sentinel analytics rule templates by MITRE technique.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Implementation Reference

  • The handler implementation in the SentinelAnalyticsRuleTemplatesCountByTechniqueTool class, including the name definition and the run method that lists analytics rule templates, extracts techniques using the helper function, counts them by technique, and returns the results.
    class SentinelAnalyticsRuleTemplatesCountByTechniqueTool(MCPToolBase):
        """
        Count Sentinel analytics rule templates by MITRE technique.
        Extracts techniques from each template and returns a mapping of technique to
        count and template summaries.
        """
    
        name = "sentinel_analytics_rule_templates_count_by_technique"
        description = "Count Sentinel analytics rule templates by MITRE technique."
    
        async def run(self, ctx: Context, **kwargs):
            """
            Count analytics rule templates by technique.
            Returns a dict: {technique: {count: int, templates: [{id, display_name}]}}
            """
            logger = self.logger
            workspace, resource_group, subscription_id = self.get_azure_context(ctx)
            client = self.get_securityinsight_client(subscription_id)
            technique_map = {}
            try:
                templates = client.alert_rule_templates.list(resource_group, workspace)
                for template in templates:
                    template_dict = (
                        template.as_dict()
                        if hasattr(template, "as_dict")
                        else dict(template)
                    )
                    _, _, techniques = extract_tags_tactics_techniques_from_dict(
                        template_dict
                    )
                    display_name = (
                        template_dict.get("display_name")
                        or template_dict.get("displayName")
                        or template_dict.get("name")
                    )
                    for technique in techniques or ["Unknown"]:
                        tkey = technique.lower() or "unknown"
                        if tkey not in technique_map:
                            technique_map[tkey] = {"count": 0, "templates": []}
                        technique_map[tkey]["count"] += 1
                        technique_map[tkey]["templates"].append(
                            {
                                "id": template_dict.get("id"),
                                "display_name": display_name,
                            }
                        )
                return {
                    "valid": True,
                    "error": None,
                    "results": technique_map,
                    "errors": [],
                }
            except Exception as e:
                logger.error("Error in %s: %s", self.__class__.__name__, str(e))
                return {
                    "valid": False,
                    "error": str(e),
                    "results": None,
                    "errors": [str(e)],
                }
  • Registration of the SentinelAnalyticsRuleTemplatesCountByTechniqueTool with the MCP server instance.
    SentinelAnalyticsRuleTemplatesCountByTechniqueTool.register(mcp)
  • Helper utility function extract_tags_tactics_techniques_from_dict used by the tool handler to parse tactics and techniques from rule template dictionaries for counting.
    def extract_tags_tactics_techniques_from_dict(obj):
        """
          Extract tags, tactics, and techniques from an analytics rule/template dict.
    
        Args:
            obj (dict): Analytics rule or template dictionary.
    
        Returns:
            tuple: (tags, tactics, techniques)
                tags (list[dict]): All tags as {name, value} pairs.
                tactics (list[str]): List of tactics (from tags or legacy fields).
                techniques (list[str]): List of techniques (from tags or legacy fields).
    
        Extraction precedence:
            - Tactics/techniques: Prefer tags with name 'tactics'/'techniques'
              (case-insensitive, split on comma). Fallback to legacy fields.
            - Tags: All tags as {name, value} pairs (robust to SDK object, dict, or string).
        """
        tags = []
        tactics = []
        techniques = []
        raw_tags = obj.get("tags")
        if raw_tags:
            for tag in raw_tags:
                tag_name = None
                tag_value = None
                if isinstance(tag, dict):
                    tag_name = tag.get("name") or tag.get("Name")
                    tag_value = tag.get("value") or tag.get("Value")
                elif hasattr(tag, "name") and hasattr(tag, "value"):
                    tag_name = getattr(tag, "name", None)
                    tag_value = getattr(tag, "value", None)
                elif isinstance(tag, str):
                    tag_name = tag
                    tag_value = None
                else:
                    try:
                        tag_name = str(tag)
                    except Exception:
                        continue
                if tag_name is not None:
                    tags.append({"name": tag_name, "value": tag_value})
        for tag in tags:
            if tag["name"] and isinstance(tag["name"], str):
                if tag["name"].lower() == "tactics" and tag["value"]:
                    tactics += [t.strip() for t in tag["value"].split(",") if t.strip()]
                elif tag["name"].lower() == "techniques" and tag["value"]:
                    techniques += [t.strip() for t in tag["value"].split(",") if t.strip()]
        legacy_tactics = obj.get("tactics")
        if legacy_tactics:
            tactics += [
                t.strip() for t in legacy_tactics if isinstance(t, str) and t.strip()
            ]
        legacy_techniques = obj.get("techniques")
        if legacy_techniques:
            techniques += [
                t.strip() for t in legacy_techniques if isinstance(t, str) and t.strip()
            ]
        tactics = list(dict.fromkeys([t for t in tactics if t]))
        techniques = list(dict.fromkeys([t for t in techniques if t]))
        return tags, tactics, techniques
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool counts items, implying a read-only operation, but doesn't disclose behavioral traits such as authentication needs, rate limits, output format, or whether it's a safe query. The description is minimal and lacks essential operational context.

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 waste. It is appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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 has no annotations, no output schema, and low schema coverage (0%), the description is incomplete. It doesn't provide enough context for an agent to understand how to use the tool effectively, such as parameter usage, return values, or behavioral constraints, making it inadequate for the tool's complexity.

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?

Schema description coverage is 0%, with one required parameter 'kwargs' of type string. The description adds no meaning beyond the schema—it doesn't explain what 'kwargs' represents, its expected format, or how it relates to counting by MITRE technique. This fails to compensate for the low schema coverage.

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 ('Count') and resource ('Sentinel analytics rule templates by MITRE technique'), providing specific verb+resource. However, it doesn't distinguish itself from the sibling tool 'sentinel_analytics_rules_count_by_technique' which counts rules rather than rule templates, missing explicit differentiation.

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?

No guidance is provided on when to use this tool versus alternatives like 'sentinel_analytics_rule_templates_list' or 'sentinel_analytics_rules_count_by_technique'. The description lacks context about prerequisites, exclusions, or comparisons to sibling tools.

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