A secure MCP server for browsing directories and files with access control
Project description
Directory Browser MCP Server
一个用于浏览目录和文件的MCP (Model Context Protocol) 服务器。
功能特性
- 📁 目录浏览 - 列出指定目录的内容
- 📄 文件信息 - 获取文件/目录的详细信息
- 🔍 权限检查 - 检查路径的访问权限
- 🛡️ 安全控制 - 基于白名单的目录访问控制
安装
cd directory_browser_mcp
pip install -e .
配置
编辑 config.json 文件来配置允许访问的目录:
{
"allowed_directories": [
"/Users/用户名/Documents",
"/Users/用户名/Desktop",
"/项目根目录"
],
"show_hidden_files": false,
"max_entries": 1000
}
使用方法
作为MCP服务器运行
python -m directory_browser_mcp
可用工具
-
list_directory - 列出目录内容
path: 目录路径show_hidden: 是否显示隐藏文件 (可选)
-
get_file_info - 获取文件详细信息
path: 文件或目录路径
-
check_path_access - 检查路径访问权限
path: 要检查的路径
安全特性
- ✅ 白名单目录访问控制
- ✅ 路径穿越攻击防护
- ✅ 文件系统权限检查
- ✅ 安全错误处理
示例
# 列出目录
{
"tool": "list_directory",
"arguments": {
"path": "/Users/username/Documents",
"show_hidden": false
}
}
# 获取文件信息
{
"tool": "get_file_info",
"arguments": {
"path": "/Users/username/Documents/file.txt"
}
}
# 检查访问权限
{
"tool": "check_path_access",
"arguments": {
"path": "/Users/username/Documents"
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file directory_browser_mcp-0.1.4.tar.gz.
File metadata
- Download URL: directory_browser_mcp-0.1.4.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1395afa16450db691a57270170739c5187189d9dac4343727965ed63dcd6fa87
|
|
| MD5 |
481b6050825fa59000422b542dbebd31
|
|
| BLAKE2b-256 |
28bf5663b85e0ac824965903b5cbb627eb2dc50bd4b63a1a545665a3d61fcc1e
|
File details
Details for the file directory_browser_mcp-0.1.4-py3-none-any.whl.
File metadata
- Download URL: directory_browser_mcp-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
097925b51e586d5043370d566fb819822ea33224f79062a593eea910be0c31c4
|
|
| MD5 |
2bf45f61bf09322d5a88eb270b2b474a
|
|
| BLAKE2b-256 |
ead7674e068a8e302aaf0dd5878ad0fea968df2dd9d124186f16b20b9b287428
|