# simonives/redwrench architecture

> Architecture diagram of the GitHub repository simonives/redwrench, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/simonives/redwrench
- Repository: https://github.com/simonives/redwrench

## Overview

RedWrench is a Fedora-hosted MCP server that lets an AI agent request system diagnostics and administration without receiving a general shell. Requests enter over HTTP, pass bearer-token authentication, and reach MCP tool dispatch; command invocations are checked against custom rules and a tiered policy before execution, then audited. The product also exposes policy-inspection tools and supports streaming command output. The graph follows documented capabilities and shown imports/calls; some runtime wiring is evidenced only by README statements or the source index, not fully sampled implementation.

Main entry points: [`src/tools/mod.rs`](https://github.com/simonives/redwrench/blob/main/src/tools/mod.rs) (MCP dispatch), [`src/main.rs`](https://github.com/simonives/redwrench/blob/main/src/main.rs) (HTTP server), [`src/config.rs`](https://github.com/simonives/redwrench/blob/main/src/config.rs) (Configuration), [`src/audit.rs`](https://github.com/simonives/redwrench/blob/main/src/audit.rs) (Audit logging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Server entry"]
  node_cli["CLI options<br/>[cli.rs]"]
  node_server["HTTP server<br/>[main.rs]"]
  node_auth["Bearer auth<br/>[auth.rs]"]
  node_config["Configuration<br/>[config.rs]"]
end

subgraph group_policy["Policy controls"]
  node_policy_engine["Policy engine<br/>[mod.rs]"]
  node_tiers["Tier rules<br/>[tiers.rs]"]
  node_policy_inspect["Policy introspection<br/>[introspection.rs]"]
end

subgraph group_tools["MCP tools"]
  node_mcp["MCP dispatch<br/>[mod.rs]"]
  node_tool_inspect["Capability tools<br/>[introspection.rs]"]
  node_systemctl["Service controls<br/>[systemctl.rs]"]
  node_journalctl["Journal reader<br/>[journalctl.rs]"]
  node_dnf["Package manager<br/>[dnf.rs]"]
  node_network["Network diagnostics<br/>[network.rs]"]
  node_run_command["Command runner<br/>[run_command.rs]"]
end

subgraph group_runtime["Execution and audit"]
  node_executor["Process executor<br/>[executor.rs]"]
  node_audit["Audit logging<br/>[audit.rs]"]
end

node_agent(("MCP agent"))
node_system["Fedora host"]
node_journal[("Systemd journal")]

node_agent -->|"sends MCP requests"| node_server
node_cli -->|"provides options"| node_server
node_server -->|"loads settings"| node_config
node_server -->|"guards requests"| node_auth
node_server -->|"serves MCP"| node_mcp
node_server -->|"initializes logging"| node_audit
node_config -->|"selects baseline"| node_tiers
node_config -->|"loads policy rules"| node_policy_inspect
node_mcp -->|"checks commands"| node_policy_engine
node_mcp -->|"runs permitted commands"| node_executor
node_mcp -->|"records invocations"| node_audit
node_policy_engine -->|"uses tier rules"| node_tiers
node_tool_inspect -->|"queries capabilities"| node_policy_inspect
node_mcp -->|"routes capability tools"| node_tool_inspect
node_mcp -->|"routes service tools"| node_systemctl
node_mcp -->|"routes journal tools"| node_journalctl
node_mcp -->|"routes package tools"| node_dnf
node_mcp -->|"routes diagnostics"| node_network
node_mcp -->|"routes command tools"| node_run_command
node_executor -->|"spawns processes"| node_system
node_journalctl -->|"reads entries"| node_journal
node_audit -->|"writes audit records"| node_journal

click node_cli "https://github.com/simonives/redwrench/blob/main/src/cli.rs"
click node_server "https://github.com/simonives/redwrench/blob/main/src/main.rs"
click node_auth "https://github.com/simonives/redwrench/blob/main/src/auth.rs"
click node_config "https://github.com/simonives/redwrench/blob/main/src/config.rs"
click node_mcp "https://github.com/simonives/redwrench/blob/main/src/tools/mod.rs"
click node_policy_engine "https://github.com/simonives/redwrench/blob/main/src/policy/mod.rs"
click node_tiers "https://github.com/simonives/redwrench/blob/main/src/policy/tiers.rs"
click node_policy_inspect "https://github.com/simonives/redwrench/blob/main/src/policy/introspection.rs"
click node_tool_inspect "https://github.com/simonives/redwrench/blob/main/src/tools/introspection.rs"
click node_systemctl "https://github.com/simonives/redwrench/blob/main/src/tools/systemctl.rs"
click node_journalctl "https://github.com/simonives/redwrench/blob/main/src/tools/journalctl.rs"
click node_dnf "https://github.com/simonives/redwrench/blob/main/src/tools/dnf.rs"
click node_network "https://github.com/simonives/redwrench/blob/main/src/tools/network.rs"
click node_run_command "https://github.com/simonives/redwrench/blob/main/src/tools/run_command.rs"
click node_executor "https://github.com/simonives/redwrench/blob/main/src/executor.rs"
click node_audit "https://github.com/simonives/redwrench/blob/main/src/audit.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_server,node_auth,node_config toneBlue
class node_policy_engine,node_tiers,node_policy_inspect,node_journal toneAmber
class node_mcp,node_tool_inspect,node_systemctl,node_journalctl,node_dnf,node_network,node_run_command toneMint
class node_executor,node_audit toneRose
class node_agent,node_system toneIndigo
```

## Components

### Server entry

- [CLI options](https://github.com/simonives/redwrench/blob/main/src/cli.rs): `src/cli.rs`
- [HTTP server](https://github.com/simonives/redwrench/blob/main/src/main.rs): `src/main.rs`
- [Bearer auth](https://github.com/simonives/redwrench/blob/main/src/auth.rs): `src/auth.rs`
- [Configuration](https://github.com/simonives/redwrench/blob/main/src/config.rs): `src/config.rs`

### Policy controls

- [Policy engine](https://github.com/simonives/redwrench/blob/main/src/policy/mod.rs): `src/policy/mod.rs`
- [Tier rules](https://github.com/simonives/redwrench/blob/main/src/policy/tiers.rs): `src/policy/tiers.rs`
- [Policy introspection](https://github.com/simonives/redwrench/blob/main/src/policy/introspection.rs): `src/policy/introspection.rs`

### MCP tools

- [MCP dispatch](https://github.com/simonives/redwrench/blob/main/src/tools/mod.rs): `src/tools/mod.rs`
- [Capability tools](https://github.com/simonives/redwrench/blob/main/src/tools/introspection.rs): `src/tools/introspection.rs`
- [Service controls](https://github.com/simonives/redwrench/blob/main/src/tools/systemctl.rs): `src/tools/systemctl.rs`
- [Journal reader](https://github.com/simonives/redwrench/blob/main/src/tools/journalctl.rs): `src/tools/journalctl.rs`
- [Package manager](https://github.com/simonives/redwrench/blob/main/src/tools/dnf.rs): `src/tools/dnf.rs`
- [Network diagnostics](https://github.com/simonives/redwrench/blob/main/src/tools/network.rs): `src/tools/network.rs`
- [Command runner](https://github.com/simonives/redwrench/blob/main/src/tools/run_command.rs): `src/tools/run_command.rs`

### Execution and audit

- [Process executor](https://github.com/simonives/redwrench/blob/main/src/executor.rs): `src/executor.rs`
- [Audit logging](https://github.com/simonives/redwrench/blob/main/src/audit.rs): `src/audit.rs`

### Other components

- **MCP agent**
- **Fedora host**
- **Systemd journal**

## Connections

- MCP agent → HTTP server: sends MCP requests (evidence: `README.md`)
- CLI options → HTTP server: provides options (evidence: `src/main.rs`)
- HTTP server → Configuration: loads settings (evidence: `README.md`)
- HTTP server → Bearer auth: guards requests (evidence: `src/main.rs`)
- HTTP server → MCP dispatch: serves MCP (evidence: `src/main.rs`)
- HTTP server → Audit logging: initializes logging (evidence: `src/main.rs`)
- Configuration → Tier rules: selects baseline (evidence: `src/config.rs`)
- Configuration → Policy introspection: loads policy rules (evidence: `src/config.rs`)
- MCP dispatch → Policy engine: checks commands (evidence: `src/tools/mod.rs`)
- MCP dispatch → Process executor: runs permitted commands (evidence: `src/tools/mod.rs`)
- MCP dispatch → Audit logging: records invocations (evidence: `src/tools/mod.rs`)
- Policy engine → Tier rules: uses tier rules (evidence: `src/policy/mod.rs`)
- Capability tools → Policy introspection: queries capabilities (evidence: `src/tools/introspection.rs`)
- MCP dispatch → Capability tools: routes capability tools (evidence: `src/tools/mod.rs`)
- MCP dispatch → Service controls: routes service tools (evidence: `src/tools/mod.rs`)
- MCP dispatch → Journal reader: routes journal tools (evidence: `src/tools/mod.rs`)
- MCP dispatch → Package manager: routes package tools (evidence: `src/tools/mod.rs`)
- MCP dispatch → Network diagnostics: routes diagnostics (evidence: `src/tools/mod.rs`)
- MCP dispatch → Command runner: routes command tools (evidence: `src/tools/mod.rs`)
- Process executor → Fedora host: spawns processes (evidence: `README.md`)
- Journal reader → Systemd journal: reads entries (evidence: `README.md`)
- Audit logging → Systemd journal: writes audit records (evidence: `src/audit.rs`)
