mcpField
O
openwrt-mcp-server

openwrt-mcp-server

Local
github.com/morninglight-elCloud & Infra30Updated 24w ago

About openwrt-mcp-server

A Rust bridge for OpenWrt and Linux edge devices that offers a single-device JSON-RPC control surface over HTTP and MQTT. It suits users who want AI agents or orchestration systems to reach a router or similar device. A standalone multi-device fleet mode and EdgePulse integration are planned but not yet implemented.

Key features

  1. 01JSON-RPC 2.0 over HTTP and MQTT
  2. 02Token authentication via x-api-token header
  3. 03Device context from ubus with Linux fallback
  4. 04Allowlisted command execution with risk metadata
  5. 05device.describe capability introspection
  6. 06TOML configuration with startup validation

Use cases

  1. 01Providing a remote control endpoint for one OpenWrt device
  2. 02Letting an AI agent read device context and status
  3. 03Running allowlisted commands on an edge device over MQTT

MCP support

The project is an MCP-style JSON-RPC bridge rather than a fully standard MCP server, and the planned EdgePulse integration and fleet service are not yet implemented.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

openwrt-mcp-server

openwrt-mcp-server is a Rust-based MCP-style bridge for OpenWrt and Linux edge devices. Today it exposes a single-device JSON-RPC control surface over HTTP and MQTT. The long-term direction is to let the Rust server also run outside OpenWrt as a standalone fleet MCP service that can manage many OpenWrt devices through EdgePulse and other device adapters.

Current deployment modes:

  • Local OpenWrt or Linux companion process for one device.
  • Remote bridge endpoint for AI agents and orchestration systems.
  • Future standalone fleet server with device registry, rule-based access control, and multi-tenant isolation.

Current Capabilities

  • HTTP API using warp.
  • MQTT transport using rumqttc.
  • JSON-RPC 2.0 request and response envelopes.
  • Token-protected HTTP endpoints via the x-api-token header.
  • TOML configuration with startup validation.
  • Real context collection from OpenWrt ubus, with Linux fallback data from /proc, /sys, and ip -j.
  • Allowlisted command execution for supported device actions.
  • device.describe capability introspection for transports, commands, command risk metadata, and context collectors.
  • Lightweight command and context registries as extension points for future modules.
  • Structured JSON logs for service, config, HTTP, and MQTT events.
  • JSON Schema documentation for command and context payloads under schema/.

Project Layout

  • src/context/collector.rs: Collects device context.
  • src/context/registry.rs: Declares built-in context collectors and extension metadata.
  • src/executor/command.rs: Dispatches allowlisted commands.
  • src/executor/registry.rs: Declares command names, required args, and risk levels.
  • src/http/routes.rs: Exposes authenticated HTTP JSON-RPC endpoints.
  • src/mqtt/handler.rs: Handles MQTT subscription, dispatch, and response publishing.
  • src/config/mod.rs: Loads and validates config.toml.
  • src/logging.rs: Emits compact JSON log records.
  • src/model/types.rs: Defines shared request/result/context types.
  • schema/: Contains JSON Schema files for documented payload shapes.
  • docs/edgepulse-integration-roadmap.md: Describes EdgePulse, fleet, RBAC, and multi-tenant plans.

Build and Test

cargo build --release
cargo test

For OpenWrt deployment, cross-compile with the OpenWrt SDK or a musl target appropriate for the device.

Configuration

Example config.toml:

[mqtt]
broker = "mqtt://localhost:1883"
client_id = "openwrt-one"
username = "mcp-user"
password = "mcp-pass"
topic_prefix = "mcp/device/openwrt-one"

[http]
enable = true
listen_addr = "0.0.0.0"
port = 8080
token = "your-api-token"

Validation currently rejects:

  • Empty mqtt.broker, mqtt.client_id, or mqtt.topic_prefix.
  • MQTT topic prefixes containing + or #.
  • Invalid http.listen_addr.
  • http.port = 0.
  • Empty http.token when HTTP is enabled.

HTTP API

All HTTP endpoints require:

x-api-token: <configured token>

Get current context:

curl -H 'x-api-token: change-me' \
  http://127.0.0.1:8080/api/context

Describe server capabilities:

curl -H 'x-api-token: change-me' \
  http://127.0.0.1:8080/api/describe

Execute an allowlisted command:

curl -H 'x-api-token: change-me' \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","method":"device.executeCommand","params":{"command":"get_context"},"id":"cmd-1"}' \
  http://127.0.0.1:8080/api/cmd

Supported built-in commands are declared in src/executor/registry.rs.

MQTT API

Command topic:

{topic_prefix}/cmd

Response topic:

{topic_prefix}/resp

Example capability request:

{
  "jsonrpc": "2.0",
  "method": "device.describe",
  "params": {},
  "id": "describe-1"
}

Example command request:

{
  "jsonrpc": "2.0",
  "method": "device.executeCommand",
  "params": {
    "command": "restart_interface",
    "args": {
      "interface": "wan"
    }
  },
  "id": "cmd-1"
}

Schemas

Schema files document the expected payloads:

  • schema/command.schema.json
  • schema/context.schema.json

Runtime validation is currently implemented through typed parsing, command allowlisting, argument checks, and config validation. Full JSON Schema validation is planned as a future hardening step.

EdgePulse Integration

openwrt-mcp-server is intended to integrate with ../edgepulse as a remote MCP bridge. EdgePulse should remain the OpenWrt-local authority for telemetry, policy, named actions, audit logs, and AI agent conversation state. This Rust server should translate remote HTTP/MQTT/MCP-facing requests into EdgePulse local APIs where available.

See docs/edgepulse-integration-roadmap.md for the detailed plan.

Roadmap

Current baseline:

  • Single-device HTTP/MQTT JSON-RPC bridge.
  • OpenWrt/Linux context collection.
  • Command and context registries.
  • device.describe introspection.
  • Structured JSON logs.
  • Config validation.
  • Schema documentation.

Near-term hardening:

  • Runtime JSON Schema validation.
  • Persistent audit log for HTTP/MQTT requests and command results.
  • EdgePulse client adapter for edgepulse-ctl, then ubus or Unix socket.
  • Replace direct mutation commands with EdgePulse policy-gated named actions where available.
  • Command sandboxing beyond the initial allowlist.
  • CLI utility for testing and debugging requests.

Fleet direction:

  • Standalone MCP server mode outside OpenWrt.
  • Device registry and explicit target selection.
  • Rule-based access control for users, service accounts, devices, methods, and permissions.
  • Tenant-aware config, tokens, MQTT routing, context caches, policies, and audit records.
  • Multi-tenant fleet service operation.

Longer-term extensions:

  • WebSocket transport for dashboards and live operations.
  • Streaming telemetry metrics endpoint.
  • Context delta compression for low-bandwidth MQTT.
  • Secure boot and system integrity reporting.
  • Scheduler support for recurring commands.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.