Skip to content

MCP & AI Agents

Madhyamas ships with a built-in Model Context Protocol (MCP) server that lets AI agents inspect captured traffic, create mocks and rewrites, manage sessions, and control every feature of the proxy — without leaving your agent's chat or IDE.

MCP is an open standard that lets LLM-powered tools call external services through a uniform interface. The Madhyamas MCP server exposes 146 tools covering traffic inspection, mocks, breakpoints, replay, sessions, scripting, plugins, and more — 135 core tools, plus 11 enterprise tools that are registered automatically when the connected server runs the enterprise tier.

How It Works

┌────────────┐     stdio      ┌────────────────┐     REST      ┌──────────────┐
│  AI Agent  │ ─────────────▶ │ madhyamas mcp  │ ────────────▶ │ madhyamas    │
│  (Claude,  │   JSON-RPC     │  (MCP server)  │   /api/*      │  proxy + UI  │
│  Cursor…)  │ ◀───────────── │                │ ◀──────────── │              │
└────────────┘                └────────────────┘               └──────────────┘
  1. You start the Madhyamas proxy (madhyamas serve).
  2. Your AI agent spawns madhyamas mcp as a child process (stdio transport).
  3. The MCP server forwards tool calls to the proxy's REST API at http://127.0.0.1:3001.
  4. The agent sees the results and can act on them — list traffic, create a mock, replay a request, etc.

Prerequisites

  • Madhyamas installed and on your PATH (madhyamas --version works)
  • The proxy running: madhyamas serve
  • Health check passes: curl http://localhost:3001/api/health returns OK
  • An MCP-compatible AI agent (Claude Desktop, Windsurf, Cursor with an MCP extension, OpenCode, CommandCode, Devin CLI, or any client that speaks MCP)

Configuring Your Agent

The MCP server is invoked as madhyamas mcp. Add it to your agent's MCP server config under the key madhyamas.

Claude Desktop

Config file location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
json
{
  "mcpServers": {
    "madhyamas": {
      "command": "/usr/local/bin/madhyamas",
      "args": ["mcp"],
      "env": {
        "MADHYAMAS_API_URL": "http://127.0.0.1:3001"
      }
    }
  }
}

Restart Claude Desktop after editing.

Windsurf (Codeium)

Config file location:

  • macOS: ~/.codeium/windsurf/mcp_config.json
  • Linux: ~/.config/windsurf/mcp_config.json
  • Windows: %APPDATA%\windsurf\mcp_config.json

Use the same JSON shape as Claude Desktop above. Restart Windsurf after editing.

Cursor

Cursor does not natively host MCP servers. Two options:

  1. Use the CLI directly in Cursor's integrated terminal — see the CLI reference:
    bash
    madhyamas traffic list --json
    madhyamas mocks create --url-pattern "*/api/test*" --status-code 200
  2. Install an MCP-compatible Cursor extension and add the same JSON config as Claude Desktop.

OpenCode / CommandCode / Devin CLI

These harnesses follow the Agent Skills standard and read MCP config from a project or global directory (e.g. .opencode/, .commandcode/, .devin/). Add the madhyamas server using the same JSON shape as Claude Desktop. See skills/madhyamas/references/harness-setup.md in the repo for harness-specific paths.

Generic MCP Client

For any MCP-compatible client, use this template:

json
{
  "mcpServers": {
    "madhyamas": {
      "command": "/path/to/madhyamas",
      "args": ["mcp"],
      "env": {
        "MADHYAMAS_API_URL": "http://127.0.0.1:3001",
        "MADHYAMAS_TIMEOUT": "30",
        "RUST_LOG": "info"
      }
    }
  }
}

Docker

If the proxy runs in Docker with -p 3001:3001, the host-side MCP server connects to http://localhost:3001 as shown in the generic template above. No container-internal networking is needed.

Environment Variables

VariableDefaultDescription
MADHYAMAS_API_URLhttp://127.0.0.1:3001API endpoint of the running proxy
MADHYAMAS_TIMEOUT30Request timeout in seconds
RUST_LOGinfoLogging level (trace, debug, info, warn, error)

Verification

After configuring your agent, verify the MCP server works:

  1. Confirm the proxy is healthy:
    bash
    curl http://localhost:3001/api/health
  2. Test the MCP server manually:
    bash
    echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | madhyamas mcp
    You should see a JSON response listing all available tools.
  3. In your agent, ask: "Show me the recent HTTP traffic captured by Madhyamas" or "List all Madhyamas MCP tools".

Tool Categories

The MCP server exposes 146 tools grouped by feature (135 core + 11 enterprise). The table below summarizes the categories; see the full tool reference for parameter-level detail.

CategoryToolsWhat you can do
Traffic Inspection7List, search, count, clear traffic; import HAR; get script traces
Mock Rules22Create, update, delete, toggle, test, and version mock rules
Mock Collections6Group mocks into collections and toggle them together
Mock Analytics2Inspect mock hit counts and analytics
Breakpoints7Create, list, delete, and pause/resume breakpoints
Replay6Replay saved requests, run advanced batches, view history
Sessions5Create, switch, delete, and export sessions
Configuration2Get and update proxy configuration
Capture Mode2Toggle between Recording and Passthrough modes
Throttle4Set latency/bandwidth/loss presets; enable/disable
Rewrites7Create, update, toggle, and apply rewrite templates
gRPC5Inspect gRPC connections, streams, frames, and stats
Scripts16Create, validate, test, toggle, and view history for JS scripts
Plugins19Install, enable, configure, sign, and scaffold WASM plugins
Auto Save3Configure and trigger session backups
Block List7Add, remove, and toggle blocked domains/patterns
Focus Hosts4Add and remove hosts highlighted in the traffic view
Mirror3Configure response mirroring to disk
Logs3View and rotate application logs
WebSocket Traffic4Inspect WebSocket connections and messages
Certificate1Download the CA certificate
Enterprise (enterprise tier only)11Manage users, roles, audit logs, and licenses

Example Agent Prompts

Once connected, try these prompts in your AI agent:

  • "List the last 10 requests to api.example.com captured by Madhyamas."
  • "Create a mock that returns 200 OK with a JSON body for any GET /api/users/* request."
  • "Show me all 5xx responses from the last hour and summarize the error patterns."
  • "Replay the saved login request 50 times with 5 concurrent connections and report the latency stats."
  • "Add a rewrite that injects an Authorization: Bearer test-token header on all requests to staging.example.com."

See also

Released under the MIT OR Apache-2.0 License.