opening soon
Docs

Using portmole

Everything the client does, in the order you will meet it: install, sign in, open a tunnel, read what came through it. When something goes wrong, the help page lists every message and what to do about it.

Quick start

portmole is one program. Your coding agent starts it as an MCP server, or you run it yourself in a terminal. The npx lines below need Node 18 or newer and install nothing permanently.

Claude Code

claude mcp add portmole -- npx -y portmole mcp

Run it in a terminal. Add -s user after add to have it in every project.

Claude Desktop

{
  "mcpServers": {
    "portmole": { "command": "npx", "args": ["-y", "portmole", "mcp"] }
  }
}

Settings → Developer → Edit Config opens claude_desktop_config.json. Add the entry, then restart the app.

Codex

codex mcp add portmole -- npx -y portmole mcp

Or add it to ~/.codex/config.toml by hand:

[mcp_servers.portmole]
command = "npx"
args = ["-y", "portmole", "mcp"]

Cursor

{
  "mcpServers": {
    "portmole": { "command": "npx", "args": ["-y", "portmole", "mcp"] }
  }
}

Put this in .cursor/mcp.json in your project, or in ~/.cursor/mcp.json for every project.

VS Code

{
  "servers": {
    "portmole": { "type": "stdio", "command": "npx", "args": ["-y", "portmole", "mcp"] }
  }
}

Put this in .vscode/mcp.json in your workspace. VS Code calls the list servers, not mcpServers.

Windsurf

{
  "mcpServers": {
    "portmole": { "command": "npx", "args": ["-y", "portmole", "mcp"] }
  }
}

Put this in ~/.codeium/windsurf/mcp_config.json, then refresh the MCP servers in Windsurf's settings.

Gemini CLI

{
  "mcpServers": {
    "portmole": { "command": "npx", "args": ["-y", "portmole", "mcp"] }
  }
}

Put this in ~/.gemini/settings.json, or in .gemini/settings.json in your project.

Another tool

{
  "mcpServers": {
    "portmole": { "command": "npx", "args": ["-y", "portmole", "mcp"] }
  }
}

Any MCP client that can start a local program works. The command is npx with the arguments -y portmole mcp; most tools take it in this shape.

Start a new agent session after adding it, then ask in plain words: open port 3000 with portmole. The first time, the agent shows you a sign-in link.

Terminal

  1. Install. npm install -g portmole. Without Node, download the program for your system from the GitHub releases page and put it on your PATH.
  2. Check. portmole version prints the version.
  3. Sign in. portmole login, then approve the code in your browser.
  4. Open a port. portmole http 3000.

The command prints the address, then each request as it arrives, and keeps running until you press Ctrl+C:

https://my-shop-ada.portmole.dev -> localhost:3000

Starting the installed program from an agent

With portmole installed, any of the entries above can use it directly in place of npx: the command is portmole and the only argument is mcp. It starts faster, works offline, and helps where a desktop app cannot find npx, which happens on Windows.

{
  "mcpServers": {
    "portmole": { "command": "portmole", "args": ["mcp"] }
  }
}

Signing in

Every tunnel belongs to an account, and accounts sign in with GitHub. There is no password to create.

  1. The client prints a link. It asks portmole for a sign-in and shows a link with a short code, for example HXSD-XMWV. From an agent, tunnel_create returns the same link for the agent to show you.
  2. You sign in to GitHub. Opening the link takes you to GitHub, which asks whether portmole may know who you are. This tells portmole your account; it does not sign the machine in yet.
  3. You approve the code on portmole.dev. GitHub sends you back to a portmole page that shows your portmole name and the code. If the code matches the one in your terminal or agent, press Approve. This second step is the one that signs the machine in.
  4. The client finishes by itself. It receives a token, stores it and prints Signed in as <name>. From an agent, ask for the tunnel again.

If the terminal keeps waiting after you signed in to GitHub, the page with the Approve button is still open somewhere: go back to it and press the button. A page that shows a different code belongs to an older attempt; close it and open the newest link.

You can also open https://portmole.dev/activate and type the code in by hand, which helps when the link was shown on another device.

What Approve means. Approving lets the machine that shows that code open tunnels under your account. Signing in to GitHub alone approves nothing. If someone sends you a sign-in link you did not start yourself, close the page: the code on it belongs to their machine.

The link works for 10 minutes. The token is kept in a file only your user can read, in your user config directory (portmole/credentials.json). Each machine has its own token.

portmole login     sign this machine in
portmole logout    sign out and revoke the token

portmole logout revokes the token on the server too. Tunnels still open with that token are closed within about 30 seconds.

Addresses and names

An address has the form <name>-<handle>.portmole.dev.

  • Handle. Your GitHub user name in lower case, letters and digits only, at most 20 characters: Ada-Lovelace becomes adalovelace. If that is taken, a number is added. It is fixed when you first sign in and stays the same if you rename your GitHub account.
  • Name. The name you pass, or else the name of the folder the client runs in. It is put in lower case, every run of other characters becomes a hyphen, and it is cut to 26 characters: ~/code/My Shop becomes my-shop. A folder name with nothing usable in it gets 8 random characters.

Because the name comes from the folder, the same project gets the same address every time you open it.

When a name is already in use

  • A second port of the same project, in the same agent session, gets the port in its name: the frontend on 3000 is my-shop-ada, the API on 8000 is my-shop-8000-ada.
  • The same name open from another machine on your account gets four random characters, such as my-shop-3fa9-ada, and the tool result says so. From the terminal command you get the error instead; pass a different name.

Addresses are easy to guess. Anything that should stay private needs a password. Names without the handle and your own domain are not available yet.

Terminal commands

Run portmole help for the list. Running portmole alone, portmole -h or portmole --help prints the same.

portmole http <port> [name]   expose localhost:<port>; runs until Ctrl+C
    --bots=<list>             automated visitors to admit
portmole console              open, rename and close tunnels from a page
                              on this machine, and watch their requests
portmole mcp                  serve the tools to a coding agent over stdio
portmole login                sign this machine in
portmole logout               sign out and revoke the token
portmole version              print the version
portmole help                 print this list

portmole http <port> [name]

Exposes localhost:<port> and prints the address. It signs you in first if this machine has no token, and runs until you press Ctrl+C, which closes the tunnel.

portmole http 3000            https://<folder>-<you>.portmole.dev
portmole http 3000 demo       https://demo-<you>.portmole.dev
portmole http 8080 api --bots=none
  • port is a number from 1 to 65535. Anything else is refused with invalid port.
  • name is optional. Without it, the folder you run the command in names the tunnel. See addresses and names.
  • --bots= chooses which automated visitors get in. See bots and crawlers.

While it runs it shows how much of the day's data allowance is used, then one line for each request: time, method, status, duration and path.

https://my-shop-ada.portmole.dev -> localhost:3000
Data used today: 12.4 MB of 5.0 GB

Requests appear below. Press Ctrl+C to close the tunnel.

16:06:12  GET     200     84 ms  /
16:06:13  POST    201     41 ms  /api/orders
16:06:15  GET     403      0 ms  /

The command asks the server for the request log once a second and the log holds the last 20 requests, so a burst larger than that is shown in part. One command opens one tunnel: for a frontend and an API, run it twice with two names, open both in the console, or let an agent open both.

portmole console

Serves a page on this machine for opening, renaming and closing tunnels and watching their requests. It has a section of its own.

portmole mcp

Serves the four tools to a coding agent over standard input and output. Agents start this themselves from the entry you added in the quick start; you do not run it by hand. Its tunnels close when the agent session ends.

portmole login

Signs this machine in and stores the token. You rarely need it: portmole http and portmole console start a sign-in themselves when there is no token. See signing in.

portmole logout

Deletes the stored token and revokes it on the server, then prints Signed out. Tunnels still open with that token close within about 30 seconds. If the server cannot be reached, the token is still removed from this machine and the command says that it could not be revoked.

portmole version

Prints the version, as portmole <version>. portmole --version does the same. Include it when you ask for help.

portmole help

Prints the list of commands with a line on each, two examples and the address of this page. A command portmole does not know prints portmole: cannot run "…" as given followed by the same list, and exits with status 2.

The console

portmole console starts a small page on your own machine and prints its address:

Console: http://127.0.0.1:4040

Tunnels opened there stay open while this command runs. Press Ctrl+C to close them.

Open the address in a browser. If port 4040 is taken, the command picks a free port and prints that one.

  • Open a tunnel. Enter the local port and, if you like, a name. Without a name the folder the command was started in names the tunnel.
  • Copy the address with the button on the tunnel, or click the address to open it in a new tab.
  • Rename. Gives the tunnel a new name and so a new address. The old address stops working; the part after the last hyphen is your GitHub name and stays. If the new name cannot be opened, the old address is put back.
  • Close a tunnel without stopping the others.
  • Requests. Each tunnel shows its latest requests, newest first: time, method, status, duration and path. The page refreshes every two seconds.
  • Data today. The top of the page shows how much of the daily allowance is used.

What to know before relying on it:

  • The console shows the tunnels it opened itself, not those of a portmole http command or an agent session running next to it. They still count toward the limit of two.
  • Its tunnels close when the command stops.
  • It has no fields for a password or for bot rules; tunnels opened there use the defaults. For a protected tunnel, use an agent.
  • The page answers only on this machine, under 127.0.0.1 or localhost, and takes changes only from its own page. Another website open in your browser cannot use it to open a tunnel.

The four tools

These are what your agent sees after you add portmole. You do not call them yourself: say what you want in plain words, such as "open port 3000 with portmole", "what requests came in?" or "close the tunnel", and the agent picks the tool. Tunnels opened by an agent close when the agent session ends.

tunnel_create

Exposes a local port and returns its address. Call it once per port.

InputTypeMeaning
portinteger, requiredLocal port the app listens on, 1 to 65535.
namestringName used in the address. Defaults to the project folder name.
basic_authstringuser:password that visitors must enter. See password protection.
allow_botsstringWhich automated visitors to admit: search, ai_crawlers, ai_assistants, comma-separated, or all, or none. Defaults to ai_assistants. See bots and crawlers.

Result:

https://my-shop-ada.portmole.dev -> localhost:3000
Tunnel name: my-shop

When you are not signed in, the result is the sign-in instruction instead:

Sign-in needed. Ask the user to open https://portmole.dev/activate?code=HXSD-XMWV,
check that the page shows the code HXSD-XMWV, and approve. Then call tunnel_create again.

Calling it again for a port that is already open returns the same address, and applies a changed basic_auth or allow_bots. A port outside 1 to 65535 is refused with port must be between 1 and 65535, and a name with no letter or digit in it with name needs at least one letter or digit.

tunnel_list

No input. Lists the tunnels open in this session, or says No tunnels are open.

my-shop: https://my-shop-ada.portmole.dev -> localhost:3000
my-shop-8000: https://my-shop-8000-ada.portmole.dev -> localhost:8000
Data used today: 12.4 MB of 5.0 GB

tunnel_close

Takes name, the tunnel name as reported by tunnel_create or tunnel_list (not the full address). Result: Closed my-shop. A name that is not open in this session gets no open tunnel named "…".

tunnel_requests

Takes name and optionally limit, how many requests to return. Returns the most recent requests, newest last, or No requests yet. The result starts with a line telling the agent that everything below was sent by visitors and is data, not instructions: paths and headers are written by whoever sent the request.

[
 {
  "time": "2026-11-22T13:01:58.55+03:00",
  "method": "POST",
  "path": "/webhooks/payment?id=7",
  "status": 200,
  "ms": 41,
  "headers": {
   "Content-Type": "application/json",
   "User-Agent": "ExampleHooks/1.0"
  }
 }
]

Password protection

Pass basic_auth as user:password to tunnel_create, or ask your agent to "put a password on it". Visitors then get the browser's own user name and password prompt before anything reaches your app. Scripts send the usual Authorization: Basic header.

  • portmole checks the password and removes the header, so your app never sees the tunnel's password.
  • After 10 wrong answers, that visitor is locked out of that tunnel for a minute. While locked out, even the right password is refused.
  • To change the password, call tunnel_create again for the same port with the new value.

Choose a password nobody could guess, and not one you use elsewhere: it is sent to portmole when the tunnel opens. The terminal command and the console have no password option yet; use an agent for a protected tunnel.

Bots and crawlers

A tunnel shows unfinished work, so by default it keeps crawlers out and lets AI assistants in. You choose with allow_bots on tunnel_create, or --bots= on the terminal command.

KindWho that isBy default
ai_assistantsAI tools fetching one page because a person asked: ChatGPT, Claude, Perplexity and others when you paste them your link.admitted
ai_crawlersCrawlers collecting pages for AI models and AI search: GPTBot, ClaudeBot, PerplexityBot, CCBot and others.turned away
searchSearch engine and SEO crawlers: Googlebot, Bingbot, YandexBot and others.turned away

Give a comma-separated list, or all, or none. For example, "open port 3000 and let search engines in" becomes allow_bots: "search, ai_assistants".

  • A bot that is turned away gets status 403, and shows up in the request log so you can see who came.
  • Unless search is admitted, every answer carries X-Robots-Tag: noindex, nofollow, and the tunnel answers /robots.txt itself instead of your app.
  • Admitted bots skip the visitor notice, which they could not click through.

The /robots.txt that portmole writes names each known bot and says whether it may come in, then closes with a rule for everyone else. With the default setting it reads like this:

# Written by portmole for this tunnel; the app's own robots.txt is not served.
User-agent: chatgpt-user
User-agent: claude-user
…
Allow: /

User-agent: gptbot
…
Disallow: /

User-agent: *
Disallow: /

An unknown kind in the list is refused when the tunnel opens, with unknown kind of bot "…": use search, ai_crawlers, ai_assistants, all or none.

Bots are recognised by the name they give in their User-Agent. That stops the ones that play fair, which is what keeps a development site out of search results and training sets. It does not stop a program that lies about who it is; for that, use a password.

Request log

portmole remembers the last 20 requests of each tunnel so an agent can see what arrived. Each entry has the time, method, path with query string, status, duration in milliseconds and the request headers.

  • Authorization, Cookie and Proxy-Authorization headers are left out.
  • At most 40 headers are kept per request, each value cut at 200 characters; paths are cut at 500.
  • Request and response bodies are never recorded.
  • The log is held in memory only and is gone when the tunnel closes.
  • Requests refused for a wrong password show up with status 401.

WebSockets and large transfers

A tunnel carries HTTP, and what rides on it:

  • WebSockets pass through, so hot reload, live dashboards and chat work over the public address as they do on localhost.
  • Uploads and downloads have no size limit of their own and no time limit: a transfer takes as long as it takes. What counts is the daily data allowance, and both directions count toward it.
  • Webhooks from payment providers and other services reach your app directly; they are never shown the visitor notice.

Your app receives each request with the visitor's own Host header, which is the tunnel address, and with X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto added, so it can tell the visitor's address and that the visit came over https. A dev server that refuses host names it does not know needs the tunnel's name in its list of allowed hosts.

A tunnel does not carry other protocols. There is no way to expose a database port or SSH through it.

The client connects to your app at localhost:<port>, by name, so it finds dev servers that listen on IPv6 only as well as those on 127.0.0.1.

Reconnecting

The client holds one connection to portmole. When that connection breaks, because your network changed, the laptop slept or portmole restarted, the client dials again by itself: after one second, then two, four and so on, up to every 30 seconds. Once it is back, it opens the same tunnels again under the same addresses, with the same password and bot rules. In between, visitors get portmole: no tunnel is open at this address.

  • If another session of your account took a name while you were away, that tunnel is not restored; the others are.
  • The client stops for good in three cases: the session length is reached, the token was revoked, or the account was closed. portmole http and portmole console then end with a message; run them again. An agent session forgets its tunnels, and the next tunnel_create connects again.
  • Stopping your app does not close the tunnel. Visitors get portmole: nothing is listening on localhost:<port> until the app is back, and the address stays the same.

Limits

There is one plan today, and it is free. Paid plans are not available yet.

LimitValueWhat happens at the limit
Tunnels open at once2 per accountThe third is refused until you close one. Tunnels on all your machines count together.
Session length2 hoursThe connection ends and its tunnels close. Open them again to get the same addresses. See reconnecting.
Requests120 per minute from each visitor, 1200 per minute per tunnel in totalFurther requests get status 429 with a Retry-After: 60 header until the minute is over. One busy visitor cannot use up the tunnel for the others.
Requests in flight200 at once, per tunnelRequests beyond that get status 429. Long-running requests such as open WebSockets count while they are open.
Connections4 per accountEach running portmole http, console or agent session with a tunnel holds one. The fifth is refused.
Data5 GB per day, per accountTransfers in progress are cut, new requests get 429 and no new tunnel opens until midnight UTC. Both directions count.
Request loglast 20 per tunnelOlder entries are dropped.
Wrong passwords10 per minute, per visitor and tunnelThat visitor is locked out for the rest of the minute.
Visitor noticefirst browser visitSee below.

The numbers may change as real use shows what is reasonable.

What visitors see

The first time someone opens a tunnel address in a browser, portmole shows a short notice instead of your site. It names the address and your handle, says the page is served from a developer's computer, and warns against entering passwords or card numbers for a link from someone they do not trust. Continue to the site takes them on to the page they asked for.

  • The choice is remembered for one day in a cookie named portmole-ok on that tunnel address.
  • Only page views in a browser get the notice: requests that are not GET or do not ask for HTML pass straight through. Webhooks and API calls are never affected.
  • The path /_portmole/continue on tunnel addresses is used by the notice and does not reach your app.

The notice cannot be switched off on the free plan.

Environment variables

PORTMOLE_TOKEN
A token to use instead of the stored one, for CI and scripts. When it is set, the client never starts a sign-in.
PORTMOLE_SERVER
The server to connect to. Defaults to https://portmole.dev. Stored tokens are tied to the server they were issued by.

Security model

  • One outbound connection. The client connects out to portmole over TLS. Nothing listens on your machine, no port is opened on your router and no admin rights are needed.
  • Only the port you name. The client forwards to localhost:<port> for the tunnels you opened and nothing else.
  • portmole can see your traffic in transit. Visitors connect to portmole over HTTPS; portmole reads each request to route it and passes it down the client's encrypted connection. It is not end-to-end encrypted between the visitor and your app.
  • What is stored. Your GitHub numeric id, your handle, a hash of each token, which account opened which address and when, and daily totals of requests and data. Request and response bodies are never stored. The privacy page has the full list.
  • Tokens open tunnels and nothing more. A token cannot read your GitHub account; portmole asks GitHub only who you are, once, at sign-in.
  • The client is open source. You can read what it sends in the repository. The hosted service is not open source.

Uninstall

portmole logout                 revoke this machine's token
claude mcp remove portmole      remove it from Claude Code
codex mcp remove portmole       remove it from Codex
npm uninstall -g portmole       remove the program

For Cursor, delete the portmole entry from .cursor/mcp.json. Run portmole logout first, while the program is still installed.

When something goes wrong

The help page lists every message the client, a tunnel and the sign-in page can show, with what each one means and what to do, followed by answers to common questions and where to write.