Repository navigation
Description
Summary
Self-play testing of the MCP API revealed a consistent pattern: aggregate endpoints provide useful summaries, but LLMs often can't drill down to actionable information without direct database access. This RFC consolidates findings and proposes solutions.
Context
- Discovered during: Self-play testing session where Claude used only MCP tools (no DB access) to investigate insights
- Method: 14 experiments testing different API entry points and drill-down paths
- Documented in: CLAUDE.md "Design Philosophy" section (Principles 2 & 3)
Problem Statement
The API follows RFC #17's "don't over-distill" principle well - it surfaces raw signals. But it violates a complementary principle: every aggregate should have a drill-down path.
Example failure mode:
analyze_failures()→ "821 Bash errors"- LLM asks: "Which commands are failing?"
- Dead end - no way to see failing commands without DB access
Findings Summary
Issues Already Created
| Issue | Problem | Impact |
|---|---|---|
| #45 | analyze_failures shows counts, not failing commands |
Can't fix errors |
| #46 | sample_sequences rejects MCP tool names (underscores) |
Can't analyze MCP workflows |
| #47 | tool_result events missing tool_name correlation |
Can't see what tool caused error |
| #48 | get_permission_gaps doesn't match glob patterns |
Stale recommendations |
New Gaps Identified
| Aggregate Endpoint | Missing Drill-Down | Proposed Solution |
|---|---|---|
get_agent_activity |
Agent context (what task, parent session) | Add get_agent_events(agent_id) or include task context |
classify_sessions |
Why session is "debugging" | Include top error tools/commands in classification |
analyze_failures |
Which specific commands failed | Add error_examples with command breakdown |
What Works Well
| Entry Point | Drill-Down | Notes |
|---|---|---|
search_messages |
→ get_session_events(session_id) |
✅ Full path works |
find_related_sessions |
Shows shared files | ✅ Actionable |
get_file_activity |
N/A | ✅ Already actionable |
get_handoff_context |
N/A | ✅ Already actionable |
detect_parallel_sessions |
Shows overlapping sessions | ✅ Useful |
Proposed Solutions
1. Enrich analyze_failures (fixes #45)
Add error_examples to show top failing commands:
{
"errors_by_tool": [{"tool": "Bash", "errors": 821}],
"error_examples": {
"Bash": [
{"command": "cargo test", "count": 89, "sample_error": "test failed"},
{"command": "grep", "count": 150, "sample_error": "exit code 1"}
]
}
}2. Correlate tool_result with tool_use (fixes #47)
Either at ingest time or query time, link tool_result events to their preceding tool_use:
# Current (broken)
{"entry_type": "tool_result", "tool_name": null, "is_error": true}
# Proposed
{"entry_type": "tool_result", "tool_name": "Bash", "command": "cargo test", "is_error": true}3. Add agent drill-down
Option A: New endpoint get_agent_events(agent_id)
Option B: Include agent context in get_agent_activity:
{
"agent_id": "a8f24f8",
"parent_session_id": "dce71971-...",
"task_description": "Explore codebase for...", # from Task tool invocation
"top_tools": [...]
}4. Fix pattern matching (fixes #46, #48)
- sample_sequences rejects MCP tool names with underscores #46: Allow underscores in
sample_sequencestool name validation - Permission gap detection doesn't match glob patterns correctly #48: Use
fnmatchfor glob pattern matching in permission gaps
5. Enrich classify_sessions
Include WHY a session was classified as debugging:
{
"category": "debugging",
"confidence": 0.03,
"classification_factors": {
"error_rate": 0.05,
"top_failing_tools": ["Bash", "Edit"],
"rework_count": 12
}
}Implementation Priority
- High: Add error examples to analyze_failures output #45 (analyze_failures) - most common drill-down failure
- High: get_session_events: tool_result events missing tool_name correlation #47 (tool_result correlation) - affects multiple drill-down paths
- Medium: Permission gap detection doesn't match glob patterns correctly #48 (glob matching) - causes stale recommendations
- Medium: Agent drill-down - new RFC RFC: Close data coverage gaps in session analytics ingestion #41 feature needs completion
- Low: sample_sequences rejects MCP tool names with underscores #46 (MCP tool names) - edge case but easy fix
Validation
After implementing, re-run self-play testing:
- Start from aggregate insight
- Use only MCP tools
- Reach actionable conclusion
- If blocked, solution is incomplete
Related
- RFC RFC: LLM-Powered Analysis and Cross-Session Visibility #17: Don't over-distill
- RFC RFC: Close data coverage gaps in session analytics ingestion #41: Agent tracking
- Issues: Add error examples to analyze_failures output #45, sample_sequences rejects MCP tool names with underscores #46, get_session_events: tool_result events missing tool_name correlation #47, Permission gap detection doesn't match glob patterns correctly #48
- CLAUDE.md: Design Philosophy section
Activity
feat: Close drill-down gaps in MCP API (RFC #49)
feat: Close drill-down gaps in MCP API (RFC #49) (#52)