MCP server for querying Linux kernel docs, code, and APIs.
Project description
linux-kernel-mcp
linux-kernel-mcp is an MCP server that lets Codex look up Linux kernel
documentation, upstream source files, release information, and optional local
kernel source trees.
Chinese documentation is available in README.zh-CN.md.
You do not need a local Linux checkout to use the remote documentation tools. Local source-tree search is optional and can be enabled later when you have a kernel tree on your machine.
Quick Start
Register the server with Codex:
codex mcp add linux_kernel -- uvx linux-kernel-mcp
Restart Codex after adding the MCP server.
After that, ask Codex kernel-related questions such as:
Search the latest Linux kernel docs for GPIO descriptor APIs.
Fetch the upstream implementation of drivers/gpio/gpiolib.c around line 200.
What is the latest stable Linux kernel release?
What Works Without A Local Kernel Tree
These features work immediately after installation:
- Search
docs.kernel.org - Fetch and summarize a
docs.kernel.orgpage - Query latest stable and mainline releases from
kernel.org - Open online source-browsing entry points for kernel symbols
- Fetch files from the upstream Torvalds tree through Gitiles
- Build high-level implementation checklists for kernel-facing tasks
This is enough for documentation lookup, API research, and comparing against latest upstream code.
Optional Local Kernel Tree
If you also have a Linux kernel source tree locally, enable local inspection in one of two ways.
Set a default before starting Codex:
export LINUX_KERNEL_TREE=/path/to/linux
Or set it during a Codex session:
set_kernel_root("/path/to/linux")
Then local tools can search and read your tree:
search_local_kernel_api("devm_gpiod_get")
read_local_kernel_file("drivers/gpio/gpiolib.c", start_line=200)
Check the active local root:
get_kernel_root()
Use a different tree for one call:
search_local_kernel_api("platform_driver_register", root="/path/to/other/linux")
If no local tree is configured, local tools return a clear configuration error. Remote documentation and upstream source tools continue to work.
Available Tools
Remote lookup tools:
latest_kernel_releasessearch_kernel_docsfetch_kernel_docsearch_online_kernel_codefetch_upstream_kernel_fileplan_kernel_implementation
Local source-tree tools:
get_kernel_rootset_kernel_rootsearch_local_kernel_coderead_local_kernel_filesearch_local_kernel_api
Driver-planning tools:
list_driver_template_blueprints_toolget_driver_template_blueprint_toolplan_driver_scaffold
Typical Workflow
- Search the latest official docs for the subsystem or API.
- Fetch upstream source snippets when the latest implementation matters.
- Configure a local kernel tree only if you need version-specific local code.
- Search nearby local examples and API call sites.
- Ask Codex to plan the implementation and call out version-sensitive checks.
Codex Configuration
The codex mcp add command writes this configuration for you:
[mcp_servers.linux_kernel]
command = "uvx"
args = ["linux-kernel-mcp"]
To make a project always use one local kernel tree, add:
[mcp_servers.linux_kernel.env]
LINUX_KERNEL_TREE = "/path/to/linux"
Local Development
If you are working from a local checkout of this repository instead of the PyPI package, register the checkout path:
codex mcp add linux_kernel -- uvx --from /path/to/linux-kernel-mcp linux-kernel-mcp
From inside the repository, you can build and test the package:
uv build
uvx --from dist/linux_kernel_mcp-0.1.0-py3-none-any.whl linux-kernel-mcp
The command starts an MCP stdio server and waits for a client handshake, so it does not print normal CLI output.
Limitations
- The server provides lookup and planning tools; it does not guarantee that a kernel patch is correct.
- Driver scaffold planning is metadata-first today; it does not emit final C source yet.
- Upstream source lookup fetches by file path rather than by a full symbol index.
set_kernel_rootis session-local state. After an MCP restart, set it again or provideLINUX_KERNEL_TREE.
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 linux_kernel_mcp-0.1.0.tar.gz.
File metadata
- Download URL: linux_kernel_mcp-0.1.0.tar.gz
- Upload date:
- Size: 87.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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 |
f86e1e9b3f8db8592db7159e3faab18297b387240dd3139d9fc33e7b6d47e4dd
|
|
| MD5 |
e9d6d54eb617a01f4e1ed88175839d1b
|
|
| BLAKE2b-256 |
b56a640232d9e17767f5dba7e655549c53213356378d51fc7debfd6d3ce41871
|
File details
Details for the file linux_kernel_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: linux_kernel_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.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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 |
31038c1c57b698f7c32ad208f31094e2067bbb9a244fe0a4112105c3aa31b126
|
|
| MD5 |
2b5f10e6c0b96605c7db40bbec77a4a2
|
|
| BLAKE2b-256 |
3f9d69255c604a265c11600929d70d18a4efb2fc6a57a536667861df3d590f5c
|