Logo Porterminal

Porterminal

Cộng đồng
lyehe

Quick n' dirty web/mcp terminal tunneling your phone & pc

Nhà phát hànhlyehe
Kho mãporterminal
Ngôn ngữPython
Bản fork
8
Sao
298
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépAGPL-3.0
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Porterminal cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    298 sao và 8 bản fork từ kho mã được liên kết.

[!WARNING] That complete URL is full access to this computer. It contains a random per-launch access code, and anyone (or any AI agent) you hand it to gets a real shell on your machine. Treat the URL and QR code like a secret, only share them with people and agents you trust, and read Security before you point Porterminal at anything important.

Why

I need something dangerously easy to remote access a computer.

ngrok requires registration and the free tier sucks. Cloudflare Tunnel is excellent plumbing, but by itself it only gives you a tunnel, not a phone-friendly terminal. Tailscale is great when you own both ends, but it still means joining devices to a private network. Termius requires complicated setup: port forwarding, firewall rules, key management...

So I built something simpler: run a command, scan a QR, start typing.

Then it clicked: the same trick (one command, one URL) is the easiest way to give an AI agent a real terminal on any computer. No MCP server to write, no SSH keys, no Docker, no config. Run uvx ptn, hand over the URL, and the agent runs commands, reads the screen, and answers prompts on that machine. And because it's a web terminal, you can open the same session in any browser to watch it work live, or grab the keyboard and take over.

Features

  • Hand a computer to an agent, full control, and watch it - Give an AI agent the URL and it gets a real terminal on the machine via MCP or plain REST. Open the same session in any browser to watch it work live, and grab the keyboard whenever you want. No keys, no Docker. The agent learns how from <url>/llms.txt and <url>/.well-known/mcp.json. See Agent access.
  • One command, instant access - uvx ptn and you (or an agent) get a real terminal on this machine. No SSH, no port forwarding, no config files. Cloudflare tunnel + QR code.
  • Actually usable on mobile - Touch-optimized with momentum scrolling, pinch-to-zoom, swipe gestures, and modifier keys (Ctrl, Alt).
  • Full terminal apps - vim, htop, less, tmux all work correctly with proper alt-screen buffer handling.
  • Persistent multi-tab sessions - Sessions survive disconnects. Close the browser, switch networks, reconnect from another device, and your shell and running processes are still there. You and an agent can share one session: watch it work, or take over.
  • Cross-platform - Windows (PowerShell, CMD, WSL), Linux/macOS (Bash, Zsh, Fish, Nushell, and any shell via $SHELL). Auto-detects your shells.
  • Hard to guess by default - Every launch adds an independent 128-bit random access path. The bare tunnel hostname and every wrong path return 404. The URL is hidden on screen, but the QR contains the complete credential, so keep both private. Press c to copy agent instructions and URL, u to copy the URL only, or s to show the agent prompt on screen (q closes it).

Install

MethodInstallUpdate
uvx (no install)uvx ptnuvx ptn@latest
uv tooluv tool install ptnuv tool upgrade ptn
pipxpipx install ptnpipx upgrade ptn
pippip install ptnpip install -U ptn

One-line install (uv + ptn):

OSCommand
Windowspowershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/lyehe/porterminal/master/install.ps1 | iex"
macOS/Linuxcurl -LsSf https://raw.githubusercontent.com/lyehe/porterminal/master/install.sh | sh

Requires Python 3.12+ and cloudflared (auto-installed if missing).

Usage

bash
ptn                    # Start in current directory
ptn ~/projects/myapp   # Start in specific folder
FlagDescription
-n, --no-tunnelLocal network only (no Cloudflare tunnel)
--mcp-onlyMCP shell control without a QR code, browser terminal, or REST API
-p, --passwordPrompt for password to protect this session
-sp, --save-passwordSave or clear password in config
-tp, --toggle-passwordSet password requirement (on/off/toggle)
-v, --verboseShow detailed startup logs
-i, --initCreate .ptn/ptn.yaml with auto-discovered project scripts as buttons
-if, --init-from URL/PATHCreate .ptn/ptn.yaml from a URL or local file
-c, --composeEnable compose mode by default
-k, --keep-qrKeep the QR code visible after the first connection
-u, --check-updateCheck if a newer version is available
-V, --versionShow version

While running: with a tunnel active, the connection URL is hidden on screen for privacy. Press c to copy agent instructions and URL, including /mcp, /api/agent/run, and /llms.txt; press u to copy the URL only; press s to show the full agent prompt as selectable text (q closes it); or scan the QR to connect. Ctrl+C stops the server.

Agent access (MCP + REST)

For shell control entirely behind the scenes, run ptn --mcp-only. The local terminal UI stays open: press c to copy the agent prompt and MCP address, u to copy just the MCP address, or s to show the prompt on screen (q closes it). These keys also work with --no-tunnel. Connect your MCP client to the generated <url>/mcp endpoint. This mode shows no QR code and disables the web terminal, browser WebSockets, and REST API, so commands cannot be watched or entered through the browser. MCP discovery and /llms.txt remain available. The complete MCP URL still grants shell control of the computer.

The same URL also works for AI agents. MCP-capable clients can use <url>/mcp (Streamable HTTP) for native typed tools. Agents that cannot register an MCP server can use the REST fallback at <url>/api/agent/run with ordinary HTTP requests. Either path creates a persistent agent shell, shown as a 🤖 tab you can watch and take over from your phone.

Hand the agent the complete generated URL, including its access code. MCP clients can auto-discover the server from <url>/.well-known/mcp.json (the MCP server.json descriptor), and there's a human/agent-readable <url>/llms.txt with usage. The base page also includes accessibility-visible hints for browser-driving agents, while the human UI stays compact. Example client config:

json
{
  "mcpServers": {
    "porterminal": { "url": "https://<your-tunnel>.trycloudflare.com/<access-code>/mcp" }
  }
}

MCP tools: run_command (clean output + exit code), read_screen, send_keys, send_signal (Ctrl-C / EOF).

REST fallback:

bash
curl -s -X POST https://<your-tunnel>.trycloudflare.com/<access-code>/api/agent/run \
  -H "content-type: application/json" \
  -d '{"command":"echo hello","timeout":30}'

The response includes a session_id; reuse it with <url>/api/agent/screen, <url>/api/agent/keys, <url>/api/agent/signal, and DELETE <url>/api/agent/session.

When you open Porterminal on your phone, the top-right copy button copies the same agent-ready share text. Browser-only agents also get a fallback on the base page: a DOM-readable Terminal screen mirror and a clearly labeled Terminal input.

Security: <url> means the complete generated URL, including its random access code. The bare tunnel hostname exposes nothing, but anyone (or any agent) with the complete URL gets full, non-elevated shell access. See docs/agent-access.md.

Mobile Gestures

GestureAction
TapFocus terminal, clear selection
Long-pressStart text selection
Double-tapSelect word
Swipe left/rightArrow keys (← →)
ScrollMomentum scrolling with physics
PinchZoom text (10-24px)

Modifier keys (Ctrl, Alt, Shift): Tap once for sticky (one keystroke), double-tap for lock.

Compose mode (▤ button): Toggle a text input field where you can type or dictate, edit your text with full mobile editing features (autocorrect, suggestions, cursor positioning), then send to terminal. Useful for longer commands or voice input.

Configuration

Run ptn --init to create a starter config. It auto-discovers project scripts from package.json, pyproject.toml, or Makefile and adds them as buttons:

bash
ptn -i
# Created: .ptn/ptn.yaml
# Discovered 3 project script(s): build, dev, test

Or create ptn.yaml manually:

yaml
# Terminal settings
terminal:
  default_shell: nu              # Default shell ID
  shells:                        # Custom shell definitions
    - id: nu
      name: Nushell
      command: nu
      args: []

# Custom buttons (appear in toolbar)
# row: 1 = default row, 2+ = additional rows
buttons:
  - label: "claude"
    send:
      - "claude"
      - 100        # delay in ms
      - "\r"
  - label: "build"
    send: "npm run build\r"
    row: 2         # second button row

# Update checker settings
update:
  notify_on_startup: true   # Show update notification
  check_interval: 86400     # Seconds between checks (default: 24h)

# Security settings
security:
  require_password: true    # Always require password at startup
  password_hash: ""         # Saved password hash (use ptn -sp to set)
  max_auth_attempts: 5      # Max failed attempts before disconnect

Config is searched in order: $PORTERMINAL_CONFIG_PATH, ./ptn.yaml, ./.ptn/ptn.yaml, ~/.ptn/ptn.yaml.

Security

Every launch creates a new 128-bit random path such as https://<tunnel>.trycloudflare.com/<access-code>/. All browser, WebSocket, MCP, REST, health, and static routes require that exact prefix; the bare host and wrong paths return 404. This makes brute-forcing a discovered tunnel hostname impractical.

The complete generated URL is still a bearer credential: anyone who gets it has shell access. Restart Porterminal to rotate the code if it leaks. The optional password adds authentication to browser WebSockets, but MCP and REST continue to trust the complete URL so agents can use the one-link workflow.

A browser remembers a successful password in plaintext storage scoped to that complete launch URL. Saving a password for a newer launch on the same origin retires older Porterminal password entries; clearing or rejecting a remembered password removes them all without touching other browser storage. Consequently, concurrent launches on the same origin may prompt again, while an already authenticated connection remains connected.

From the UI: Open Settings (gear icon) and use the Security section to set/change password and toggle password requirement. Changes require server restart.

From CLI:

bash
# One-time password (prompt each session)
ptn -p

# Save password to config (no prompt needed)
ptn -sp
# Password: ****
# Confirm password: ****

# Clear saved password (enter empty password)
ptn -sp
# Password: [press Enter]

# Set or toggle password requirement
ptn -tp          # Toggle on/off

See docs/security.md for details.

Troubleshooting

Connection fails? Use the complete generated URL, including its access code. Cloudflare tunnel issues can also be resolved by restarting the server (Ctrl+C, then ptn) for a fresh tunnel and access path.

uvx ptn still runs an older version? An existing uv tool installation can take precedence. Run uv tool upgrade ptn, or bypass installed tools with uvx --isolated ptn@latest.

Shell not detected? Set your $SHELL environment variable or configure shells in ptn.yaml.

c/u says "Clipboard unavailable" on Linux? Porterminal copies through the system's own tool, and Ubuntu desktop ships none: install wl-clipboard (Wayland) or xclip/xsel (X11). Without one, Porterminal can only send an OSC 52 terminal-clipboard sequence, which GNOME Terminal and other VTE-based terminals ignore and no terminal ever confirms, so the URL is shown on screen instead. Set PORTERMINAL_DISABLE_OSC52_CLIPBOARD=1 to turn the OSC 52 fallback off entirely for terminals that misbehave on it.

Contributing

This project does not accept external contributions (pull requests or code changes) for security reasons (see CONTRIBUTING.md). You're welcome to fork and run your own copy under AGPL-3.0.

Run from source:

bash
git clone https://github.com/lyehe/porterminal
cd porterminal
uv sync --frozen
uv run --frozen ptn

License

AGPL-3.0

Cài đặt

TypingMind
{
  "mcpServers": {
    "porterminal": {
      "command": "ptn",
      "args": []
    }
  }
}

Dùng MCP Porterminal với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Porterminal, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Porterminal làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Porterminal.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "porterminal": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Porterminal, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Porterminal.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Porterminal giúp tôi làm việc này không?
Porterminal
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Porterminal.

Câu hỏi thường gặp

Máy chủ MCP Porterminal dùng để làm gì?

Porterminal là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Porterminal với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Porterminal với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Porterminal với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Porterminal, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Porterminal với TypingMind?

Porterminal hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Porterminal cung cấp những công cụ nào trong TypingMind?

Porterminal cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Porterminal không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Porterminal yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇