analyze_recorded_traffic
Analyze saved network traffic recordings to identify patterns, filter by criteria like host or status, and generate structured summaries for debugging and monitoring.
Instructions
Analyze a saved recording snapshot with compact summaries. Returns structured TrafficSummary items with matched_fields and match_reasons. Use get_traffic_entry_detail to drill down into a specific entry_id afterwards.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recording_path | No | ||
| preset | No | api_focus | |
| host_contains | No | ||
| path_contains | No | ||
| method_in | No | ||
| status_in | No | ||
| resource_class_in | No | ||
| min_priority_score | No | ||
| request_header_name | No | ||
| request_header_value_contains | No | ||
| response_header_name | No | ||
| response_header_value_contains | No | ||
| request_content_type | No | ||
| response_content_type | No | ||
| request_body_contains | No | ||
| response_body_contains | No | ||
| request_json_query | No | ||
| response_json_query | No | ||
| include_body_preview | No | ||
| max_items | No | ||
| max_preview_chars | No | ||
| max_headers_per_side | No | ||
| scan_limit | No |
Implementation Reference
- The core logic for analyze_recorded_traffic, which handles orchestration of history snapshots and building the query result.
async def analyze_recorded_traffic( self, *, recording_path: str | None, query: TrafficQuery, ) -> TrafficQueryResult: try: prepared = await self.prepare_capture( source="history", query=query, recording_path=recording_path, advance=False, ) except FileNotFoundError: return TrafficQueryResult( source="history", items=[], total_items=0, scanned_count=0, matched_count=0, filtered_out_count=0, filtered_out_by_class={}, warnings=["no_saved_recordings"], ) return self.build_query_result(prepared=prepared, query=query, include_items=True) - charles_mcp/tools/history.py:36-64 (handler)The tool registration and function handler for analyze_recorded_traffic within the MCP tool definitions.
async def analyze_recorded_traffic( ctx: ToolContext, recording_path: Optional[str] = None, preset: TrafficPreset = "api_focus", host_contains: Optional[str] = None, path_contains: Optional[str] = None, method_in: Optional[list[str]] = None, status_in: Optional[list[int]] = None, resource_class_in: Optional[list[str]] = None, min_priority_score: Optional[int] = None, request_header_name: Optional[str] = None, request_header_value_contains: Optional[str] = None, response_header_name: Optional[str] = None, response_header_value_contains: Optional[str] = None, request_content_type: Optional[str] = None, response_content_type: Optional[str] = None, request_body_contains: Optional[str] = None, response_body_contains: Optional[str] = None, request_json_query: Optional[str] = None, response_json_query: Optional[str] = None, include_body_preview: bool = True, max_items: int = 10, max_preview_chars: int = 128, max_headers_per_side: int = 6, scan_limit: int = 500, ) -> TrafficQueryResult: """Analyze a saved recording snapshot with compact summaries. Returns structured TrafficSummary items with matched_fields and match_reasons. Use get_traffic_entry_detail to drill down into a specific entry_id afterwards."""