mcp-security icon indicating copy to clipboard operation
mcp-security copied to clipboard

[secops-mcp] Add get_stats tool for Chronicle YARA-L 2.0 UDM stats and aggregation queries

Open dandye opened this issue 3 weeks ago • 0 comments

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

  1. Add get_stats in server/secops/secops_mcp/tools/stats.py and export it in server/secops/secops_mcp/tools/__init__.py.
  2. Parse start_time, end_time, and hours_back via secops_mcp.utils.parse_time_range, forward the query and options to chronicle.get_stats(...), and return {"columns": [...], "rows": [...], "total_rows": ...}, or {"error": ..., "columns": [], "rows": [], "total_rows": 0} on date-parsing or API errors.
  3. Annotate project_id, customer_id, and region as Optional[str] = None so FastMCP generates nullable JSON Schema types.
  4. Document Chronicle SIEM YARA-L 2.0 statistical query syntax with filtering, match:, outcome:, order:, and limit: sections. Ensure example outputs reflect that Chronicle :udmSearch strips the leading $ from outcome: variable names in returned column headers, such as "user_count_by_ip" rather than "$user_count_by_ip", and avoid advertising legacy max_events or case_insensitive parameters as active controls when YARA-L 2.0 requires nocase in the query text.
  5. Use lazy %s pattern strings in logger.info and logger.error(..., exc_info=True) calls per Google Python Style Guide Section 3.10.1.
  6. Add unit tests in server/secops/tests/test_secops_tools_unit.py and integration tests in server/secops/tests/test_secops_mcp.py using valid YARA-L 2.0 match: and outcome: query syntax rather than pipe | stats syntax.

dandye avatar Nov 06 '26 19:11 dandye