Skip to main content
Glama
lucasoeth

mitmproxy-mcp MCP Server

by lucasoeth

list_flows

Retrieve detailed HTTP request/response data including headers, content previews, and metadata from a specific mitmproxy session to analyze network traffic.

Instructions

Retrieves detailed HTTP request/response data including headers, content (or structure preview for large JSON), and metadata from specified flows

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesThe ID of the session to list flows from

Implementation Reference

  • The primary handler function for the 'list_flows' tool. It processes the session_id argument, loads flows from the dump file using a helper function, iterates over HTTP flows to create summaries (index, method, URL, status), and returns a JSON-formatted list or appropriate error messages.
    async def list_flows(arguments: dict) -> list[types.TextContent]:
        """
        Lists HTTP flows from a mitmproxy dump file.
        """
        session_id = arguments.get("session_id")
        if not session_id:
            return [types.TextContent(type="text", text="Error: Missing session_id")]
    
        try:
            flows = await get_flows_from_dump(session_id)
    
            flow_list = []
            for i, flow in enumerate(flows):
                if flow.type == "http":
                    request = flow.request
                    response = flow.response
                    flow_info = {
                        "index": i,
                        "method": request.method,
                        "url": request.url,
                        "status": response.status_code if response else None
                    }
                    flow_list.append(flow_info)
    
            return [types.TextContent(type="text", text=json.dumps(flow_list, indent=2))]
        except FileNotFoundError:
            return [types.TextContent(type="text", text="Error: Session not found")]
        except Exception as e:
            return [types.TextContent(type="text", text=f"Error reading flows: {str(e)}")]
  • Registration of the 'list_flows' tool in the @server.list_tools() handler, defining the tool name, description, and input JSON schema requiring 'session_id'.
    types.Tool(
        name="list_flows",
        description="Retrieves detailed HTTP request/response data including headers, content (or structure preview for large JSON), and metadata from specified flows",
        inputSchema={
            "type": "object",
            "properties": {
                "session_id": {
                    "type": "string",
                    "description": "The ID of the session to list flows from"
                }
            },
            "required": ["session_id"]
        }
    ),
  • Dispatch logic in the @server.call_tool() handler that routes calls to the 'list_flows' function when the tool name matches.
    if name == "list_flows":
        return await list_flows(arguments)
  • Supporting helper function called by the list_flows handler to load and cache mitmproxy flows from the session dump file using mitmproxy's FlowReader.
    async def get_flows_from_dump(session_id: str) -> list:
        """
        Retrieves flows from the dump file, using the cache if available.
        """
        dump_file = os.path.join(DUMP_DIR, f"{session_id}.dump")
        if not os.path.exists(dump_file):
            raise FileNotFoundError("Session not found")
    
        if session_id in FLOW_CACHE:
            return FLOW_CACHE[session_id]
        else:
            with open(dump_file, "rb") as f:
                reader = io.FlowReader(f)
                flows = list(reader.stream())
            FLOW_CACHE[session_id] = flows
            return flows
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions retrieving 'detailed HTTP request/response data' including headers, content, and metadata, but lacks critical behavioral details such as whether this is a read-only operation, potential rate limits, error handling, or how large JSON is handled ('structure preview'). This leaves significant gaps for an agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the key action ('Retrieves detailed HTTP request/response data'). It could be slightly more structured by separating scope details, but it avoids unnecessary fluff and earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It hints at behavioral aspects like handling 'large JSON' but doesn't fully explain return values, error cases, or operational constraints. For a tool with no structured support, more detail is needed to guide an agent effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'session_id' adequately. The description adds no additional meaning or context about the parameter beyond what the schema provides, such as format examples or how to obtain a session_id. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Retrieves') and resource ('detailed HTTP request/response data from specified flows'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_flow_details' or 'analyze_protection', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'get_flow_details' or 'analyze_protection'. The description mentions retrieving data from 'specified flows' but doesn't clarify prerequisites, such as needing a valid session_id or how this differs from other flow-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/lucasoeth/mitmproxy-mcp'

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