Skip to main content
Glama
USBGuard-MCP

USBGuard-MCP

USBGuard-MCP

Intelligent USB security through the Model Context Protocol.

CI Security PyPI Python License: MIT MCP Registry

mcp-name: io.github.0x5t4l1n/usbguard-mcp

USBGuard-MCP is an independent, read-only MCP server that lets AI agents inspect USBGuard: list devices, analyze the authorization policy, observe authorization events, and produce evidence-based security findings. It is not affiliated with or endorsed by the USBGuard project.

Status: 0.1.0, first release. Validated against a running USBGuard 1.1.4 daemon, a real USB flash drive and three MCP clients on one Fedora KDE laptop. Other distributions and USBGuard versions are untested. Full record: docs/validation.md.

Why

USBGuard answers "may this device be used?" but its CLI output is text meant for humans. An agent asked to "audit my USB policy" would otherwise have to run raw shell commands. USBGuard-MCP gives it a narrow, typed, read-only interface instead: no arbitrary command execution, no write access, structured results, and findings that state their evidence and limits.

Related MCP server: Linux MCP Server

Key features

  • 32 read-only tools, 6 resources and 5 prompts (reference).

  • Read-only by construction: the backend can only run usbguard --version, list-devices, list-rules and watch. Nothing can authorize, block, reject, or edit policy.

  • Policy analysis that respects USBGuard semantics: first-match-wins ordering, set operators (equals is the default), wildcards, and conditions. It reports duplicates, shadowed or conflicting rules and permissive rules only when set logic proves them, and states what it cannot evaluate.

  • Explainable heuristics: every finding has evidence, severity, confidence, limitations and remediation. It never calls a device "malicious" and does not detect malware or firmware attacks.

  • Untrusted-metadata handling: device names, serials and rule text are sanitized, kept out of finding prose, and flagged as untrusted in every response.

  • Privacy by default: serials, hashes, ports, host identifiers and audit metadata are redacted. No telemetry; runs fully offline.

  • Explicit mock mode with synthetic scenarios, so development needs no root or hardware.

Architecture

flowchart TD
    A[MCP client] -->|STDIO| B[FastMCP server]
    B --> C[Tools / resources / prompts]
    C --> D[Input validation]
    D --> E[Services: devices, policy, audit, events]
    E --> F[Redaction layer]
    E --> G[Backend interface]
    G --> H[CLI backend<br/>command guard + bounded subprocess]
    G --> M[Mock backend<br/>explicit opt-in]
    H --> I[usbguard CLI] --> J[usbguard daemon<br/>source of truth]

Details: docs/architecture.md.

Security model

Read-only, least privilege, no sudo, no shell=True, absolute root-owned executable path, minimal environment, timeouts, output and concurrency limits, redaction on by default. See docs/threat-model.md and docs/permissions.md.

Supported platforms

Linux only. Fedora is the development platform; Fedora, RHEL, CentOS Stream, Rocky, AlmaLinux, Ubuntu, Debian, Arch and openSUSE are recognized and receive install hints. Recognized does not mean tested: only Fedora has been exercised, and only up to the point of an inactive daemon. USBGuard versions differ between distributions; this was developed against USBGuard 1.1.4.

Requirements

Python 3.11+, USBGuard installed and its daemon running (not needed for --mock). USBGuard-MCP never installs or configures USBGuard for you.

Installation

uvx usbguard-mcp --version      # run without installing (needs uv)
pip install usbguard-mcp        # or install into an environment
usbguard-mcp --mock             # try synthetic data, no USBGuard needed

From a checkout: uv sync && uv run usbguard-mcp. See docs/installation.md.

Official MCP Registry

Listed on the official MCP Registry as io.github.0x5t4l1n/usbguard-mcp (PyPI package, STDIO). Registry data for this server: /v0.1/servers?search=io.github.0x5t4l1n/usbguard-mcp. The registry documents no official badge, so the badge above is a generic shields.io badge that reads the registry API live. The registry stores metadata only; the package is installed from PyPI.

Quick start

  1. Try it on synthetic data: uvx usbguard-mcp --mock (an MCP client speaks to it over STDIO).

  2. For real data, ask an administrator for the minimal read-only ACL in docs/permissions.md, then run uvx usbguard-mcp and call check_permissions.

MCP client configuration

Client

Status (live, real daemon, 2026-12-06)

Claude Code

Tested: tool call returned the real USBGuard version

Codex CLI

Tested: same

OpenCode

Tested with caveats: use a project-level opencode.json; small models may need the server named in the prompt

MCP Inspector (CLI)

Tested: tools/list, tools/call

Claude Desktop, VS Code

Config shape follows vendor docs; untested

Examples live in examples/. For instance, with a local checkout:

claude mcp add --scope user --transport stdio usbguard -- uvx usbguard-mcp
codex mcp add usbguard -- uvx usbguard-mcp

Tools

Full generated reference: docs/tools.md.

Group

Tools

System

get_usbguard_version, get_system_status, check_permissions, get_server_info, health_check

Devices

list_usb_devices, list_allowed_devices, list_blocked_devices, list_rejected_devices, inspect_usb_device, search_usb_devices, get_device_statistics, classify_usb_device, compare_usb_devices

Policy

list_policy_rules, inspect_policy_rule, analyze_security_policy, detect_duplicate_rules, detect_permissive_rules, detect_policy_conflicts, recommend_policy_improvements, preview_policy_rule

Security

assess_usb_security, detect_suspicious_interfaces, detect_composite_devices, analyze_device_risk, detect_identity_changes, generate_security_report

Monitoring

collect_usb_events, get_recent_usb_events, get_event_statistics, analyze_usb_activity

Resources: usbguard://system/status, usbguard://devices, usbguard://policies, usbguard://events/recent, usbguard://security/summary, usbguard://documentation. Prompts: audit_usb_security, investigate_usb_device, review_usb_policy, analyze_recent_usb_activity, generate_usb_security_report.

Example prompts

  • "List all authorized USB devices."

  • "Are there any blocked USB devices?"

  • "Audit my current USB authorization policy."

  • "Explain which devices expose multiple USB interfaces."

  • "Review my USBGuard configuration for security weaknesses."

  • "Generate a USB security assessment report."

Example (synthetic data) from detect_policy_conflicts:

{"code": "CONFLICTING_RULE", "severity": "medium", "confidence": "high",
 "summary": "A later rule has a different target but is unreachable: an earlier unconditional rule always matches first.",
 "evidence": {"earlier_rule_id": 1, "later_rule_id": 3, "earlier_target": "allow", "later_target": "block"},
 "limitations": ["Rule conditions (if ...) are evaluated by the daemon at runtime, not here.", "..."],
 "remediation": "Decide which target is intended, then fix the rule order or remove the unreachable rule."}

Troubleshooting

See docs/troubleshooting.md. Start with check_permissions.

Known limitations

  • Validated on one laptop, one USBGuard version (1.1.4) and one distribution (Fedora); parsers are strict and report PARSE_ERROR rather than guessing, so other versions may need fixes.

  • Event timestamps are collection time, not occurrence time (USBGuard watch gives none); only order is reliable. USBGuard device IDs change when a device is replugged.

  • ImplicitPolicyTarget and other settings in usbguard-daemon.conf are root-only and not read.

  • Rule conditions (if ...) are not evaluated. Policy analysis is sound but incomplete.

  • Rejected/disconnected devices are only visible via the live list or events seen this session.

  • Events come from a bounded in-memory buffer; there is no historical journal source.

  • No native IPC backend, HTTP transport or write operations.

Roadmap

0.x: more distributions and USBGuard versions, MCP Registry submission. Later, each needing its own security review: native IPC backend, persistent local event storage, authenticated localhost HTTP, carefully controlled administrative functions. None may weaken the read-only default.

Contributing

See CONTRIBUTING.md. Report vulnerabilities per SECURITY.md.

License and acknowledgment

MIT, see LICENSE and THIRD_PARTY_NOTICES.md. Thanks to the USBGuard project (GPL-2.0-or-later). This project invokes its CLI and copies none of its code.

Available Tools

32 tools
analyze_device_riskAnalyze Device RiskB
Read-onlyIdempotent

Assess observable characteristics of one device with a fixed, documented weighting. 'none_observed' does not mean safe.

Inputs: device_id (required). Returns: object

analyze_security_policyAnalyze Security PolicyA
Read-onlyIdempotent

Analyze policy structure and posture: rule counts, terminal rule, permissive rules, duplicates, shadowed and conflicting rules. States limits it cannot evaluate (daemon implicit target, runtime conditions).

Inputs: no named parameters. Returns: object

analyze_usb_activityAnalyze Usb ActivityA
Read-onlyIdempotent

Analyze buffered authorization activity: devices allowed, blocked or rejected, and repeated re-insertions.

Inputs: no named parameters. Returns: object

assess_usb_securityAssess Usb SecurityA
Read-onlyIdempotent

Overall USB security assessment: overall severity, finding counts by severity, the most severe findings and composite devices. Heuristic and evidence-based.

Inputs: no named parameters. Returns: object

check_permissionsCheck PermissionsA
Read-onlyIdempotent

Probe which read-only capabilities (list devices, list policy, listen to events) this account has, and explain what an administrator would need to grant. Never changes any permission.

Inputs: no named parameters. Returns: object

classify_usb_deviceClassify Usb DeviceA
Read-onlyIdempotent

Identify probable device categories from USB interface class codes, with per-interface reasoning, confidence and limitations. Composite devices list every function.

Inputs: device_id (required). Returns: object

collect_usb_eventsCollect Usb EventsA
Read-only

Listen for USBGuard events for a bounded time window (usbguard watch), add them to the bounded buffer and return them. Cancellable; the child process is always terminated.

Inputs: seconds. Returns: object

compare_usb_devicesCompare Usb DevicesA
Read-onlyIdempotent

Compare observable attributes of two devices (IDs, status, interfaces). Serial and hash equality are reported as booleans only.

Inputs: first_device_id (required), second_device_id (required). Returns: object

detect_composite_devicesDetect Composite DevicesA
Read-onlyIdempotent

List devices exposing multiple distinct functions, flagging combinations that consumer hardware commonly uses (headsets, webcams with microphones).

Inputs: no named parameters. Returns: object

detect_duplicate_rulesDetect Duplicate RulesA
Read-onlyIdempotent

Find rules that repeat, or are fully covered by, an earlier unconditional rule with the same target (potentially redundant).

Inputs: no named parameters. Returns: object

detect_identity_changesDetect Identity ChangesA
Read-onlyIdempotent

Compare a device against a baseline you collected earlier (see the baseline_template of inspect_usb_device). Only supplied fields are compared; serial and hash values are never echoed, and while their redaction is on they are skipped entirely (reported in skipped_fields) so the tool cannot be used to guess hidden identifiers.

Inputs: baseline (required), device_id (required). Returns: object

detect_permissive_rulesDetect Permissive RulesA
Read-onlyIdempotent

Find allow rules that are excessively broad: allow-all, wildcard IDs, vendor-wide or interface-class wildcards, and ID-only matches that can be imitated.

Inputs: no named parameters. Returns: object

detect_policy_conflictsDetect Policy ConflictsA
Read-onlyIdempotent

Find unreachable rules whose target differs from an earlier rule that always matches first, and note intentional ordered exceptions. Only provable cases are reported.

Inputs: no named parameters. Returns: object

detect_suspicious_interfacesDetect Suspicious InterfacesB
Read-onlyIdempotent

Identify potentially unexpected interface combinations (for example keyboard plus storage). A finding means 'worth reviewing', never 'malicious'.

Inputs: min_severity. Returns: object

generate_security_reportGenerate Security ReportB
Read-onlyIdempotent

Generate a structured report: findings with evidence, severity, confidence, limitations and remediation. Set include_devices for redacted device records.

Inputs: include_devices. Returns: object

get_device_statisticsGet Device StatisticsA
Read-onlyIdempotent

Summarize devices by authorization status, interface class and classification.

Inputs: no named parameters. Returns: object

get_event_statisticsGet Event StatisticsA
Read-onlyIdempotent

Summarize the events currently in the buffer by kind, status and presence.

Inputs: no named parameters. Returns: object

get_recent_usb_eventsGet Recent Usb EventsA
Read-onlyIdempotent

Return events from the bounded in-memory buffer (empty until collect_usb_events has run). Does not read history.

Inputs: limit, status, device_id. Returns: object

get_server_infoGet Server InfoA
Read-onlyIdempotent

Return the USBGuard-MCP version, read-only guarantee, tool inventory, redaction settings and unsupported capabilities.

Inputs: no named parameters. Returns: object

get_system_statusGet System StatusA
Read-onlyIdempotent

Report host platform, USBGuard availability and whether the daemon IPC is reachable. A missing or unreachable daemon is reported as status, never faked.

Inputs: no named parameters. Returns: object

get_usbguard_versionGet Usbguard VersionA
Read-onlyIdempotent

Retrieve the installed USBGuard version by running usbguard --version.

Inputs: no named parameters. Returns: object

health_checkHealth CheckA
Read-onlyIdempotent

Verify the integration end to end: USBGuard installed, daemon reachable, and the device list parses. Returns per-check results.

Inputs: no named parameters. Returns: object

inspect_policy_ruleInspect Policy RuleA
Read-onlyIdempotent

Inspect one rule: its attributes, plus any permissiveness, duplicate, shadowing or conflict findings that involve it.

Inputs: rule_id (required). Returns: object

inspect_usb_deviceInspect Usb DeviceA
Read-onlyIdempotent

Return all observable attributes of one device plus its classification and a baseline_template usable with detect_identity_changes.

Inputs: device_id (required). Returns: object

list_allowed_devicesList Allowed DevicesA
Read-onlyIdempotent

List devices USBGuard currently authorizes (target allow).

Inputs: limit. Returns: object

list_blocked_devicesList Blocked DevicesA
Read-onlyIdempotent

List devices USBGuard currently blocks (target block): present but not authorized.

Inputs: limit. Returns: object

list_policy_rulesList Policy RulesB
Read-onlyIdempotent

List the policy rules enforced by the daemon (usbguard list-rules) in evaluation order. Rules are scanned top to bottom and the first applicable rule decides.

Inputs: limit. Returns: object

list_rejected_devicesList Rejected DevicesA
Read-onlyIdempotent

List devices with target reject where observable. Rejected devices are removed from the system, so the daemon list usually omits them; entries may also come from events this server observed (see source) and may no longer be present.

Inputs: limit. Returns: object

list_usb_devicesList Usb DevicesA
Read-onlyIdempotent

List USB devices recognized by USBGuard (usbguard list-devices), all statuses. device_id is USBGuard's internal ID, distinct from vendor_id/product_id.

Inputs: limit. Returns: object

preview_policy_rulePreview Policy RuleA
Read-onlyIdempotent

Validate and analyze a proposed rule without applying it. The text is parsed in-process and is never passed to USBGuard or a shell.

Inputs: rule (required). Returns: object

recommend_policy_improvementsRecommend Policy ImprovementsA
Read-onlyIdempotent

Recommend policy changes derived from findings. Advisory only; never applied.

Inputs: no named parameters. Returns: object

search_usb_devicesSearch Usb DevicesA
Read-onlyIdempotent

Search devices by name substring, vendor/product ID, interface prefix, status or classification. Filters are ANDed. Serial search is intentionally unsupported so serials cannot be probed one value at a time.

Inputs: name, limit, status, category, +3 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 32 tools

    Disambiguation3/5

    Tools divide into recognizable families (device listing, policy analysis, event handling, reporting), but several overlap heavily: analyze_security_policy already reports permissive/duplicate/shadowed/conflicting rules that detect_permissive_rules, detect_duplicate_rules and detect_policy_conflicts expose separately, and assess_usb_security vs generate_security_report is a fuzzy split. The four list_* device tools also largely duplicate list_usb_devices with filters. Descriptions do help separate them, but an agent could easily misselect among the analysis tools.

    Naming Consistency5/5

    Every tool follows a clean snake_case verb_noun pattern (get_, list_, inspect_, detect_, analyze_, assess_, generate_, collect_, preview_, search_, classify_, compare_), including the check_ and health_ style status verbs. No camelCase or arbitrary-name deviations.

    Tool Count3/5

    32 tools is heavy for a read-only audit integration and exceeds the comfortable 3-15 range. While there is genuine depth (device inspection, policy analysis, event buffering, reporting), several granular detect_*/analyze_* tools could be consolidated without losing capability.

    Completeness4/5

    For a deliberately read-only server, coverage is strong: version/health/permission checks, device listing/inspection/classification/comparison, policy inspection and analysis, event collection and statistics, plus reporting. Write operations (allow/block/apply rules) are intentionally absent by design, and a couple of analyses are constrained by redaction, but there are no unintended dead ends for the stated purpose.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      A local MCP server for the LimaCharlie security platform that provides investigation, administration, and content-review workflows via a broad read-only tool surface with explicit organization scoping and audit logging.
      100
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A read-only MCP server for Linux and macOS system administration, diagnostics, and troubleshooting, supporting remote SSH execution and multi-host management.
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      A secure, read-only MCP server for AI-powered system monitoring. It provides real-time OS metrics, config discovery, and safe log tailing to enable autonomous infrastructure audits without shell access risks.
      4
      2
      ISC