npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcpcn/mcp-port-manager

v1.0.4

Published

端口管理及释放 MCP Server - 列出端口占用与进程信息,支持释放指定端口(跨平台)。

Readme

端口管理及释放 MCP

这是一个基于 Model Context Protocol (MCP) 的“端口管理及释放”服务,提供:

  • 列出本机当前正在使用的端口以及对应的占用进程
  • 查询指定端口的占用详情,并可选择终止进程释放端口

跨平台支持:Windows / macOS / Linux。尽量使用系统自带命令,无需额外安装。

功能概览

  • list-ports
    • 列出端口占用信息,支持按协议、状态、端口/范围、PID、进程名等过滤
  • port-info
    • 查看特定端口的占用详情
    • 可选参数 kill=true 终止对应进程(force=true 强制)

安装与构建

cd typescript/端口管理及释放
npm install
npm run build

运行

node dist/index.js

你也可以通过 MCP 客户端(如 Claude/Cursor)调用内置工具。

MCP 配置示例

以 Cursor/Claude 为例,添加配置(路径按你的本地实际调整):

{
"mcpServers": {
"mcp-port-manager": {
"command": "node",
"args": [
"D:/Work/Projects/vscode/skills/typescript/端口管理及释放/dist/index.js"
      ]
    }
  }
}

工具说明

1) list-ports

参数(均可选):

  • protocol: "all" | "tcp" | "udp"
  • state: "all" | "listen" | "established"
  • port: number
  • portRange: "3000-4000"
  • pid: number
  • processName: string(包含匹配,不区分大小写)
  • includeSystem: boolean(预留)

返回:文本化列表(每条包含协议、本地地址:端口、状态、PID、进程名等)

示例:

  • 列出所有监听端口:
    • 调用:list-ports { "state": "listen" }
  • 列出 3000-4000 范围内的 TCP 端口:
    • 调用:list-ports { "protocol": "tcp", "portRange": "3000-4000" }

2) port-info

参数:

  • port: number(必填)
  • protocol: "auto" | "tcp" | "udp"(默认 "auto")
  • kill: boolean(默认 false)
  • force: boolean(默认 false)

返回:

  • 端口占用详情;如 kill=true 会附带终止结果

示例:

  • 查看 3000 端口占用:
    • 调用:port-info { "port": 3000 }
  • 强制释放 3000 端口:
    • 调用:port-info { "port": 3000, "kill": true, "force": true }

跨平台说明

  • Windows:
    • 查询:netstat -ano(配合 tasklist 解析进程名)
    • 终止:taskkill /PID [/F]
  • Linux:
    • 查询:ss -tunap 或 netstat -tunlp;必要时使用 lsof -nP -i
    • 终止:kill 或 kill -9
  • macOS:
    • 查询:lsof -nP -i
    • 终止:kill / kill -9

注意:某些命令可能需要管理员/提升权限;缺少权限时会返回相应错误信息。

安全提示

  • 终止进程可能导致业务中断。建议先仅查询,确认后再加 kill=true(必要时再 force=true)。
  • 生产环境操作需谨慎,建议在变更窗口进行,并有回滚预案。

开发

  • TypeScript 构建至 dist/index.js
  • 仅依赖 @modelcontextprotocol/sdk(最小依赖)