](https://mseep.ai/app/danielavdar-dev-kit-mcp-server)
MCP服务器开发工具包
](https://pypi.org/project/dev-kit-mcp-server/) ](https://img.shields.io/pypi/v/dev-kit-mcp-server) 
   
面向代理开发工具的模型上下文协议(MCP)服务器,在根项目目录中提供范围授权操作。此软件包支持安全执行操作,如运行makefile命令、移动和删除文件,未来计划包括更多代码编辑工具。它是VS Code副驾驶和其他人工智能辅助开发工具的优秀MCP服务器。
特性
- 🔒 安全操作:在有作用域的授权根目录中执行操作
- 🛠️ Makefile命令执行:在项目中安全地运行makefile命令
- 📁 文件操作:在授权目录中移动、创建、重命名和删除文件
- 🔄 Git操作:执行Git操作,如状态、添加、提交、推送、拉取和签出
- 🔌 MCP集成:将任何代码库转换为符合MCP的系统
- 🤖 人工智能辅助开发:与VS Code副驾驶和其他AI工具的出色集成
- 🔄 可扩展框架:轻松添加用于代码编辑和其他操作的新工具
- 🚀 快速性能:采用FastMCP构建,实现高性能
安装
pip install dev-kit-mcp-server用法
运行服务器
# Recommended method (with root directory specified)
dev-kit-mcp-server --root-dir=workdir
# With custom TOML file for predefined commands
dev-kit-mcp-server --root-dir=workdir --commands-toml=custom_commands.toml
# 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 参数指定执行文件操作的目录。出于安全原因,这很重要,因为它将文件操作限制在此目录中。
这 --commands-toml 参数允许您为预定义命令指定自定义TOML文件,而不是使用默认值 pyproject.toml 文件。当您想为不同目的定义一组单独的命令时,这很有用。
可用工具
服务器提供以下工具:
文件操作
- create_dir:在授权的根目录中创建目录
- edit_file:通过用新文本替换指定开始行和结束行之间的行来编辑文件
- move_dir:在授权的根目录中移动文件和目录
- remove_file:删除授权根目录中的文件
- 重命名文件:重命名授权根目录中的文件和目录
Git操作
- git_status:获取Git存储库的状态(已更改的文件、未跟踪的文件等)
- git_add:将文件添加到Git索引(暂存区)
- git_提交:将更改提交到Git存储库
- git_push:将更改推送到远程Git存储库
- git_pull:从远程Git存储库中提取更改
- git_checkout:在Git存储库中签出或创建分支
- 使用 git_diff:显示提交、提交和工作树等之间的差异。
Makefile操作
- exec_make_target:在项目中安全地运行makefile命令
勘探作业
- 搜索文件:在项目目录中按正则表达式模式搜索文件。支持可选的根目录和输出长度限制。
- 搜索文本:在文件中搜索与给定模式匹配的行。支持文件过滤、上下文行和输出长度限制。
- read_lines:从文件中读取特定行或范围。支持行范围选择和输出长度限制。
预定义命令
- 预定义命令:执行TOML文件中的预定义命令(默认值:\[tool.dkmcp.commans\]部分下的pyproject.TOML)
预定义命令的TOML文件格式如下:
[tool.dkmcp.commands]
test = "uv run pytest"
lint = "ruff check"
check = "uvx pre-commit run --all-files"
doctest = "make doctest"每个命令都被定义为一个键值对,其中键是命令名称,值是要执行的命令。例如,当您调用预定义的命令“test”时,它将在根目录中执行“uv run pytest”。
下面是一个如何在自定义TOML文件中定义命令的简单示例:
# custom_commands.toml
[tool.dkmcp.commands]
# Basic commands
hello = "echo Hello, World!"
date = "date"
# Development commands
test = "pytest"
lint = "ruff check ."
build = "python setup.py build"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"]})
# Exploration Operations
# Search for Python files
result = await client.call_tool("search_files", {"pattern": ".*\\.py$"})
# Search for files in a specific directory with output limit
result = await client.call_tool("search_files", {
"pattern": "test.*",
"root": "tests",
"max_chars": 1000
})
# Search for text patterns in files
result = await client.call_tool("search_text", {"pattern": "def.*test"})
# Search in specific files with context
result = await client.call_tool("search_text", {
"pattern": "import",
"files": ["main.py", "utils.py"],
"context": 2
})
# Read specific lines from a file
result = await client.call_tool("read_lines", {"file_path": "README.md", "start": 1, "end": 10})
# Read entire file with character limit
result = await client.call_tool("read_lines", {
"file_path": "config.json",
"max_chars": 500
})
# Predefined Commands
# Execute a predefined command
result = await client.call_tool("predefined_commands", {"command": "test"})
# Execute a predefined command with a parameter
result = await client.call_tool("predefined_commands", {"command": "test", "param": "specific_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贡献
欢迎投稿!请随时提交拉取请求。
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
