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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcpcn-directory-browser-mcp

v0.1.18

Published

基于 Model Context Protocol 的目录浏览与打开工具(TypeScript/Node 版本)

Readme

Directory Browser MCP Server (TypeScript)

一个使用 Node.js + TypeScript 编写的 Model Context Protocol (MCP) 服务器,用于安全地浏览与打开本地目录。新版实现了 ROOTS 协议,可以向客户端暴露经过白名单校验的根目录列表。

特性

  • 📁 目录浏览:列出指定目录的文件与子目录,支持隐藏文件过滤与数量限制
  • 📄 详细信息:获取文件/目录的尺寸、时间戳、权限等元数据
  • 🔍 权限检查:检测目标路径的读/写/执行权限,并返回安全策略结论
  • 🗂️ ROOTS 协议:通过 ROOTS 动态暴露安全的根目录,方便客户端挂载
  • 🛡️ 安全防护:内置白名单、路径穿越校验与跨平台兼容处理
  • 🖥️ 目录打开:在系统文件管理器中直接打开已校验的目录

环境要求

  • Node.js 18+
  • npm 或 pnpm / yarn 等兼容包管理器

安装与构建

# 安装依赖
npm install

# 构建 TypeScript 输出到 dist/
npm run build

# 作为 MCP 服务器运行(STDIO 传输)
npm start

开发调试可使用:

npm run dev

配置

服务器启动时会按以下优先级查找 config.json

  1. 当前工作目录:./config.json
  2. 项目目录:dist/../config.json
  3. 用户目录:~/.directory_browser_mcp/config.json

配置示例:

{
  "allowed_directories": [
    "/Users/your-name",
    "/Users/your-name/Documents",
    "/Users/your-name/Desktop"
  ],
  "show_hidden_files": false,
  "max_entries": 1000
}

字段说明:

  • allowed_directories:允许访问的根目录集合(绝对路径)
  • show_hidden_files:缺省是否展示隐藏文件
  • max_entries:单次目录列出的最大条目数

若未提供配置,将自动回退到用户主目录、Documents、Desktop 与 Downloads 的默认白名单。

可用工具

| 工具名 | 描述 | 参数 | | --- | --- | --- | | list_directory | 列出目录内容 | path (必填)、show_hidden (选填) | | get_file_info | 获取文件/目录详细信息 | path (必填) | | check_path_access | 检查路径访问权限 | path (必填) | | open_directory | 在系统文件管理器中打开目录 | path (必填) |

所有工具都会先经过安全白名单校验,未通过时会直接返回拒绝原因。

运行方式

构建后可直接使用 dist/index.js(已在 package.jsonbin 字段中声明),或将其集成到支持 MCP 的代理/客户端。STDIO 传输由 @modelcontextprotocol/sdk 提供的 StdioServerTransport 完成。

旧的 Python 实现已移至 python_src/ 目录,可按需参考或清理。

License

MIT