feat: 实现 MCP 工具集中式路径验证,增强安全性和可配置性

- 新增 path-validator.ts:参考 MCP filesystem 服务器设计的集中式路径验证器
  - 支持 CCW_PROJECT_ROOT 和 CCW_ALLOWED_DIRS 环境变量配置
  - 多层路径验证:绝对路径解析 → 沙箱检查 → 符号链接验证
  - 向后兼容:未设置环境变量时回退到 process.cwd()

- 更新所有 MCP 工具使用集中式路径验证:
  - write-file.ts: 使用 validatePath()
  - edit-file.ts: 使用 validatePath({ mustExist: true })
  - read-file.ts: 使用 validatePath() + getProjectRoot()
  - smart-search.ts: 使用 getProjectRoot()
  - core-memory.ts: 使用 getProjectRoot()

- MCP 服务器启动时输出项目根目录和允许目录信息

- MCP 管理界面增强:
  - CCW Tools 安装卡片新增路径设置 UI
  - 支持 CCW_PROJECT_ROOT 和 CCW_ALLOWED_DIRS 配置
  - 添加"使用当前项目"快捷按钮
  - 支持 Claude 和 Codex 两种模式
  - 添加中英文国际化翻译

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-12-21 18:14:06 +08:00
parent f492f4839a
commit 45f92fe066
11 changed files with 330 additions and 16 deletions

View File

@@ -290,6 +290,8 @@ const i18n = {
'codexlens.modelDeleted': 'Model deleted',
'codexlens.modelDeleteFailed': 'Model deletion failed',
'codexlens.deleteModelConfirm': 'Are you sure you want to delete model',
'codexlens.modelListError': 'Failed to load models',
'codexlens.noModelsAvailable': 'No models available',
// CodexLens Indexing Progress
'codexlens.indexing': 'Indexing',
@@ -609,6 +611,12 @@ const i18n = {
'mcp.claudeMode': 'Claude Mode',
'mcp.codexMode': 'Codex Mode',
// CCW Tools Path Settings
'mcp.pathSettings': 'Path Settings',
'mcp.useCurrentDir': 'Use current directory',
'mcp.useCurrentProject': 'Use current project',
'mcp.allowedDirsPlaceholder': 'Comma-separated paths (optional)',
// Codex MCP
'mcp.codex.globalServers': 'Codex Global MCP Servers',
'mcp.codex.newServer': 'New Server',
@@ -1617,6 +1625,8 @@ const i18n = {
'codexlens.modelDeleted': '模型已删除',
'codexlens.modelDeleteFailed': '模型删除失败',
'codexlens.deleteModelConfirm': '确定要删除模型',
'codexlens.modelListError': '加载模型列表失败',
'codexlens.noModelsAvailable': '没有可用模型',
// CodexLens 索引进度
'codexlens.indexing': '索引中',
@@ -1914,6 +1924,12 @@ const i18n = {
'mcp.claudeMode': 'Claude 模式',
'mcp.codexMode': 'Codex 模式',
// CCW Tools Path Settings
'mcp.pathSettings': '路径设置',
'mcp.useCurrentDir': '使用当前目录',
'mcp.useCurrentProject': '使用当前项目',
'mcp.allowedDirsPlaceholder': '逗号分隔的路径列表(可选)',
// Codex MCP
'mcp.codex.globalServers': 'Codex 全局 MCP 服务器',
'mcp.codex.newServer': '新建服务器',