# DanielAvdar
## 基本信息
- Slug: `danielavdar-dev-kit-mcp-server`
- Source: modelscope
- Publisher: @DanielAvdar/dev-kit-mcp-server
- Categories: developer-tools / code-execution / file-systems
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@DanielAvdar/dev-kit-mcp-server
## 简介
暂无描述。
## MCP Server 详情

# Dev-Kit MCP 服务器

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dev-kit-mcp-server)](https://pypi.org/project/dev-kit-mcp-server/)
[![version](https://img.shields.io/pypi/v/dev-kit-mcp-server)](https://img.shields.io/pypi/v/dev-kit-mcp-server)
[![License](https://img.shields.io/:license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![OS](https://img.shields.io/badge/ubuntu-blue?logo=ubuntu)
![OS](https://img.shields.io/badge/win-blue?logo=windows)
![OS](https://img.shields.io/badge/mac-blue?logo=apple)
[![Tests](https://github.com/DanielAvdar/dev-kit-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/DanielAvdar/dev-kit-mcp-server/actions/workflows/ci.yml)
[![Code Checks](https://github.com/DanielAvdar/dev-kit-mcp-server/actions/workflows/code-checks.yml/badge.svg)](https://github.com/DanielAvdar/dev-kit-mcp-server/actions/workflows/code-checks.yml)
[![codecov](https://codecov.io/gh/DanielAvdar/dev-kit-mcp-server/graph/badge.svg?token=N0V9KANTG2)](https://codecov.io/gh/DanielAvdar/dev-kit-mcp-server)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Last Commit](https://img.shields.io/github/last-commit/DanielAvdar/dev-kit-mcp-server/main)

这是一个面向代理开发工具的模型上下文协议（MCP）服务器，提供在根项目目录中进行范围授权操作的功能。该软件包支持安全执行诸如运行makefile命令、移动和删除文件等操作，并计划在未来增加更多代码编辑工具。它作为VS-Code Copilot和其他AI辅助开发工具的优秀MCP服务器。

<a href="https://glama.ai/mcp/servers/@DanielAvdar/dev-kit-mcp-server">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/@DanielAvdar/dev-kit-mcp-server/badge" alt="dev-kit-mcp-server MCP server" />
</a>

## 特性

- 🔒 **安全操作**：在指定范围内授权的根目录中执行操作
- 🛠️ **Makefile 命令执行**：在项目内安全地运行Makefile命令
- 📁 **文件操作**：在授权目录内移动、创建、重命名和删除文件
- 🔄 **Git 操作**：执行如状态查看、添加、提交、推送、拉取和检出等Git操作
- 🔌 **MCP 集成**：将任何代码库转换为符合MCP标准的系统
- 🤖 **AI 辅助开发**：与VS-Code Copilot及其他AI工具良好集成
- 🔄 **可扩展框架**：轻松添加新的代码编辑工具及其他操作
- 🚀 **高性能**：基于FastMCP构建，确保高性能

## 安装

bash
pip install dev-kit-mcp-server


## 使用方法

### 运行服务器

bash
# 推荐的方法（指定了根目录）
dev-kit-mcp-server --root-dir=workdir

# 使用自定义TOML文件预定义命令
dev-kit-mcp-server --root-dir=workdir --commands-toml=custom_commands.toml

# 替代方法
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**: 删除授权根目录内的文件- **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 命令

#### 预定义命令
- **predefined_commands**: 从 TOML 文件执行预定义命令（默认：pyproject.toml 中的 [tool.dkmcp.commands] 部分）

预定义命令的 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 文件中定义命令的简单示例：

toml
# custom_commands.toml
[tool.dkmcp.commands]
# 基本命令
hello = "echo Hello, World!"
date = "date"

# 开发命令
test = "pytest"
lint = "ruff check ."
build = "python setup.py build"


### 使用 MCP 客户端的示例

python
from fastmcp import Client
async def example():
    async with Client() as client:
        # 列出可用工具
        tools = await client.list_tools()

        # 文件操作
        # 创建一个目录
        result = await client.call_tool("create_dir", {"path": "new_directory"})

        # 移动一个文件
        result = await client.call_tool("move_dir", {"path1": "source.txt", "path2": "destination.txt"})

        # 删除一个文件
        result = await client.call_tool("remove_file", {"path": "file_to_remove.txt"})

        # 重命名一个文件
        result = await client.call_tool("rename_file", {"path": "old_name.txt", "new_name": "new_name.txt"})

        # 编辑一个文件
        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 操作
        # 获取仓库状态
        result = await client.call_tool("git_status")

        # 将文件添加到索引
        result = await client.call_tool("git_add", {"paths": ["file1.txt", "file2.txt"]})

        # 提交更改
        result = await client.call_tool("git_commit", {"message": "Add new files"})

        # 从远程拉取更改
        result = await client.call_tool("git_pull", {"remote": "origin", "branch": "main"})

        # 将更改推送到远程
        result = await client.call_tool("git_push")

        # 检出一个分支
        result = await client.call_tool("git_checkout", {"branch": "feature-branch", "create": True})

        # Makefile 操作
        # 运行一个 makefile 命令
        result = await client.call_tool("exec_make_target", {"commands": ["test"]})

        # 预定义命令
        # 执行一个预定义命令
        result = await client.call_tool("predefined_commands", {"command": "test"})

        # 执行带有参数的预定义命令
        result = await client.call_tool("predefined_commands", {"command": "test", "param": "specific_test"})


## 开发

### 设置

bash
# 克隆仓库
git clone https://github.com/DanielAvdar/dev-kit-mcp-server.git
cd dev-kit-mcp-server

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest


### 贡献

欢迎贡献！请随时提交 Pull Request。

## 许可证此项目采用MIT许可证进行授权 - 详情请参见LICENSE文件。

