Skip to main content
Glama
ZeroSOC

defender-xdr

by ZeroSOC

defender_run_hunting_query

Read-only

Run KQL advanced hunting queries across Defender XDR data to investigate threats across endpoint, identity, email, and cloud apps.

Instructions

Run an advanced hunting query (KQL) across Defender XDR data: endpoint, identity, email and cloud apps in one query. Tables include AlertInfo, AlertEvidence, DeviceProcessEvents, DeviceNetworkEvents, DeviceFileEvents, DeviceRegistryEvents, DeviceLogonEvents, DeviceEvents, IdentityLogonEvents, IdentityDirectoryEvents, EmailEvents, EmailUrlInfo, UrlClickEvents and CloudAppEvents. Which tables hold data depends on the tenant's licences: an empty result from a table that defender_get_capabilities reports as empty or not exposed is a visibility gap, not a finding and not a permissions problem. The sensor records no creation event for some processes (services started before it, some short-lived instances): a process absent from DeviceProcessEvents may still be there as the InitiatingProcessId and InitiatingProcessCreationTime of other events, so look there before concluding it did not run. Match a process by PID together with its creation time, never by PID alone. Timestamps are UTC. Data is limited to the last 30 days. Example: "DeviceProcessEvents | where Timestamp > ago(1d) | where FileName =~ 'powershell.exe' | project Timestamp, DeviceName, ProcessCommandLine | limit 50".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe Kusto Query Language (KQL) query. End exploratory queries with '| limit N' to keep results context-friendly.
timespanNoISO 8601 duration limiting how far back to query, e.g. 'P7D' or 'PT12H'. Defaults to the service maximum (30 days).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnlyHint and openWorldHint, and the description adds substantial behavioral caveats: process creation events may be missing for certain processes, PIDs must be matched with creation times, empty table results may be a licensing/visibility issue, timestamps are UTC, and data is capped at 30 days. This goes well beyond the annotations and meaningfully shapes how an agent should interpret results.

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 long, but not padded: every sentence conveys an operational fact an agent needs to avoid misinterpreting results or crafting invalid queries. The main purpose is front-loaded, and the caveats are organized logically, ending with a concrete example that illustrates the expected KQL shape.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a free-form KQL tool with no output schema, the description is unusually complete. It covers supported data domains, specific tables, licensing-dependent availability, timestamp conventions, retention limits, process-identification nuances, and a query example. An agent has enough context to invoke the tool safely and interpret its results sensibly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already covers both parameters fully, and the description goes further by listing valid tables, giving a concrete KQL example, warning about process-inference pitfalls, and clarifying the timespan default relative to the 30-day service maximum. This is a strong value-add beyond the schema fields.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Run an advanced hunting query (KQL) across Defender XDR data,' and enumerates the data domains and tables involved. This clearly differentiates it from the sibling tools, which are mostly structured getters for specific entities. No ambiguity remains about what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives strong practical usage context: it explains which tables exist, that availability depends on licences, that empty results can indicate a visibility gap rather than a finding or permissions issue, and that timestamps are UTC with a 30-day limit. It does not explicitly name alternative tools to prefer instead, but the tool is the only free-form KQL hunting interface among its siblings, so the when-to-use guidance is effectively clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools