mcp-security
mcp-security copied to clipboard
[secops-mcp] Add get_stats tool for Chronicle YARA-L 2.0 UDM stats and aggregation queries
Summary
server/secops exposes raw event search tools such as search_security_events and export_udm_search_csv, and the underlying secops Python SDK already provides chronicle.get_stats(...), yet secops-mcp does not register an MCP tool for statistical aggregation queries.
Adding a get_stats tool lets agents run Chronicle SIEM YARA-L 2.0 statistical queries with match: and outcome: sections over UDM events, returning compact columns, rows, and total_rows summaries for top-N rankings, distinct counts, rare-value frequency analysis, and time-bucketed roll-ups without fetching thousands of raw UDM events into context.
Backfilled to track the ongoing contribution in #246 by @jllangley.
Acceptance criteria
- Add
get_statsinserver/secops/secops_mcp/tools/stats.pyand export it inserver/secops/secops_mcp/tools/__init__.py. - Parse
start_time,end_time, andhours_backviasecops_mcp.utils.parse_time_range, forward the query and options tochronicle.get_stats(...), and return{"columns": [...], "rows": [...], "total_rows": ...}, or{"error": ..., "columns": [], "rows": [], "total_rows": 0}on date-parsing or API errors. - Annotate
project_id,customer_id, andregionasOptional[str] = Noneso FastMCP generates nullable JSON Schema types. - Document Chronicle SIEM YARA-L 2.0 statistical query syntax with filtering,
match:,outcome:,order:, andlimit:sections. Ensure example outputs reflect that Chronicle:udmSearchstrips the leading$fromoutcome:variable names in returned column headers, such as"user_count_by_ip"rather than"$user_count_by_ip", and avoid advertising legacymax_eventsorcase_insensitiveparameters as active controls when YARA-L 2.0 requiresnocasein the query text. - Use lazy
%spattern strings inlogger.infoandlogger.error(..., exc_info=True)calls per Google Python Style Guide Section 3.10.1. - Add unit tests in
server/secops/tests/test_secops_tools_unit.pyand integration tests inserver/secops/tests/test_secops_mcp.pyusing valid YARA-L 2.0match:andoutcome:query syntax rather than pipe| statssyntax.