MCP Server Guide

Connect AI coding agents to your live tunnel traffic — CLI v1.1.0+

What the MCP Server Does

The tunnl mcp command starts a Model Context Protocol server over stdio. MCP is a standard that lets AI coding agents (Claude Desktop, Cursor, Copilot Agent Mode) call external tools in a structured way.

When you add tunnl as an MCP server, your AI agent can:

  • List your active tunnel connections
  • Query request history with filters (method, path, status code, time range)
  • Read the full headers and body of any captured request
  • Replay a request against your running handler
  • Compare the original response against a replayed response
  • Export any request as a curl command

The agent can see what your webhook handler is actually receiving and what it is returning, without you switching between windows.

📋
tunnl mcp does not start a tunnel. It queries existing tunnel data. You still need to run tunnl --port 3000 (or similar) in another terminal to establish the tunnel connection.

Setup: Claude Desktop

Edit your Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the tunnl MCP server:

claude_desktop_config.json
{
  "mcpServers": {
    "tunnl": {
      "command": "tunnl",
      "args": ["mcp"],
      "env": {
        "TUNNL_SERVER": "https://webhooks.example.com",
        "TUNNL_TOKEN": "tk_your_api_key_here"
      }
    }
  }
}

Restart Claude Desktop. You will see the tunnl tools available in the tool list.

💡
Use an API key, not your login JWT. Create a long-lived API key in your server dashboard (Settings → API Keys). API keys start with tk_ and do not expire when you rotate your login session.

Setup: Cursor

Create or edit .cursor/mcp.json in your project root, or add to the global Cursor MCP config:

.cursor/mcp.json
{
  "mcpServers": {
    "tunnl": {
      "command": "tunnl",
      "args": ["mcp"],
      "env": {
        "TUNNL_SERVER": "https://webhooks.example.com",
        "TUNNL_TOKEN": "tk_your_api_key_here"
      }
    }
  }
}

If you have already logged in with tunnl login, you can omit the env block — the MCP server will read credentials from ~/.tunnl/config.json.

Tool Reference

All 8 tools exposed by tunnl mcp:

list_tunnels

List all active tunnel connections on the server.

ParameterTypeDescription
No parameters

Returns an array of tunnels with subdomain, local port, connected-at timestamp, and request count.

get_tunnel

Get details for a specific tunnel by subdomain or ID.

ParameterTypeDescription
subdomainstringThe tunnel subdomain (e.g., abc123)

list_requests

Query request history with optional filters. Returns paginated results newest-first.

ParameterTypeDescription
subdomainstring (optional)Filter to a specific tunnel
methodstring (optional)Filter by HTTP method: GET, POST, etc.
pathstring (optional)Filter by path prefix or exact match
statusinteger (optional)Filter by response status code
limitinteger (optional)Number of results. Default: 20, max: 100.

get_request_detail

Get the full headers and body for a specific request.

ParameterTypeDescription
request_idstringThe request ID from list_requests

Returns the full request (method, path, headers, body) and response (status, headers, body, timing).

replay_request

Re-send a captured request to the connected CLI. The CLI forwards it to your local handler.

ParameterTypeDescription
request_idstringThe request ID to replay

The request is replayed with its original headers, including signature headers (Stripe, GitHub, Slack). The replayed response is stored and can be retrieved with get_replay_diff.

get_replay_diff

Compare the original response against a replayed response.

ParameterTypeDescription
request_idstringThe request ID (must have been replayed first)

export_curl

Export a captured request as a ready-to-run curl command.

ParameterTypeDescription
request_idstringThe request ID to export

Returns a shell-escaped curl command with all original headers and body. Useful for manual debugging and sharing.

get_tunnel_stats

Get aggregate statistics for a tunnel session.

ParameterTypeDescription
subdomainstringThe tunnel subdomain
sincestring (optional)ISO 8601 timestamp. Default: last 24 hours.

Returns request count, error rate, average response time, and a breakdown by HTTP method and status code.

Example Workflow

Once tunnl is configured as an MCP server, you can ask your agent:

example prompts
# See what your webhook handler is receiving
"Show me the last 5 requests to my abc123 tunnel"

# Debug a failing handler
"Replay the last POST to /webhook and show me what changed in the response"

# Export for manual testing
"Give me a curl command for the Stripe checkout.session.completed event
 that came in at 14:32"

# Understand a provider's payload shape
"What headers does GitHub send with push events? Look at the last 10 requests."