Skip to main content
Glama
charles-mcp

charles-mcp

by Sn0w0day

charles-mcp

CI License: MIT Node

An MCP server that gives AI agents access to Charles Proxy sessions: browse, filter, inspect, search, export and control Charles — all from your agent.

中文文档

Why

Charles is excellent at capturing traffic, but reading a large session by hand is slow. This server turns the current Charles session into a queryable local index and exposes it as MCP tools, so an agent can answer questions like:

  • "Which API returned 500 during login?"

  • "What fields does /v1/user/profile return?"

  • "Find the request that contains this order ID."

  • "Generate a curl command to replay this request."

  • "Switch to the 3G throttling preset and start recording."

It is zero-build, pure Node.js (>=20) ESM, with only two dependencies: @modelcontextprotocol/sdk and zod.

Related MCP server: proxypin-mcp

How it works

Charles exposes a Web Interface control plane. In Charles 5.x it can be reached in two ways:

  1. Through the HTTP proxy (default): request http://control.charles/ via the Charles proxy port. No separate Web Interface listener is needed.

  2. Directly: enable Proxy → Web Interface Settings and point CHARLES_WEB_URL at that listener.

The server uses the first mode by default.

Endpoints used:

/recording/{index,start,stop}
/tools/{slug}/{index,enable,disable}
/throttling/{index,activate?preset=,deactivate}
/session/{index,clear,export-json,export-har,export-xml,export-csv,export-trace,download}
/quit   /disabled

Session data is exported as JSON, streamed to a temporary file, and indexed locally. Large sessions are parsed from the tail window, so only the newest N transactions are read by default. Bodies are decoded lazily (gzip / deflate / brotli / zstd) and cached with a memory budget.

Requirements

  • Charles Proxy 5.x running on the same machine

  • Node.js >= 20

  • Charles Web Interface enabled: Proxy → Web Interface Settings… → Enabled → OK

  • The traffic you want to inspect must go through Charles (device Wi-Fi proxy, emulator, export https_proxy=http://127.0.0.1:8888, etc.)

Install

git clone https://github.com/Sn0w0day/charles-mcp.git
cd charles-mcp
npm install

The repository includes a .mcp.json for Claude Code project-scoped use. Other clients need the configuration below.

Configure

Claude Desktop

Edit the Claude Desktop config file:

OS

Path

macOS

~/Library/Application Support/Claude/claude_desktop_config.json

Windows

%APPDATA%\Claude\claude_desktop_config.json

Linux

~/.config/Claude/claude_desktop_config.json

Add the server (use an absolute path):

{
  "mcpServers": {
    "charles": {
      "command": "node",
      "args": ["/absolute/path/to/charles-mcp/server.mjs"],
      "env": {
        "CHARLES_PROXY_PORT": "8888"
      }
    }
  }
}

If Claude Desktop cannot find node (common for GUI apps on macOS), use the absolute Node path, for example /opt/homebrew/bin/node or /usr/local/bin/node. On Windows use C:\\Program Files\\nodejs\\node.exe.

Restart Claude Desktop after editing the file.

Claude Code

From the repository root:

claude mcp add --scope user --env CHARLES_PROXY_PORT=8888 charles -- node "$PWD/server.mjs"

Or use the included .mcp.json when you open Claude Code in this repository.

Other MCP clients (Cursor, Cline, etc.)

Use the same JSON shape in the client's MCP configuration:

{
  "mcpServers": {
    "charles": {
      "command": "node",
      "args": ["/absolute/path/to/charles-mcp/server.mjs"],
      "env": { "CHARLES_PROXY_PORT": "8888" }
    }
  }
}

Tools

Tool

Description

charles_status

Check the connection; report recording state, available tools, throttling presets and local index state. Start here when something looks wrong.

charles_sync

Export the current session and build/refresh the local index. Defaults to the newest 300 transactions; window controls how far back to parse (0 = full).

charles_transactions

Filter transactions by host glob, path, method, status class, URL substring, MIME, minimum body size, ascending/descending cursor pagination.

charles_transaction

Inspect one transaction: headers, decoded body (gzip/deflate/brotli/zstd + charset repair), TLS/timing info. bodyMode=summary gives a compact JSON tree; bodyMode=preview gives raw text. raw=true shows the original export JSON.

charles_search

Full-text search across decoded request/response bodies (substring or regex), with host/path/status/MIME filters and context snippets.

charles_stats

Status distribution, top hosts and slowest requests.

charles_export

Export the session as har / json / xml / csv / trace / chls. Defaults to ~/Downloads.

charles_curl

Generate a replayable curl command from a captured request (strips pseudo-headers and stale content headers, decodes the body).

charles_control

Start/stop recording, clear the session, enable/disable a tool, switch throttling presets, quit Charles. Destructive actions require confirm: true.

Typical workflow

  1. charles_status — verify Charles is reachable and the Web Interface is enabled.

  2. charles_sync — build the local index. Query tools auto-sync on first use, so this is optional unless you want a specific window.

  3. charles_transactions — narrow down with host/path/status filters.

  4. charles_transaction — inspect headers and bodies of a specific #N.

  5. charles_search — find a value across all bodies.

  6. charles_curl — reproduce a request.

  7. charles_control — start/stop recording or switch throttling.

Transaction numbers (#N) are relative to the latest snapshot. Re-running charles_sync can renumber them.

Environment variables

Variable

Default

Description

CHARLES_PROXY_HOST / CHARLES_PROXY_PORT

127.0.0.1 / 8888

Charles HTTP proxy address

CHARLES_CONTROL_HOST

control.charles

Virtual host used through the proxy

CHARLES_PROXY_USER / CHARLES_PROXY_PASSWORD

—

Proxy authentication, if your Charles proxy requires it

CHARLES_WEB_URL

—

Direct mode: use this Web Interface URL instead of the proxy, e.g. http://127.0.0.1:14010

CHARLES_WEB_USER / CHARLES_WEB_PASSWORD

—

Web Interface basic auth, if configured in Charles

CHARLES_WEB_INSECURE

—

1 to skip TLS verification in direct HTTPS mode

CHARLES_SYNC_WINDOW

300

How many newest transactions to parse per sync; 0 = full session

CHARLES_AUTO_SYNC

1

Auto-sync on first query when the index is empty; 0 disables

CHARLES_DECODE_CACHE_MB

64

Memory budget for decoded body cache (LRU)

CHARLES_EXPORT_DIR

~/Downloads

Default directory for charles_export

CHARLES_PAGE_TIMEOUT_MS / CHARLES_EXPORT_TIMEOUT_MS

15000 / 120000

Control page / export timeout

CHARLES_DL_HARD_CAP_MB

2048

Hard cap for a single export download

Troubleshooting

Symptom

Fix

Web Interface is disabled

Charles → Proxy → Web Interface Settings → enable → OK

401 from the Web Interface

Set CHARLES_WEB_USER / CHARLES_WEB_PASSWORD

ECONNREFUSED 127.0.0.1:8888

Charles is not running, or the proxy port is different. Set CHARLES_PROXY_PORT.

407 / proxy authentication

Set CHARLES_PROXY_USER / CHARLES_PROXY_PASSWORD

Index is empty

Record some traffic and call charles_sync, or check CHARLES_AUTO_SYNC

Large session is slow

Lower CHARLES_SYNC_WINDOW, or use charles_export and process the file separately

control.charles requests appear

They are excluded by default; pass includeSelf: true to include them

Claude Desktop cannot find node

Use the absolute Node path in command

Direct mode with a self-signed certificate

Set CHARLES_WEB_INSECURE=1

Security and privacy

Captured traffic can contain credentials, cookies, tokens, personal data and proprietary payloads. The MCP server sends the decoded content to the AI model, so only point it at traffic you are authorized to inspect. The server uses stdio only and does not open a network port. charles_export writes files to the path you specify.

Development

npm install
npm test           # unit tests, no Charles required
npm run test:smoke # direct Web Interface smoke test (Charles required)
npm run test:e2e   # MCP protocol e2e, spawns the server and generates traffic (Charles + network required)

The export schema is normalized in one place: normalize() in session-store.mjs. If a future Charles version changes the export format, compare it with charles_transaction { raw: true } and adjust that function.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      Integrates Charles Proxy with MCP clients to provide real-time and historical network traffic capture and structured analysis. It features a summary-first approach that filters noise and desensitizes data for efficient, low-token agent debugging and monitoring.
      18
      110 PyPI
      336
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI to analyze real-time HTTP(S) traffic captured by ProxyPin, with tools to browse, search, and inspect requests and responses, as well as access saved history sessions.
      21 npm
      4
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to connect to Charles Proxy for live and historical traffic analysis, summary-first insights, request detail inspection, and data-driven mock creation via Map Local/Remote.
      47
      MIT