Skip to main content

Ruff Tutor MCP

Ruff violations as learning opportunities, not just auto-fixes

demo

概要

Pythonの静的解析ツール Ruff を利用し、コードの品質向上とエンジニアのスキルアップを両立させるための Model Context Protocol (MCP) サーバーです。

背景と目的

AIによるコーディング支援(Claude Code等)は強力ですが、静的解析ツールによる指摘事項が自動修正される過程で、「なぜその書き方が推奨されないのか」「正しいPythonの流儀(Pythonic)とは何か」を学ぶ機会が失われがちです。

本ツールは、単なる自動修正機能ではなく、「指摘内容の背景(PEPや設計原則)を理解した上で修正する」というプロセスをワークフローに組み込むために開発されました。

特徴

  • 📚 教育的なフィードバック: エラー検知時に、修正コードだけでなく、該当するルールの詳細・PEPへの参照・なぜそれが問題なのかという背景情報を提示します。
  • 🎯 段階的な学習モード: ユーザーの習熟度や状況に合わせて、情報の提示方法をコントロール可能です(詳細)。
  • 🧠 確実な知識定着: 安易な自動修正を防ぎ、必要に応じてユーザー自身の修正を促すことで、記憶への定着を図ります。

セットアップ

Claude Code

claude mcp add ruff-tutor -- uvx --from git+https://github.com/223mle/ruff-tutor-mcp ruff-tutor-mcp

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) または %APPDATA%\Claude\claude_desktop_config.json (Windows) に以下を追加:

{
  "mcpServers": {
    "ruff-tutor": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/223mle/ruff-tutor-mcp",
        "ruff-tutor-mcp"
      ]
    }
  }
}

学習モード

モード 説明
beginner 修正前/修正後のコード例を表示し、詳しい説明付きでユーザーに修正を促す
advanced コード例を表示せず、説明のみでユーザー自身に考えさせる
auto 説明を表示した後、自動修正を実行(デフォルト)

設定ファイル(オプション)

プロジェクトルートに .ruff-tutor.toml を配置することで、デフォルトの動作をカスタマイズできます。

# .ruff-tutor.toml
mode = "auto"  # "beginner", "advanced", "auto"
max_retry = 2      # advanced モードでの最大リトライ回数 (1-10)

使用例

Claude Codeを起動し、MCP接続後、以下のように依頼します:

@xxx.py をリファクタリングしてください。

以下のような形式で結果が表示されます: example

Metadata

Release files for iflow-mcp_223mle_ruff-tutor-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iflow-mcp_223mle_ruff-tutor-mcp 0.1.0
File Size Uploaded
iflow_mcp_223mle_ruff_tutor_mcp-0.1.0.tar.gz 30.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for iflow-mcp_223mle_ruff-tutor-mcp 0.1.0
File Interpreter ABI Platform
iflow_mcp_223mle_ruff_tutor_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 MB

Release files / iflow_mcp_223mle_ruff_tutor_mcp-0.1.0.tar.gz

Download URL iflow_mcp_223mle_ruff_tutor_mcp-0.1.0.tar.gz
Size 30.8 MB
Tags Source
SHA-256 checksum
How to use checksums
e171d5702c38e3bb2191c3065933e49fc033e5eeaa7125f899e6357bd481ef04
BLAKE2b-256 checksum
How to use checksums
5b2efc16303209753a5371efb8b6c595756b5f5a716e69efb3a0788941b135c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / iflow_mcp_223mle_ruff_tutor_mcp-0.1.0-py3-none-any.whl

Download URL iflow_mcp_223mle_ruff_tutor_mcp-0.1.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d765c070b2057ece57475d22f5890ae8f3b0d4745334dc92a2d5d8bd25e88a6
BLAKE2b-256 checksum
How to use checksums
24ddab0bc21c7e2d178e6d90a13562a5dcdce6b065dc5fa57b21089dfc24f222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page