Dev-Kit MCP 服务器



一个面向代理开发工具的模型上下文协议 (MCP) 服务器,在项目根目录中提供范围授权操作。此软件包支持安全执行诸如运行 makefile 命令、移动和删除文件等操作,并计划未来包含更多代码编辑工具。它是 VS-Code Copilot 和其他 AI 辅助开发工具的优秀 MCP 服务器。
特征
- 🔒安全操作:在范围内的授权根目录内执行操作
- 🛠️ Makefile 命令执行:在项目内安全地运行 makefile 命令
- 📁文件操作:在授权目录内移动、创建、重命名和删除文件
- 🔄 Git 操作:执行 Git 操作,如状态、添加、提交、推送、拉取和签出
- 🔌 MCP 集成:将任何代码库转变为符合 MCP 的系统
- 🤖 AI 辅助开发:与 VS-Code copilot 和其他 AI 工具完美集成
- 🔄可扩展框架:轻松添加用于代码编辑和其他操作的新工具
- 🚀快速性能:采用 FastMCP 构建,性能卓越
安装
pip install dev-kit-mcp-server
用法
运行服务器
# Recommended method (with root directory specified)
dev-kit-mcp-server --root-dir=workdir
# Alternative methods
uv run python -m dev_kit_mcp_server.mcp_server --root-dir=workdir
python -m dev_kit_mcp_server.mcp_server --root-dir=workdir
--root-dir
参数指定执行文件操作的目录。出于安全原因,这很重要,因为它将文件操作限制在该目录中。
可用工具
该服务器提供以下工具:
文件操作
- create_dir :在授权的根目录内创建目录
- edit_file :通过用新文本替换指定开始行和结束行之间的行来编辑文件
- move_dir :在授权的根目录内移动文件和目录
- remove_file :删除授权根目录内的文件
- rename_file :重命名授权根目录内的文件和目录
Git 操作
- git_status :获取 Git 存储库的状态(更改的文件、未跟踪的文件等)
- git_add :将文件添加到 Git 索引(暂存区)
- git_commit :将更改提交到 Git 存储库
- git_push :将更改推送到远程 Git 存储库
- git_pull :从远程 Git 存储库中提取更改
- git_checkout :在 Git 存储库中签出或创建分支
- git_diff :显示提交、提交和工作树等之间的差异。
Makefile 操作
- exec_make_target :在项目内安全地运行 makefile 命令
MCP 客户端使用示例
from fastmcp import Client
async def example():
async with Client() as client:
# List available tools
tools = await client.list_tools()
# File Operations
# Create a directory
result = await client.call_tool("create_dir", {"path": "new_directory"})
# Move a file
result = await client.call_tool("move_dir", {"path1": "source.txt", "path2": "destination.txt"})
# Remove a file
result = await client.call_tool("remove_file", {"path": "file_to_remove.txt"})
# Rename a file
result = await client.call_tool("rename_file", {"path": "old_name.txt", "new_name": "new_name.txt"})
# Edit a file
result = await client.call_tool("edit_file", {
"path": "file_to_edit.txt",
"start_line": 2,
"end_line": 4,
"text": "This text will replace lines 2-4"
})
# Git Operations
# Get repository status
result = await client.call_tool("git_status")
# Add files to the index
result = await client.call_tool("git_add", {"paths": ["file1.txt", "file2.txt"]})
# Commit changes
result = await client.call_tool("git_commit", {"message": "Add new files"})
# Pull changes from remote
result = await client.call_tool("git_pull", {"remote": "origin", "branch": "main"})
# Push changes to remote
result = await client.call_tool("git_push")
# Checkout a branch
result = await client.call_tool("git_checkout", {"branch": "feature-branch", "create": True})
# Makefile Operations
# Run a makefile command
result = await client.call_tool("exec_make_target", {"commands": ["test"]})
发展
设置
# Clone the repository
git clone https://github.com/DanielAvdar/dev-kit-mcp-server.git
cd dev-kit-mcp-server
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。