query_analytics
Analyze conversation history across timeline, tool stacks, problem resolution, cost breakdown, and comprehensive summaries to identify patterns and insights.
Instructions
Query analytics across timeline, tool stacks, problem resolution,
spend, and conversation summary.
Args:
view: What to analyze:
- "timeline" (default): What happened on a specific date
- "stacks": Technology stack patterns over time
- "problems": Debugging and problem resolution patterns
- "spend": Cost breakdown by source/time
- "summary": Comprehensive conversation analysis summary
date: Date in YYYY-MM-DD format (used with view="timeline")
month: YYYY-MM filter (used with stacks, problems, spend views)
source: Source filter for spend (e.g., "openrouter", "claude_code")
limit: Max results (default 15)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| view | No | timeline | |
| date | No | ||
| month | No | ||
| source | No | ||
| limit | No |
Implementation Reference
- The `query_analytics` tool handler function implementation, which dispatches requests based on the `view` argument to specific analysis functions.
@mcp.tool() def query_analytics( view: str = "timeline", date: str = None, month: str = None, source: str = None, limit: int = 15, ) -> str: """ Query analytics across timeline, tool stacks, problem resolution, spend, and conversation summary. Args: view: What to analyze: - "timeline" (default): What happened on a specific date - "stacks": Technology stack patterns over time - "problems": Debugging and problem resolution patterns - "spend": Cost breakdown by source/time - "summary": Comprehensive conversation analysis summary date: Date in YYYY-MM-DD format (used with view="timeline") month: YYYY-MM filter (used with stacks, problems, spend views) source: Source filter for spend (e.g., "openrouter", "claude_code") limit: Max results (default 15) """ cfg = get_config() # Analytics data lives in data/interpretations/ and data/facts/ interp_dir = cfg.data_dir / "interpretations" facts_dir = cfg.data_dir / "facts" if view == "timeline": if not date: return "Please provide a date (YYYY-MM-DD) for timeline view." return _query_timeline(date, facts_dir, interp_dir) elif view == "stacks": return _query_tool_stacks(month, limit, interp_dir) elif view == "problems": return _query_problem_resolution(month, limit, interp_dir) elif view == "spend": return _query_spend(month, source, facts_dir) elif view == "summary": return _query_conversation_summary(interp_dir) else: return ( f"Unknown view: {view}. " "Use: timeline, stacks, problems, spend, summary" ) - brain_mcp/server/tools_analytics.py:18-19 (registration)Registration of the `query_analytics` tool within the MCP server framework.
def register(mcp): """Register analytics tools with the MCP server."""