Tutorial: LAN AI MCP Bridge & Autonomous Agent Workflow

PylotOS includes a zero-dependency Model Context Protocol (MCP) JSON-RPC 2.0 stdio server (tools/mcp_bridge/ in PylotOS/pylotos) and a repo-packaged agent skill (skills/pylotos-dev/SKILL.md).

Together with pylotos-sdk, AI coding agents (Claude Code, Cursor, Windsurf, VS Code Copilot, Gemini CLI) can write an adaptive MicroPython app, verify it locally in pylotos-sim, deploy it over Wi-Fi to a physical ESP32 board, read live stdout/stderr logs, and visually inspect a PNG screenshot of the real LCD — closing the entire embedded hardware-in-the-loop cycle autonomously.


1. Setup in Claude Code / Cursor / Windsurf

Add the bridge to .mcp.json (or claude_desktop_config.json):

{
  "mcpServers": {
    "pylotos": {
      "command": "python3",
      "args": ["-m", "tools.mcp_bridge"],
      "cwd": "/path/to/pylotos",
      "env": {
        "PYLOTOS_HOST": "pylotos-cardputer.local",
        "PYLOTOS_OTA_KEY": "optional-fleet-key-for-unattended-deploy"
      }
    }
  }
}

Tip: Even without PYLOTOS_HOST, calling discover_devices automatically scans _pylotos._tcp.local. via mDNS and probes /api/ota/info across your LAN!


2. Complete 15-Tool MCP Reference

CategoryTool NamePurpose
Discovery & HWdiscover_devicesMulticast mDNS (_pylotos._tcp.local.) + HTTP probe returning board IDs, chips, IPs, and asym-v1 OTA state.
describe_boardFull hal.describe() JSON: display archetype, input caps, memory/PSRAM, buses, active wireless radios & expansion_ports.
Visual & UIget_ui_stateCurrent pylotos.ui widget tree, focus index, active theme, and notification queue JSON.
capture_screenshotCaptures the live physical ESP32 framebuffer over :8266 and returns an MCP image/png block for multimodal AI vision!
App Lifecyclelist_appsLists installed /apps/* scripts, active running state, and boot autostart config.
read_app_fileReads UTF-8 source or config files under /apps/.
deploy_appAtomic SHA-256 verified upload with automatic .bak backup, optional run=true, and crash rollback_guard=true.
run_app / stop_appStarts or cleanly stops a foreground /apps/ script (triggering hal.wireless_reset_app_handles()).
rollback_appRestores the previous .bak version of an app in one call.
read_app_logsIncremental since_seq stdout/stderr ringbuffer reader for live exception & print debugging.
Config & Diagget_app_config / set_app_configReads or deep-merges per-device /apps/.config/<app>.json overrides without modifying shared Python code.
get_coredumpChecks 0x13000 Flash ELF Core Dump metadata and optionally downloads Base64 ELF slices.
trigger_ota_checkQueries or triggers Asymmetric Recovery-OTA (asym-v1) checks against a manifest URL.

  1. Inspect Hardware: Call discover_devices -> describe_board to learn exact screen dimensions, input profile, and attached radios/overlays.
  2. Simulate Locally First: Run pytest or pylotos-sim <script.py> --board <board_id> using pylotos-sdk to catch layout or MicroPython syntax issues in < 1s.
  3. Atomic Deploy: Call deploy_app(path="my_app.py", content=..., run=True, rollback_guard=True).
  4. Verify Logs & Pixels: Call read_app_logs to confirm zero tracebacks, then call capture_screenshot to visually confirm widget alignment on the physical screen!