Pystub MCP server
io.github.KoyoYeager/pystub·v0.1.1Auto-detect stubbable packages for Python exe builds and generate minimal stub code
0 stars13 downloads/wk
Reviews
Write oneNobody has reviewed Pystub yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Pystub tools (4)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
analyzeプロジェクトのエントリーポイントから import グラフを解析し、 スタブ置換可能なパッケージを自動検出します。
check特定のパッケージがプロジェクト内でどのように使われているか詳細に分析します。
generatestubbable パッケージの最小スタブコードを生成します。
graphエントリーポイントからの import グラフを構築して可視化します。
Public scan report
scanner v0.1.9 · 2026-09-27 · same rubric, same numbers if you re-run it
- Code scan11 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitylocal package, no credentials required12/15
- Maintenancelast push 180 days ago8/15
- Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
How Pystub compares
Against every graded MCP server, from our own scans and uptime checks. Updated after each scan run.
- Safety score
- 82/100
- higher than 63% of 48,255 servers
- Tools
- 4
- the typical server has 7
- Tools that change things
- 0%
- typical: 0%. Fewer write tools means less an agent can break
- Downloads a week
- 13
- more than 4% of 12,191 servers with a package
What its tools let an agent do: 3 read · 1 create
Install Pystub in Claude Code, Cursor or VS Code
claude mcp add pystub -- uvx mcp-pystub
What the publisher says
From the Pystub repository's README, as published. We do not edit it. Read it on GitHub
<!-- mcp-name: io.github.KoyoYeager/pystub -->
mcp-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.
背景 / Background
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.
実証データ / Verified Results
asammdf プロジェクト — PyInstaller exe ビルド(E2E 動作確認済み):
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)を全て自動検出
機能 / Features
判定結果 / Verdicts
できること / What It Can Do
- ライブラリ非固定の汎用検出: AST 構造のみで判定。ハードコードなし
- 関数レベルの使用追跡: mdf.get() は使うが mdf.to_dataframe() は使わない → pandas は stubbable
- Call と参照の区別: isinstance(x, pd.DataFrame) は stub-safe、pd.DataFrame(data) は実使用
- クラス継承の検出: class User(BaseModel) → pydantic は required
- module-level 呼び出し検出: import 時に実行されるコードを追跡
- try/except 保護の自動検出: 保護された import は nofollow と判定
- スタブコード自動生成: 参照シンボルのみの最小スタブ + ビルド手順(バックアップ・復元・検証)
- C 拡張の自動検出: .pyd / .so を含むパッケージは直接スタブ化不可と判定
- C 拡張の間接排除 (v0.2 new): C拡張パッケージを import しているサブモジュールが未使用なら、そのサブモジュールをスタブ化して C拡張を排除可能。PySide6 (523 MB) → asammdf.gui スタブで exe 40% 削減を実証
- 復元安全設計 (v0.2 new): バックアップ + バージョン固定 pip + 検証コマンドの 3 重安全策
- PyInstaller フック情報: 無効化が必要なフックファイルを通知
できないこと・制限事項 / Limitations
- C 拡張パッケージ(.pyd / .so)は直接スタブ化すると C 拡張が欠落するため required 判定。ただし generatesubmodule で間接排除が可能**(v0.2 で対応)
- 動的 import(importlib.import_module(変数))は静的解析で追跡不可(warnings で通知)
- PyInstaller カスタムフック: スタブと衝突する場合がありフックの手動無効化が必要
- 遅延初期化パターン: init で直接呼ばず後のメソッドで使うパッケージは検出精度が下がる(安全側で required に判定)
- pip 名と import 名の不一致: python-dateutil → dateutil 等のマッピングは未対応
- ランタイムの条件分岐: if sys.version < (3,11) 内の import は静的解析で判定不可
安全性の設計方針 / Safety Policy
「stubbable と判定したが実は必要だった」は絶対に起こさない設計。判定に迷う場合は required(安全側)に倒す。逆方向の誤判定(本当は stubbable なのに required)は許容する。
解析アルゴリズム / Analysis Algorithm
Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
Pystub: common questions
- Is Pystub MCP server safe?
- Mostly: it is graded B (82/100). Read the Pystub safety report
- How do I install Pystub?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does Pystub need an API key?
- Not as far as the registry entry and our scan can tell: no credentials are declared or required.
- Is Pystub maintained?
- The last commit was 217 days ago (2026-04-01). The latest release is v0.1.1.
- How does Pystub compare with other MCP servers?
- safety score 82/100 (higher than 63% of 48,255 servers); tools 4 (the typical server has 7); tools that change things 0% (typical: 0%. Fewer write tools means less an agent can break). Full comparison.