Skip to main content
Glama
README.md
# 屎山代码质量分析工具 (Fuck-U-Code-MCP)

一个基于MCP协议的屎山代码质量分析服务,旨在让你的AI写出高质量的代码。

## 功能特性

- **多语言支持**: Go、JS/TS、Python、Java、C/C++
- **屎山指数**: 0~100 分,越高越烂
- **七维度检测**: 复杂度 / 函数长度 / 注释率 / 错误处理 / 命名 / 重复度 / 结构
- **彩色终端报告**: 批评也能笑着听
- **Markdown 输出**: 方便 AI 分析与文档集成
- **灵活配置**: 摘要 / 详细模式,多语言报告

## 安装依赖

### 使用pip安装

```bash
pip install -r requirements.txt
```

### 使用uv安装(推荐)

```bash
# 安装uv(如果尚未安装)
pip install uv

# 使用uv安装依赖
uv pip install -r requirements.txt
```

## 启动服务

```bash
python fuck-u-code-mcp.py
```

## 在Cursor中配置MCP

在Cursor中使用此工具,需要在设置中配置MCP服务器:

```json
{
  "mcpServers": {
    "fuck-u-code-mcp": {
      "command": "python",
      "args": [
        "fuck-u-code-mcp.py"
      ]
    }
  }
}
```

或者使用uv运行:

```json
{
  "mcpServers": {
    "fuck-u-code-mcp": {
      "command": "uv",
      "args": [
        "run",
        "python",
        "/项目路径/fuck-u-code-mcp.py"
      ]
    }
  }
}
```

## 使用方法

通过MCP客户端调用 `fuck_u_code_mcp` 工具,必须传入要分析的文件或目录路径,以及以下选项:

### 参数说明

- `path` (必需): 要分析的文件或目录路径
- `options` (可选): 分析选项

### 常规选项

| 选项 | 简写 | 描述 |
|------|------|------|
| --verbose | -v | 显示详细报告 |
| --top N | -t | 最烂的前 N 个文件 |
| --issues N | -i | 每文件显示 N 个问题 |
| --summary | -s | 只看总结,不看过程 |
| --markdown | -m | 输出 Markdown 格式报告 |
| --lang | -l | 报告语言 (zh-CN/en-US) |
| --exclude | -e | 排除指定目录或文件 |
| --skipindex | -x | 跳过 index.js/ts 文件 |

### 使用示例

```python
# 通过MCP客户端调用(必须提供path参数)
result = client.call_tool("fuck_u_code_mcp", {
    "path": ".",  # 分析当前目录
    "options": {
        "verbose": True
    }
})

result = client.call_tool("fuck_u_code_mcp", {
    "path": "/path/to/your/project",  # 分析指定目录
    "options": {
        "top": 3
    }
})

result = client.call_tool("fuck_u_code_mcp", {
    "path": "/path/to/your/file.py",  # 分析指定文件
    "options": {
        "lang": "en-US"
    }
})

result = client.call_tool("fuck_u_code_mcp", {
    "path": ".",  # 分析当前目录
    "options": {
        "summary": True
    }
})

result = client.call_tool("fuck_u_code_mcp", {
    "path": "/path/to/your/project",  # 分析指定目录
    "options": {
        "exclude": "**/test/**"
    }
})

result = client.call_tool("fuck_u_code_mcp", {
    "path": ".",  # 分析当前目录
    "options": {
        "markdown": True
    }
})
```

## 高级用法-Markdown 输出

适合 AI 分析、文档集成、CI/CD、团队协作

```python
# 生成Markdown报告(必须提供path参数)
result = client.call_tool("fuck_u_code_mcp", {
    "path": "/path/to/your/project",  # 分析指定目录
    "options": {
        "markdown": True
    }
})
# 将结果保存到文件
with open("report.md", "w") as f:
    f.write(result)
```

Markdown 报告包含:
- 总体评分
- 指标表格
- 问题文件
- 改进建议

## 脚本说明

项目包含两个预编译的二进制脚本:
- `fuck-u-code-for-mac`: macOS版本
- `fuck-u-code-for-win`: Windows版本

服务会根据运行环境自动选择合适的脚本执行。

## 项目参考

本项目基于 [fuck-u-code](https://github.com/Done-0/fuck-u-code.git) 项目开发,感谢原作者的贡献。

fuck-u-code是一款专门揭露屎山代码的质量分析工具,用犀利又搞笑的方式告诉你:你的代码到底有多烂。

### fuck-u-code 特性

- **多语言支持**: Go、JS/TS、Python、Java、C/C++
- **屎山指数**: 0~100 分,越高越烂
- **七维度检测**: 复杂度 / 函数长度 / 注释率 / 错误处理 / 命名 / 重复度 / 结构
- **彩色终端报告**: 批评也能笑着听
- **Markdown 输出**: 方便 AI 分析与文档集成
- **灵活配置**: 摘要 / 详细模式,多语言报告

### 原项目地址

- GitHub: [https://github.com/Done-0/fuck-u-code.git](https://github.com/Done-0/fuck-u-code.git)

本项目在原项目基础上进行了扩展,增加了MCP协议支持,使其能够在Cursor等支持MCP协议的IDE中直接使用。

## 许可证

本项目采用MIT许可证,详情请参见[LICENSE](LICENSE)文件。