MCP server for learning Python best practices through Ruff violations
Project description
Ruff Tutor MCP
Ruff violations as learning opportunities, not just auto-fixes
概要
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 をリファクタリングしてください。
以下のような形式で結果が表示されます:

Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_223mle_ruff_tutor_mcp-0.1.0.tar.gz.
File metadata
- Download URL: iflow_mcp_223mle_ruff_tutor_mcp-0.1.0.tar.gz
- Upload date:
- Size: 30.8 MB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e171d5702c38e3bb2191c3065933e49fc033e5eeaa7125f899e6357bd481ef04
|
|
| MD5 |
80599b567cb8d5596e5c2837e1b7e113
|
|
| BLAKE2b-256 |
5b2efc16303209753a5371efb8b6c595756b5f5a716e69efb3a0788941b135c8
|
File details
Details for the file iflow_mcp_223mle_ruff_tutor_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_223mle_ruff_tutor_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d765c070b2057ece57475d22f5890ae8f3b0d4745334dc92a2d5d8bd25e88a6
|
|
| MD5 |
a113f8a1d2f1c652ea5bbc548f589b69
|
|
| BLAKE2b-256 |
24ddab0bc21c7e2d178e6d90a13562a5dcdce6b065dc5fa57b21089dfc24f222
|