
Kconfig Mcp
io.github.0xmortuex由 GitHub 帳號 0xmortuex 發布v0.1.0更新於 Oct 24, 2026
Why can't I enable CONFIG_X? Explains Kconfig dependencies and finds a verified fix.
概覽
解釋 Kconfig 選項(例如 CONFIG_X)為何無法啟用,提供含檔案與行號的相依鏈,以及經過驗證的最小修正方案。
- 可以做什麼
- 將 Kconfig 原始碼樹(可附帶現有 .config)載入為具名工作階段並管理多個工作階段
- 遞迴解釋 bool 或 tristate 選項為何不是 y/m/n,附檔案與行號,並給出經驗證的最小修正及其副作用
- 檢視選項的型別、提示、值、可指定值、相依性、預設值、select/imply 雙向關係與說明文字
- 列出所有 select 或 imply 該選項的符號,並以正規表示式搜尋名稱、提示與說明文字
- 像 menuconfig 一樣指定值並回報隨之變動的其他選項,與另一份設定、defconfig 或片段比對
- 寫出 .config 或最小 defconfig
- 適用情境
- 適合在設定 Linux 核心、Zephyr、U-Boot 或 Buildroot 時,某個選項在 menuconfig 中消失或變灰,或需要在改動設定前先了解會連帶開啟或關閉哪些選項。
- 執行需求
- 在本機執行 Python 3.10+ 程序,從 PyPI 安裝 kconfig-mcp。需要含 Kconfig 檔案的原始碼樹,稀疏檢出即可,不需核心建置環境。載入 Linux 時需傳入 SRCARCH、ARCH 等架構變數,沒有編譯器時可使用 shell="dry"。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Kconfig Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
kconfig-mcp
"Why can't I enable CONFIG_X?", answered with file:line and a fix that's been checked.
kconfig-mcp is an MCP server that lets an AI agent reason about Kconfig, the configuration system used by the Linux kernel, Zephyr, U-Boot, Buildroot and others.
Everyone who has configured a kernel has hit this: the option you want isn't in
menuconfig, or it's there but greyed out, and the reason is five depends on hops
away in a different directory. kconfig-mcp walks that chain for you. Then it searches
for the smallest set of changes that would unlock the option, and applies them to
the real tree to verify they work before it shows them to you.
What it looks like
This is real output on the current Linux tree (18,913 symbols) for x86:
The same question on a 32-bit build (ARCH=i386) ends somewhere no symbol change can
reach, and the tool says so instead of inventing a fix:
Why it's built this way
- Fixes are verified, not guessed. Kconfig is full of edge cases: tristate
mneedsMODULES, bools promotemtoy, choices deselect their other members,selectoverridesdepends on, anddefault yturns things on silently. So every candidate plan is applied to the loaded tree and checked. Only plans that really reach the goal are shown as fixes, together with their side effects (what elseselect/imply/defaults switch on or off). - It parses current Linux. It's built on Kconfiglib, which hasn't had a release
since 2020 and can't parse Linux's newer
modules,transitionalanddepends on X if Ysyntax. kconfig-mcp rewrites those lines as files are read, keeping every line number exact.depends on X if Yis lowered with a line-by-line port ofexpr_trans_comparefromscripts/kconfig/expr.c, so it behaves exactly as kconfig does, including how kconfig treats!Swhen S ism. - Environment problems are named. Linux sources
arch/$(SRCARCH)/Kconfig, and an unset variable silently becomes"". kconfig-mcp tracks undefined variables and names them in the error (undefined variable(s): SRCARCH (the arch/ directory to use, ...)) instead of leaving you witharch//Kconfig not found.
Install
Python 3.10+. You don't need a kernel build environment. A source tree with its Kconfig files is enough, even a sparse checkout:
Loading trees
shell controls the tree's $(shell,...) calls, which is how Linux probes the
compiler:
"run"(default) runs them with a POSIXsh, asmake menuconfigwould. Compiler-dependent symbols then reflect your real toolchain."dry"runs nothing. Linux's probe idioms get fixed answers: feature probes read as absent, and the toolchain reports as GCC 13.2.$(error-if)checks become warnings. Results then carry a note that compiler-dependent symbols such asCC_HAS_*read as absent.
Tools
Symbol names work with or without CONFIG_. A misspelt name gets "Did you mean: ...".
Limitations
transitionalsymbols are alwaysn. Real kconfig reads them from an old.configto migrate a value during a rename. Kconfiglib has no equivalent.- The fix search is bounded. Selects and defaults are only explored when a symbol can't be reached through its own prompt, and the search has an expansion budget. If no verified fix is found, the result says whether the budget ran out or every route is genuinely blocked.
why_notcovers bool and tristate symbols. For int/hex/string symbols, usekconfig_symbolandkconfig_set.- Dry mode answers compiler probes generically (see above), so trust
CC_HAS_*-style symbols only withshell="run"on a real toolchain. - It depends on Kconfiglib 14.1.0, pinned because
compat.pyhooks two of its internal methods. CI parses the latest Linux tree every week, so the next new keyword shows up as a failing build rather than a silent wrong answer.
Tests
The fixture tree in tests/fixtures/tree exercises every construct the explainer
handles: depends on, select, imply, choice, visible if, menuconfig/if blocks,
defaults, tristate and modules, and an arch directory chosen by $(SRCARCH). The
Linux tests assert real facts, such as x2APIC's dependencies, the i386 dead end, and
the x86_64 defconfig already enabling it. CI runs them against a sparse checkout of
the current tree.
License
MIT. Kconfiglib is ISC-licensed.
來源:README.md,提交 6a23bfb
工具
0版本歷史
1- v0.1.0最新Oct 11, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分