Skip to main content

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.org page
  • 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_releases
  • search_kernel_docs
  • fetch_kernel_doc
  • search_online_kernel_code
  • fetch_upstream_kernel_file
  • plan_kernel_implementation

Local source-tree tools:

  • get_kernel_root
  • set_kernel_root
  • search_local_kernel_code
  • read_local_kernel_file
  • search_local_kernel_api

Driver-planning tools:

  • list_driver_template_blueprints_tool
  • get_driver_template_blueprint_tool
  • plan_driver_scaffold

Typical Workflow

  1. Search the latest official docs for the subsystem or API.
  2. Fetch upstream source snippets when the latest implementation matters.
  3. Configure a local kernel tree only if you need version-specific local code.
  4. Search nearby local examples and API call sites.
  5. 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_root is session-local state. After an MCP restart, set it again or provide LINUX_KERNEL_TREE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linux_kernel_mcp-0.1.0.tar.gz (87.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linux_kernel_mcp-0.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

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

Hashes for linux_kernel_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f86e1e9b3f8db8592db7159e3faab18297b387240dd3139d9fc33e7b6d47e4dd
MD5 e9d6d54eb617a01f4e1ed88175839d1b
BLAKE2b-256 b56a640232d9e17767f5dba7e655549c53213356378d51fc7debfd6d3ce41871

See more details on using hashes here.

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

Hashes for linux_kernel_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31038c1c57b698f7c32ad208f31094e2067bbb9a244fe0a4112105c3aa31b126
MD5 2b5f10e6c0b96605c7db40bbec77a4a2
BLAKE2b-256 3f9d69255c604a265c11600929d70d18a4efb2fc6a57a536667861df3d590f5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page