Skip to main content

OpenWrt MCP Controller

This project provides a Model Context Protocol (MCP) server for managing OpenWrt devices. It allows you to interact with and control an OpenWrt router through a simple API.

The server utilizes fastmcp to expose OpenWrt functionalities as tools that can be called remotely.

1. Prerequisites

For the server to have full functionality, a custom LuCI RPC script must be placed on the target OpenWrt device.

Install sys.lua on OpenWrt

The sys.lua file in this repository extends the capabilities of the LuCI JSON-RPC interface. You must copy this file to your OpenWrt router for tools like system_status, network_status, and set_led_state to work.

  1. Copy the file to your OpenWrt device: Use scp or any other file transfer method to copy sys.lua to your router.

    scp sys.lua root@<your_openwrt_ip>:/usr/lib/lua/luci/sys.lua
    
  2. Verify Permissions: Ensure the file has the correct permissions.

    ssh root@<your_openwrt_ip> "chmod 644 /usr/lib/lua/luci/sys.lua"
    

2. Installation

You can install this package directly from PyPI.

pip install openwrt-mcp

3. Configuration

The server is configured through environment variables. You must set the following before running the server:

  • OPENWRT_HOST: The full URL of your OpenWrt device (e.g., http://192.168.1.1).
  • OPENWRT_PASSWORD: The login password for your OpenWrt device.
  • OPENWRT_USERNAME: (Optional) The login username. Defaults to root.

Example:

export OPENWRT_HOST="http://192.168.1.1"
export OPENWRT_PASSWORD="your_secret_password"

4. Usage

Once installed and configured, you can start the MCP server with the following configuration:

{
    "mcpServers":{
        "openwrt-mcp":{
            "command":"uvx",
            "args": [
                "openwrt-mcp"
            ],
            "env":{
                "OPENWRT_HOST":"192.168.0.1",
                "OPENWRT_PASSWORD":"root",
                "OPENWRT_USERNAME":"12345678"
            }
        }
    }
}

The server will start and listen for incoming connections via standard I/O.

Available Tools

The following tools are exposed by the MCP server:

  • reboot(): Reboots the OpenWrt device.
  • system_status(): Retrieves system and board information.
  • network_status(): Gets the status of all network interfaces.
  • read_log(): Reads the system log (logread).
  • set_led_state(state: str): Sets the state of the "Green" LED. state can be 'on' or 'off'.
  • summary_log(): Provides a structured prompt template for an AI to summarize the output of read_log().

Metadata

Release files for openwrt-mcp 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openwrt-mcp 0.1.7
File Size Uploaded Provenance
openwrt_mcp-0.1.7.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openwrt-mcp 0.1.7
File Interpreter ABI Platform
openwrt_mcp-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / openwrt_mcp-0.1.7.tar.gz

Download URL openwrt_mcp-0.1.7.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e73d4a083b17b955027fe1d6954555a20c80253cb1dc1447c0c998c02d3f827e
BLAKE2b-256 checksum
How to use checksums
a3cfcf52d4153790908004686c8c74db987702c800d31951ad4ca279e999342a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / openwrt_mcp-0.1.7-py3-none-any.whl

Download URL openwrt_mcp-0.1.7-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d77abc21333e21ad62ed4ab0431b2d338039672b88336ab9c7b6fe43fcf18cc
BLAKE2b-256 checksum
How to use checksums
b42cf6be33bca50c5fb6bba616a8f01c5935c19398ec972457dedc3a51a806e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for openwrt-mcp 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page