
portview
io.github.Mapika由 GitHub 账号 Mapika 发布v2.1.0更新于 Oct 25, 2026
See what's on your ports, the processes behind them, and diagnose conflicts and leaks.
概览
一个本地 MCP 服务器,让助手列出监听端口、查看背后的进程、诊断冲突,并终止进程。
- 可以做什么
- 列出监听端口及进程详情,如 PID、用户、命令、内存和运行时长,并按进程名或命令子串查找端口。检查单个端口,包括工作目录、子进程和打开的连接。运行诊断,检查端口冲突、通配符绑定暴露、连接堆积和高内存占用。将当前端口与基线对比,查看哪些端口新开、关闭或更换了属主。终止占用某端口的进程,支持 dry-run 预览目标。
- 适用场景
- 适合助手排查本地开发服务器:查明某端口被谁占用、发现泄漏或冲突的监听、释放卡住的端口。更适合开发者在本机使用,而非共享或生产主机。
- 运行要求
- 以 stdio 方式作为本地进程运行;MCP 服务器内置于 portview 二进制中,可通过 Homebrew、安装脚本、cargo 或发布版二进制安装。未声明账号、API 密钥或环境变量。Docker 相关检查需要 docker CLI 和守护进程;SSH 功能使用系统 ssh 客户端。
安装
在 SourceWeft 中
- 打开 控制台中的 portview,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
portview
[CI] [Crates.io] [License: MIT]
portview lists ports and the processes using them on Linux, macOS, and Windows. It shows process names, commands, memory usage, and uptime. You can inspect a port, stop its process, or monitor changes in an interactive terminal UI.
It also supports Docker, remote hosts over SSH, and an MCP server for coding agents.
Install
Homebrew:
Linux / macOS:
Windows (PowerShell):
Or use cargo install portview, or download a binary from
Releases.
What it does
Features
Scan
--all includes non-listening connections, with one row per connection.
--wide shows full commands. --json produces JSON output for scripts.
Ports whose owner can't be resolved are still listed, with - in the columns that can't be filled. That happens for another user's process without sudo, and for sockets like TIME_WAIT that outlive the process that opened them.
The scan, doctor, and MCP examples below are real output, captured by
demo/record.shinside an isolated namespace — which is why the user isrootand the paths are/opt/app. The Docker example is illustrative, since it needs a running daemon.
MCP server (for AI agents)
portview mcp provides port queries, diagnostics, and process termination over
the Model Context Protocol using stdio.
To register it with Claude Code:
Or configure it manually:
The MCP server is included in the portview binary. Pass --read-only to disable
the kill_port tool:
Listed in the MCP Registry as
mcp-name: io.github.Mapika/portview.
Watch mode (interactive TUI)
Tree view (t): Groups child processes under their parents.
Detail view (Enter): Shows the full unwrapped command, working directory, child process list with ports, and open connections (in --all mode).
Doctor
portview doctor checks for port conflicts, wildcard bindings, connection
buildup, and high memory usage:
Docker is auto-detected. portview doctor --json for scripting (exit code 1 on errors).
In CI
The GitHub Action runs doctor and can fail a workflow on errors or warnings:
It annotates each finding inline on the run, writes a summary table, and exposes
findings (JSON), count, errors, and warnings as step outputs:
Set install: false if portview is already on PATH. Linux and macOS runners.
SSH remote mode
Inspect ports on a remote host over SSH:
Kill actions in the remote TUI are forwarded over SSH.
If portview is not installed on the remote host, SSH mode collects data using
ss and ps, or lsof and ps where ss is unavailable. This requires a
POSIX shell and the collection tools on the remote host.
Use --agentless to collect data this way even when portview is installed on
the remote host. It supports scans, port inspection, process search,
diagnostics, and watch mode.
Run diagnostics on the collected data:
This uses the same diagnostic checks as local mode. The Docker check is skipped because agentless mode does not query remote containers.
Watch remote ports, with process termination available in the TUI:
Watch mode collects updates through a single persistent SSH connection.
Docker integration
Use --docker to include ports published by Docker containers:
Container-only rows have no host process, so PID, UPTIME, and MEM render as -.
In watch mode, press d on a Docker row to stop or restart the container, or
follow its logs.
JSON output
Custom colors
Columns: port, proto, pid, user, process, uptime, mem, command. Use --no-color to disable.
How it works
Local port and process data comes from OS interfaces:
On Linux, portview reads the executable name from /proc/<pid>/exe.
The thread name in /proc/<pid>/comm can be changed by the runtime and is
limited to 15 bytes.
Docker integration uses the docker CLI. SSH mode uses the system ssh
client to run portview or the agentless collection tools on the remote host.
MCP mode uses newline-delimited JSON-RPC 2.0 on stdin/stdout.
Building from source
Requires Rust 1.85+ (edition 2024). Shell completions and man page are generated at build time.
The repository includes a Dockerfile. To inspect the host from a container,
share the host's network and PID namespaces:
Contributing
See CONTRIBUTING.md for development setup and guidelines, and demo/README.md for regenerating the recordings.
Changes should type-check on all three platforms, not just yours:
Limitations
- Linux: Other users' ports are listed, but naming the process needs
sudo(it reads/proc/<pid>/fd/). Rows you can't attribute show-for PID, user, process, and command rather than being hidden. - macOS: Other users' ports are not listed without
sudo— sockets are enumerated per process viaproc_pidfdinfo, so a process that can't be opened contributes nothing to enumerate. For the same reason doctor cannot detect TIME_WAIT pileups there; CLOSE_WAIT is detected normally. - Windows: Ports owned by inaccessible system processes are listed with the PID but
-for name and user. Kill always force-terminates. Run as Administrator for full detail. - Docker: Requires
dockerCLI and daemon access - SSH: every command falls back to agentless collection when portview is missing on the remote, using
ss+pson Linux andlsofwheressdoes not exist. The remote needs one of those and a POSIX shell. Agentless collection cannot see Docker on the far end, so that check reports as skipped rather than passed.
License
MIT
来源:README.md,提交 63052cd
工具
0版本历史
1- v2.1.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分