项目资源管理器MCP服务器是一款强大的模型上下文协议(MCP)服务器,具备高级搜索功能,可用于探索、分析和管理项目文件。它能帮助开发者更高效地导航和分析项目,提供了全面的项目结构分析、代码搜索、依赖管理和文件操作工具。
将以下配置添加到您的MCP设置中:
{
"mcpServers": {
"project-explorer": {
"command": "npx",
"args": ["-y", "@team-jd/mcp-project-explorer", "/your/project/path"]
}
}
}
将此服务器添加到您的MCP设置配置中:
{
"mcpServers": {
"project-explorer": {
"command": "npx",
"args": [
"-y",
"@team-jd/mcp-project-explorer",
"/path/to/your/project"
]
}
}
}
📁 多目录访问:
{
"mcpServers": {
"project-explorer": {
"command": "npx",
"args": [
"-y",
"@team-jd/mcp-project-explorer",
"/path/to/project1",
"/path/to/project2",
"/path/to/project3"
]
}
}
}
# 克隆项目并进行开发设置
git clone https://github.com/MausRundung362/mcp-explorer.git
cd mcp-explorer
# 安装依赖
npm install
# 构建项目
npm run build
# 运行MCP检查器进行测试
npm run inspector
// 1. 检查可访问的目录
list_allowed_directories()
// 2. 探索项目结构
explore_project({
directory: "/your/project/path",
includeHidden: false
})
// 3. 搜索特定模式
search_files({
pattern: "useState",
searchPath: "/your/project/path",
extensions: [".jsx", ".tsx"],
excludeComments: true
})
// 4. 检查过时的依赖
check_outdated({
projectPath: "/your/project/path",
outputFormat: "detailed"
})
// 查找所有异步函数
search_files({
pattern: "async\\s+function",
regexMode: true,
extensions: [".js", ".ts"]
})
// 查找最近修改的大文件
search_files({
pattern: ".*",
minSize: 1000000, // 1MB+
modifiedAfter: "2024-01-01",
sortBy: "size"
})
// 查找TODO注释,排除测试文件
search_files({
pattern: "TODO|FIXME|BUG",
regexMode: true,
excludePatterns: ["*test*", "*spec*"],
excludeStrings: true
})
explore_project
分析项目结构,提供详细的文件信息和导入/导出分析。
// 基础用法
explore_project({
directory: "/path/to/project"
})
// 高级用法
explore_project({
directory: "/path/to/project",
subDirectory: "src", // 可选:专注于特定子目录
includeHidden: false // 可选:包含隐藏文件(默认:false)
})
✨ 特性:
node_modules
、.git
、dist
等)。search_files
高级文件和代码搜索,具备全面的过滤功能。
// 简单文本搜索
search_files({
pattern: "your search term",
searchPath: "/path/to/search"
})
// 带过滤器的高级搜索
search_files({
pattern: "function.*async", // 正则表达式模式
searchPath: "/path/to/search",
regexMode: true, // 启用正则表达式
caseSensitive: false, // 区分大小写
extensions: [".js", ".ts"], // 包含的文件类型
excludeExtensions: [".min.js"], // 排除的文件类型
excludeComments: true, // 跳过注释
excludeStrings: true, // 跳过字符串字面量
maxResults: 50, // 限制结果数量
sortBy: "relevance" // 排序方法
})
🎛️ 搜索选项:
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
pattern |
字符串 | ".*" |
搜索模式(文本或正则表达式) |
searchPath |
字符串 | 第一个允许的目录 | 搜索目录 |
extensions |
字符串数组 | 所有 | 仅包含这些文件类型 |
excludeExtensions |
字符串数组 | [] |
排除这些文件类型 |
excludePatterns |
字符串数组 | [] |
排除文件名模式 |
regexMode |
布尔值 | false |
将模式视为正则表达式 |
caseSensitive |
布尔值 | false |
区分大小写搜索 |
wordBoundary |
布尔值 | false |
仅匹配整个单词 |
multiline |
布尔值 | false |
多行正则表达式匹配 |
maxDepth |
数字 | 无限制 | 目录递归深度 |
followSymlinks |
布尔值 | false |
跟随符号链接 |
includeBinary |
布尔值 | false |
在二进制文件中搜索 |
minSize |
数字 | 无 | 最小文件大小(字节) |
maxSize |
数字 | 无 | 最大文件大小(字节) |
modifiedAfter |
字符串 | 无 | 文件修改日期之后 |
modifiedBefore |
字符串 | 无 | 文件修改日期之前 |
snippetLength |
数字 | 50 |
匹配周围的文本片段长度 |
maxResults |
数字 | 100 |
最大结果数量 |
sortBy |
字符串 | "relevance" |
排序方法:相关性、文件、行号、修改日期、大小 |
groupByFile |
布尔值 | true |
按文件分组结果 |
excludeComments |
布尔值 | false |
跳过注释 |
excludeStrings |
布尔值 | false |
跳过字符串字面量 |
outputFormat |
字符串 | "text" |
输出格式:文本、JSON、结构化 |
🎯 使用场景:
pattern: "TODO.*", excludeStrings: true
pattern: "console\\.log", regexMode: true
pattern: "import.*from", regexMode: true
modifiedAfter: "2024-01-01", extensions: [".js", ".ts"]
check_outdated
检查过时的npm包,并进行详细分析。
// 基本检查
check_outdated({
projectPath: "/path/to/project"
})
// 详细分析
check_outdated({
projectPath: "/path/to/project",
includeDevDependencies: true, // 包含开发依赖
outputFormat: "detailed" // 详细、摘要或原始格式
})
📋 输出格式:
detailed
- 包含版本和更新命令的完整包信息。summary
- 按类型统计过时包的数量。raw
- 原始的npm过时JSON输出。🔧 要求:
package.json
文件。delete_file
安全地删除文件或目录,具备保护机制。
// 删除文件
delete_file({
path: "/path/to/file.txt"
})
// 删除目录(需要递归标志)
delete_file({
path: "/path/to/directory",
recursive: true, // 目录需要此标志
force: false // 强制删除只读文件
})
⚠️ 安全特性:
recursive: true
。rename_file
重命名或移动文件和目录。
// 简单重命名
rename_file({
oldPath: "/path/to/old-name.txt",
newPath: "/path/to/new-name.txt"
})
// 移动到不同目录
rename_file({
oldPath: "/path/to/file.txt",
newPath: "/different/path/file.txt"
})
✨ 特性:
list_allowed_directories
显示服务器可以访问的目录。
list_allowed_directories()
🔧 使用场景:
src/
├── index.ts # 主服务器入口点
├── explore-project.ts # 项目分析工具
├── search.ts # 高级搜索功能
├── check-outdated.ts # NPM依赖检查器
├── delete-file.ts # 文件删除工具
├── rename-file.ts # 文件重命名/移动工具
└── list-allowed.ts # 目录权限检查器
npm run build # 编译TypeScript
npm run watch # 开发时的监视模式
npm run inspector # 使用MCP检查器进行测试
服务器仅在允许的目录内运行,提供以下保障:
详情请参阅LICENSE文件。
编码愉快! 🎉
使用TypeScript和模型上下文协议精心打造 ❤️