Skip to main content
Glama
heizaheiza

Charles MCP Server

by heizaheiza

stop_live_capture

Stop active network traffic capture in Charles Proxy and optionally save filtered data for analysis. Use this tool to end monitoring sessions and preserve relevant traffic snapshots.

Instructions

Stop an active live capture and optionally persist the filtered snapshot. Only status='stopped' means the capture is fully closed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
capture_idYes
persistNo

Implementation Reference

  • The MCP tool handler for 'stop_live_capture' which delegates the request to the live service.
    async def stop_live_capture(
        ctx: ToolContext,
        capture_id: str,
        persist: bool = True,
    ) -> StopLiveCaptureResult:
        """Stop an active live capture and optionally persist the filtered snapshot.
        Only status='stopped' means the capture is fully closed."""
        deps = get_tool_dependencies(ctx)
        try:
            return await deps.live_service.stop(capture_id, persist=persist)
        except Exception as exc:
            raise ValueError(str(exc)) from exc
  • The actual service logic that executes the stop operation for live captures.
    ) -> StopLiveCaptureResult:
        capture = self.live_manager.require(capture_id)
        raw_items = await self.export_current_session()
        self.live_manager.read(
            capture_id,
            raw_items,
            cursor=capture.cursor,
            limit=max(len(raw_items), 1),
            advance=True,
        )
    
        if capture.managed:
            stop_succeeded, stop_warnings, stop_error = await self._stop_recording_with_retry()
            capture.warnings = list(dict.fromkeys(capture.warnings + stop_warnings))
            if not stop_succeeded:
                return StopLiveCaptureResult(
                    capture_id=capture.capture_id,
                    status="stop_failed",
                    persisted_path=None,
                    total_items=len(capture.items),
                    recoverable=True,
                    active_capture_preserved=True,
                    error=stop_error or "failed to stop Charles recording",
                    warnings=list(capture.warnings),
                )
    
        persisted_path: str | None = None
        if persist:
            client = await self._get_shared_client()
            persisted_path = self.save_capture_items(
                client.get_full_save_path(),
                capture.items,
            )
    
        stopped = self.live_manager.close(capture_id)
        await self._close_shared_client()
        return StopLiveCaptureResult(
            capture_id=stopped.capture_id,
  • The Pydantic model for the result returned by stop_live_capture.
    class StopLiveCaptureResult(BaseModel):
        """Stop a live capture session."""
    
        capture_id: str
        status: Literal["stopped", "stop_failed"]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/heizaheiza/Charles-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server