MCP代码编辑器
先进的MCP(Model Context Protocol)服务器,提供带有AST分析、项目管理和交互式控制台集成的智能代码编辑工具。
🚀 主要特征
🔧 项目管理
- 项目结构自动分析 AST指数
- 智能文件过滤 尊重
.gitignore - 配置缓存 用于快速操作
- 项目类型自动检测 (Python、JavaScript等)
🔍 AST代码分析
- 搜索定义 使用地点
- 依赖性分析 在函数和类之间
- 结构变化检测 他们可以打破代码
- 代码指标 自动(函数计数,类,导入)
✏️ 智能文件编辑
- 修改精度 先进的DIFF系统
- 对关键变化的保护 轴承冲击分析
- 创建和删除 自动备份文件
- 用行号阅读 AST元数据
📚 书店整合
- 外部库索引 (pandas、numpy、requests等)
- 索引书店搜索 自动补全功能
- 兼容性分析 书店之间
🖥️ Consola互动
- 智能控制台进程 (Python、Node.js、CMD)
- 自动检测 从提示符到后台进程
- 多过程管理 同时的
- 捕获输出 按类型过滤
📦 安装
pip install mcp-code-editor⚙️ 配置MCP客户端
将以下设置添加到您的MCP客户端:
克劳德桌面
编辑配置文件:
- 视窗:
%APPDATA%/Claude/claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-code-editor": {
"command": "mcp-code-editor",
"args": [],
"env": {}
}
}
}其他MCP客户
{
"servers": {
"mcp-code-editor": {
"command": "mcp-code-editor",
"args": [],
"cwd": "/ruta/a/tu/proyecto"
}
}
}🛠️ 可用的工具
项目管理
setup_code_editor
分析项目结构并构建AST指数。
setup_code_editor(
path="/ruta/al/proyecto",
analyze_ast=True
)project_files
获取带有可选筛选器的项目文件。
project_files(
filter_extensions=[".py", ".js"],
max_depth=3,
format_as_tree=True
)代码分析
get_code_definition
搜索任何标识符的定义和使用位置。
get_code_definition(
identifier="function_name",
definition_type="function",
include_usage=True
)read_file_with_lines
为Python读取带有行号和AST元数据的文件。
read_file_with_lines(
path="archivo.py",
start_line=10,
end_line=50
)档案编辑
apply_diff_tool
通过自动依赖性分析实现精确的修改。
apply_diff_tool(
path="archivo.py",
blocks=[
{
"start_line": 15,
"end_line": 17,
"search_content": "def old_function():",
"replace_content": "def new_function():"
}
],
force=False
)create_file_tool
创建包含内容的新文件。
create_file_tool(
path="nuevo_archivo.py",
content="print('Hello World')",
overwrite=False
)delete_file_tool
删除具有备份选项的文件。
delete_file_tool(
path="archivo_obsoleto.py",
create_backup=True
)书店整合
index_library_tool
索引外部书店进行分析。
index_library_tool(
library_name="pandas",
include_private=False
)search_library_tool
在索引库中搜索定义。
search_library_tool(
library_name="pandas",
query="DataFrame",
definition_type="class"
)list_indexed_libraries_tool
列出所有索引书店。
list_indexed_libraries_tool()Consola互动
start_console_process_tool
启动交互式控制台进程。
start_console_process_tool(
command="python -u -i",
working_dir="/ruta/al/proyecto",
name="python_session"
)send_to_console_tool
将输入发送到具有智能检测的控制台进程。
send_to_console_tool(
process_id="process_id",
input_text="print('Hello')",
wait_for_response=True,
force_send=False
)check_console_tool
获取控制台输出快照。
check_console_tool(
process_id="process_id",
wait_seconds=2,
lines=50,
filter_type="stdout"
)list_console_processes_tool
列出活动的控制台进程 。
list_console_processes_tool(
include_terminated=False,
summary_only=True
)terminate_console_process_tool
完成控制台进程。
terminate_console_process_tool(
process_id="process_id",
force=False,
timeout=10
)🔐 安全特性
智能保护
- 影响分析 在关键修改之前
- 自动锁定 可能破坏多个文件的更改
- 依赖性警告 和受影响的文件
- 审查建议 基于AST分析
智能输入检测
- 自动预防 从发送命令到后台进程
- Prompt检测 VS正在运行的进程
- 力量模式 对于控制信号(Ctrl+C)
💡 使用案例
自动化开发
1. Configurar proyecto: setup_code_editor
2. Analizar estructura: project_files
3. Buscar función: get_code_definition
4. Modificar código: apply_diff_tool
5. Probar cambios: start_console_process_tool智能重构
1. Encontrar todas las ubicaciones: get_code_definition
2. Analizar dependencias: apply_diff_tool (sin force)
3. Revisar impacto: analizar warnings
4. Aplicar cambios: apply_diff_tool (con force si necesario)代码扫描
1. Indexar librerías: index_library_tool
2. Buscar en librerías: search_library_tool
3. Leer código con contexto: read_file_with_lines
4. Analizar dependencias: get_code_definition🐛 最佳实践
推荐协会
- python:
python -u -i(无缓冲模式 + 互动模式) - Node.js:
node(默认为REPL) - Windows CMD:
cmd - PowerShell:
powershell - 猛击:
bash
安全编辑工作流
- 总是使用
apply_diff_tool正弦force=True第一 - 审查警告和依赖性分析
- 只使用
force=True当你确定的时候 - 使用
get_code_definition了解影响
过程管理
- 使用
check_console_tool骗局wait_seconds适当的 - 检查状态
list_console_processes_tool - 清理完成的进程
cleanup_terminated_processes_tool
📚 业余文献
🤝 贡献
欢迎捐款。请:
- 叉库
- 为您的功能创建分支
- 必要时添加测试
- 发送拉动请求
📄 许可证
麻省理工学院许可证-查看文件 许可证 为了细节。
🔗 放大
- PyPI: https://pypi.org/project/mcp-code-editor/
- GitHub: https://github.com/alejoair/mcp-code-editor
- 文件: https://alejoair.github.io/mcp-code-editor/
- 问题: https://github.com/alejoair/mcp-code-editor/issues
