KoyoYeager/mcp-pystub
Python exe スタブ最適化 MCP サーバー / Auto-detect stubbable packages for Python exe builds
Platform-specific configuration:
{
"mcpServers": {
"mcp-pystub": {
"command": "npx",
"args": [
"-y",
"mcp-pystub"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
<!-- mcp-name: io.github.KoyoYeager/pystub -->
Python exe ビルド(PyInstaller / Nuitka / cx_Freeze)時にスタブ置換可能なパッケージを自動検出し、最小スタブコードを生成する MCP サーバー。
---
An MCP server that auto-detects stubbable packages for Python exe builds (PyInstaller / Nuitka / cx_Freeze) and generates minimal stub code to reduce executable size.
Python アプリを exe 化すると、依存ライブラリがモジュールレベルで import する重量パッケージが丸ごと同梱され、exe サイズが膨張する。実際のコードパスで使わないパッケージは最小ダミー(スタブ)で置換すれば大幅なサイズ削減が可能。
When building Python apps into executables, heavy packages imported at module level by dependencies get bundled entirely, bloating the exe size. Replacing unused packages with minimal stubs can significantly reduce size.
asammdf プロジェクト — PyInstaller exe ビルド(E2E 動作確認済み):
| | exe サイズ | 動作 | PySide6 | |---|---|---|---| | スタブなし | 431 MB | OK | ロード済み | | asammdf.gui スタブ適用 | 259 MB | OK | 排除 | | 削減 | -40%(172 MB) | 影響なし | |
asammdf 変換ツール(analyze 結果):
stubbable: pandas (59.7 MB), canmatrix (4.0 MB) — 合計 63.7 MB
submodule hints: asammdf.gui → PySide6 (523 MB) 排除可能 — 50 hints 検出> 手動でスタブ化していた 3 パッケージ(pandas, canmatrix, asammdf.gui)を全て自動検出
| ツール / Tool | 説明 / Description | |---|---| | analyze | import グラフを解析しスタブ候補を自動検出。C拡張パッケージの間接排除ヒントも出力 / Auto-detect stubbable packages + submodule stub hints for C-extension elimination | | graph | import グラフをノード・エッジで可視化 / Visualize import graph as nodes and edges | | check | 特定パッケージの使用状況を詳細分析 / Deep analysis of a specific package's usage | | generate | パッケージスタブの最小コードを生成 + ビルド手順出力 / Generate minimal stub code + build instructions | | generate_submodule | C拡張パッケージを間接排除するサブモジュールスタブを生成 / Generate submodule stubs to indirectly eliminate C-extension packages |
| 判定 / Verdict | 意味 / Meaning | |---|---| | stubbable | スタブ化可能。プロジェクトの実行パスで未使用 / Safe to stub. Not used in project's runtime path | | nofollow | try/except 保護あり。`--nofollow-import-
Loading reviews...