Rust代码质量分析工具

为Rust开发提供代码检查、测试、构建和文档生成等全面质量分析的工具套件。

  • by GeorgePearse
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 GeorgePearse/bacon-mcp

使用说明

培根mcp

用于Rust开发的MCP(模型上下文协议)服务器,灵感来自 培根.

为AI助手提供工具,用于检查、整理、测试和构建Rust项目,并进行全面的代码质量分析。

特性

核心工具

  • baconcheck -通过快速编译检查 cargo check
  • baconbuild -带有错误报告的完整版本
  • bacontest -运行并报告测试结果
  • bacon.doc -文档生成和检查

棉绒与质量

  • bac_clippy -具有多种棉绒组的综合棉绒:
    • pedantic -特别严格的检查(缺少文档、拆包使用)
    • nursery -实验性lints(可能有假阳性)
    • cargo -Cargo.toml检查(通配符deps,缺少元数据)
    • restriction -非常严格的lints(恐慌、打开包装、期待)
    • 自定义 allow, warn, deny 棉绒配置
  • bacn_clippy_strict -最严格(迂腐+托儿所+货物,拒绝警告)
  • bac_质量 -综合质量报告(剪贴簿+fmt+doc)

格式化

  • bacon_fmt -使用rustfmt自动格式化代码
  • bacon_fmt-check -检查格式而不进行修改

安全性和依赖性

  • bac_审计 -安全漏洞扫描
  • 否认 -许可证、安全和重复检查
  • bac_过时 -检查过时的依赖关系
  • bacon_udeps(英语:bacon_udeps) -查找未使用的依赖项(每晚都需要)
  • 大麻 -快速检测未使用的依赖关系

信息

  • rust_project_info -项目元数据

安装

cd bacon-mcp
npm install
npm run build

使用Claude代码

添加到您的Claude Code MCP配置中(~/.claude/mcp.json):

{
  "mcpServers": {
    "bacon": {
      "command": "node",
      "args": ["/path/to/bacon-mcp/dist/index.js"]
    }
  }
}

工具

bac_clippy

使用可配置的严格级别运行Clippy过梁。

path: /path/to/rust/project
pedantic: true       # Extra strict checks
nursery: true        # Experimental lints
cargo: true          # Cargo.toml lints
restriction: true    # Very strict (usually too much)
deny_warnings: true  # Treat warnings as errors (for CI)
fix: true            # Auto-apply fixes
allow: ["clippy::too_many_arguments"]  # Ignore specific lints
warn: ["clippy::unwrap_used"]          # Warn on specific lints
deny: ["clippy::panic"]                # Error on specific lints

bacn_clippy_strict

最高的代码质量-运行迂腐+托儿所+货物,警告被拒绝。

path: /path/to/rust/project
fix: true   # Auto-apply fixes

bac_质量

综合质量检查结合:

  • Clippy(迂腐+托儿所)
  • 格式检查
  • 文件检查
path: /path/to/rust/project

否认

检查许可证、安全性和重复项的依赖关系。

path: /path/to/rust/project
check: "all"          # all, advisories, bans, licenses, sources

bac_过时

检查是否存在过时的依赖关系。

path: /path/to/rust/project
depth: 1   # How deep in dependency tree (1 = direct only)

大麻

快速检测未使用的依赖关系。

path: /path/to/rust/project
fix: true   # Auto-remove unused deps

baconcheck

快速编译检查。

path: /path/to/rust/project
all_targets: true    # Check tests, examples, bins
all_features: true   # Enable all features

bacontest

运行测试并报告结果。

path: /path/to/rust/project
filter: "test_name"  # Run matching tests only
no_capture: true     # Show test output

baconbuild

编译项目。

path: /path/to/rust/project
release: true       # Optimized build
all_targets: true   # Build everything

bacon.doc

生成文档。

path: /path/to/rust/project
no_deps: true           # Skip dependency docs
document_private: true  # Include private items
open: true              # Open in browser

可选货物扩展

要获得完整功能,请安装以下货物扩展:

# Security auditing
cargo install cargo-audit

# Comprehensive dependency checking
cargo install cargo-deny

# Outdated dependency detection
cargo install cargo-outdated

# Unused dependency detection (fast, no nightly required)
cargo install cargo-machete

# Unused dependency detection (thorough, requires nightly)
cargo install cargo-udeps

需求

  • Node.js 18+
  • 防锈工具链(rustup, cargo, clippy, rustfmt)

许可证

麻省理工学院