Skip to content
ZH

Built-in MCP Support

RelayCraft features Built-in MCP (Model Context Protocol) Support, providing a bridge between your live network traffic and AI agents. AI assistants like Claude Desktop, Cursor, or any MCP-compatible client can directly “see” your requests, allowing for real-time traffic analysis, automated rule creation, and interactive debugging.

  1. Open Settings → Integrations → MCP Server.
  2. Toggle it on. RelayCraft starts an HTTP server on the configured port (default 7090).
  3. Copy the Bearer token shown in the panel — you’ll need it for write operations.

Configure your MCP client to point to:

http://localhost:7090/mcp

For Claude Desktop, add an entry to claude_desktop_config.json:

{
"mcpServers": {
"relaycraft": {
"type": "http",
"url": "http://localhost:7090/mcp",
"headers": {
"Authorization": "Bearer <your-token>"
}
}
}
}

The server uses JSON-RPC 2.0 over HTTP POST and follows the MCP protocol spec (2024-11-05).

These tools do not require authentication and are safe to expose to any MCP client.

List all recorded debugging sessions.

list_sessions()
→ Session IDs, names, timestamps, flow counts

Query flows in a session with optional filters.

ParameterTypeDescription
session_idstring?Session to query. Omit for the active session.
limitintegerMax flows to return. Default 50, max 200.
methodstring?Filter by HTTP method: GET, POST, etc.
statusstring?Filter by status code or range: 404, 4xx, 5xx.
domainstring?Substring match on the host.
has_errorboolean?Return only flows that have errors.
content_typestring?Substring match on the response Content-Type.

Get full details of a single flow — headers, request body, response body.

ParameterTypeDescription
idstringFlow ID from list_flows or search_flows.

Response bodies larger than 100 KB are truncated.

Search flows by keyword. By default, matches against the full URL. Use search_in to search inside request/response bodies or headers instead.

ParameterTypeDescription
querystringKeyword to search for.
search_instringWhere to search: url (default), response_body, request_body, header.
case_sensitivebooleanCase-sensitive match. Default false.
session_idstring?Session to search within.
limitintegerMax results. Default 20, max 50.

Body and header searches scan up to the 5 000 most recent flows. URL search is instant.

# Find all flows whose response body mentions "NullPointerException"
search_flows(query="NullPointerException", search_in="response_body")
# Find flows passing a specific token in a header
search_flows(query="Bearer eyJ", search_in="header")

Aggregate statistics for a session — total flows, error rate, top domains, status distribution, slowest requests.

ParameterTypeDescription
session_idstring?Session to summarise. Omit for the active session.

List all rules with key fields (ID, name, type, URL pattern, enabled state, source).

list_rules()
→ Rule list for follow-up actions like delete/toggle

Write tools require the Authorization: Bearer <token> header.

Replay a captured request through the proxy, optionally with modifications. The replayed request appears in the traffic list so you can inspect the response with get_flow.

ParameterTypeDescription
flow_idstringFlow to replay.
modifications.urlstring?Override the full URL including scheme, host, path, and query string.
modifications.methodstring?Override the HTTP method.
modifications.headersobject?Key-value pairs to add or override request headers.
modifications.bodystring?Replacement request body.
# Replay with a different endpoint
replay_request(
flow_id="abc123",
modifications={
"url": "https://api.example.com/v2/users",
"headers": {"Authorization": "Bearer new-token"}
}
)

Create a proxy rule that takes effect immediately.

ParameterTypeDescription
typestringRule type (see below).
namestringDescriptive rule name.
url_patternstringURL substring to match.
methodstring?Optional HTTP method filter.

Rule types and their extra parameters:

TypeExtra Parameters
map_localmock_body, mock_content_type (default application/json), mock_status (default 200)
map_remotetarget_url (required)
rewrite_bodyrewrite_target (request/response), rewrite_mode (set/replace/regex_replace/status_code), rewrite_content, rewrite_pattern, rewrite_replacement, rewrite_status, rewrite_content_type
rewrite_headerheader_phase (request/response), header_operation (add/set/remove), header_name, header_value
throttlebandwidth_kbps, delay_ms
block_request(no extra params)

Delete a rule by ID.

ParameterTypeDescription
rule_idstringID of the rule to delete.

Enable or disable a rule without deleting it.

ParameterTypeDescription
rule_idstringRule to toggle.
enabledbooleantrue to enable, false to disable.

Here is a typical debugging session driven by an AI agent:

  1. Capture traffic — run your app while RelayCraft is intercepting.
  2. Ask the AI: “Find all 5xx errors from api.example.com”list_flows(domain="api.example.com", status="5xx")
  3. Ask: “Show me the full request and response for the first error”get_flow(id="...")
  4. Ask: “Replay it but change the Authorization header”replay_request(flow_id="...", modifications={headers: {...}})
  5. Ask: “Mock that endpoint to return a fixed 200 response while I fix the backend”create_rule(type="map_local", ...)