Giving AI agents secure localhost access over MCP

Florian Wartner · 2026-06-28

AI coding agents have crossed a line: they no longer just suggest code, they run it. A capable agent often needs to reach a service running on your machine - to call a local API it just changed, to read a webhook it set up, or to check that a page renders. The naive way to enable that is to give the agent a shell and hope for the best. The better way is to grant a single, scoped capability over the Model Context Protocol (MCP) and audit every use of it.

This guide shows how to do that with Burrow's MCP server: the agent gets the ability to open and inspect tunnels through well-defined tools, nothing more.

burrow mcp

That prints the MCP endpoint and how to mint a token. The rest is about doing it safely.

What MCP is, briefly

The Model Context Protocol is an open standard for connecting AI agents to external tools and data. Instead of an agent guessing at shell commands, an MCP server advertises a typed list of tools with defined inputs and outputs. The agent calls those tools; the server decides what is allowed. The boundary is the point: the agent only ever does what the tools expose.

Why an agent needs to reach your dev server

Plenty of real agent tasks dead-end at localhost. The work is on your machine, but the agent cannot see it. Common cases:

  • Testing webhooks. The agent is wiring up a Stripe or GitHub integration and needs a public URL so the provider can POST events to the local handler. (See how to test webhooks locally for the manual version of this flow.)
  • Sharing a preview. You ask the agent to get a teammate or a design reviewer a link to the feature branch running on your laptop.
  • Debugging. Something is failing against real traffic and the agent needs to read the actual request that broke, then replay it while it iterates on the fix.

Without a controlled path, the alternatives are bad: hand the agent a shell, paste long-lived credentials into a prompt, or copy request payloads back and forth by hand.

Why not just give the agent a shell?

Shell access is all-or-nothing. An agent with a terminal can read any file, install anything, and reach anything your user can - which is far more authority than "let it hit my local API" requires. It is also invisible: there is no structured record of what the agent did, only scrollback.

MCP flips this around. Instead of broad access, you expose a small set of typed tools, each with a clear contract. The agent calls open_tunnel or get_recent_requests; it cannot call rm -rf because that tool does not exist. And because every call goes through the MCP server, every call can be scoped, rate-limited, and logged.

The Burrow MCP tool surface

Burrow exposes a focused set of tools so an agent can work with tunnels without touching the machine directly:

  • list_tunnels - list the team's tunnels (read scope).
  • get_tunnel - detail for one tunnel: host, target, status, usage.
  • open_tunnel - open a tunnel via a connected companion client (open scope).
  • close_tunnel - close an open tunnel (close scope).
  • get_recent_requests - read recent request metadata (bodies only if cloud history is enabled).
  • replay_request - replay a captured request through a connected client.

Each maps to a scope. A token only carries the scopes you grant it, so a token meant for read-only inspection literally cannot open or close anything.

Notice what is not here: there is no shell, no filesystem access, no "run arbitrary command." The agent can manage tunnels and inspect traffic, and that is the entire surface. Every call is scoped to the caller's own team - no cross-tenant visibility.

Step 1: mint a scoped token

Create a token at https://app.useburrow.dev/mcp-tokens. Two principles:

  1. Read-only by default. Free tokens are read-only. Start there. Only add open/close scopes when the agent genuinely needs to create tunnels, and prefer a separate token for that so you can revoke it independently.
  2. One token per agent. Give each agent (or each project) its own token. That way the audit log attributes actions correctly and you can revoke one without disrupting the others.

Step 2: connect the agent

Run burrow mcp to print the connection details:

Endpoint   https://app.useburrow.dev/mcp   (Streamable HTTP + SSE)
Auth       Bearer MCP token

Point your MCP-capable client at the endpoint with the token as a Bearer credential. This works with any MCP client - Claude, Cursor, and others. For Claude Code:

claude mcp add --transport http burrow https://app.useburrow.dev/mcp --header "Authorization: Bearer brw_mcp_…"

For Cursor or any client with a native MCP config file:

{
  "mcpServers": {
    "burrow": {
      "type": "http",
      "url": "https://app.useburrow.dev/mcp",
      "headers": { "Authorization": "Bearer brw_mcp_…" }
    }
  }
}

The agent now sees the Burrow tools alongside its other tools and can call them like any function. Ask it to "list my tunnels" or "show the last failed webhook," and it calls the matching tool. Full setup snippets, including a bridge for stdio-only clients, live on the MCP server page.

Step 3: let the agent open tunnels on demand (optional)

Reading tunnel state is useful, but the real unlock is letting an agent open a tunnel to this machine when it needs one - for example, to expose a dev server it just started so it can test against the public URL. That requires a local process willing to accept the request:

burrow companion

The companion is an idle daemon (it requires you to be logged in). When an agent calls open_tunnel with the right scope, the companion opens the tunnel from your side. You stay in control: stop the daemon and the agent can no longer reach the machine, regardless of its token.

Step 4: audit everything

Every MCP tool call is recorded in a structured audit log - which token, which tool, when, and the result. This matters for two reasons. First, you can answer "what did the agent actually do?" with a record instead of a guess. Second, it makes scope creep visible: if a read-only workflow suddenly shows open_tunnel calls, something changed and you will see it.

Treat the audit log the way you would treat access logs for any automated actor. Review it periodically, and rotate or revoke tokens that are no longer in use.

A safe default setup

For most people, the safe starting point is:

  • One read-only token per agent, minted per project.
  • No companion running unless an agent specifically needs to open tunnels.
  • A separate, short-lived token with open/close scopes for the sessions where the agent does need to create tunnels, revoked afterwards.
  • Periodic review of the audit log.

This gives agents the capability they need - reach a local service, inspect traffic - while keeping the blast radius small and observable. It is the same principle as least-privilege service accounts, applied to the agent era.

Tunnel data follows the same rules as the rest of Burrow: request bodies stay local by default and the data path is EU-hosted, so handing an agent inspection access does not quietly ship payloads off your machine.

FAQ

What is an MCP server for a tunnel? It is a server that exposes tunnel operations - open, list, close, inspect, replay - as Model Context Protocol tools, so AI agents can manage tunnels through a defined interface instead of a shell.

Which agents can use it? Any MCP-compatible client, including Claude Code and Cursor. You add Burrow as an MCP server with a scoped token.

Can the agent run shell commands on my machine? No. The MCP server exposes only the tunnel tools. There is no shell, filesystem, or arbitrary-command access.

Is agent access free? The MCP surface is read-only on the Free plan. Mutating actions like opening and closing tunnels or replaying requests require a paid plan - see pricing.

Are the agent's actions logged? Yes. Every tool call is audited, giving you a reviewable record of what the agent did.

Where to go next

For the product-level overview, see the AI agents use case and the MCP server page. The MCP docs cover the full tool reference.

If you are weighing tools, note that this is the clearest gap versus the incumbents: as covered on the ngrok alternative page, the mainstream tunnels do not ship an MCP server at all, so agent access there means scripting a CLI rather than calling scoped, audited tools.

Try Burrow free

npx useburrow http 3000 - EU-hosted, DSGVO-first, MCP-native.

Get started free · Burrow vs ngrok