litex_flow
Execute LiteX board targets with custom arguments for FPGA development, enabling hardware configuration and testing through the fpgaZeroMCP server's toolchain.
Instructions
Run a generic LiteX board target with caller-provided args.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| board | Yes | LiteX board target | |
| args | No | Extra LiteX CLI args | |
| timeout | No | Timeout in seconds |
Implementation Reference
- tools/litex.py:82-88 (handler)Main handler function for litex_flow tool - a generic LiteX flow runner that accepts board, args, and timeout parameters and delegates to _run_litex helper
def litex_flow( board: str, args: list[str] | None = None, timeout: int = 600, ) -> dict: """Generic LiteX flow runner with caller-provided args.""" return _run_litex(board, args or [], timeout) - tools/litex.py:17-32 (helper)Core helper function _run_litex that executes the LiteX command using subprocess, handles errors, timeouts, and returns structured results
def _run_litex(board: str, args: list[str] | None, timeout: int) -> dict: cmd = _build_litex_cmd(board, args) try: result = subprocess.run( cmd, capture_output=True, text=True, timeout=timeout ) return { "success": result.returncode == 0, "cmd": cmd, "stdout": result.stdout, "stderr": result.stderr, } except FileNotFoundError: return {"success": False, "error": "LiteX entrypoint not found."} except subprocess.TimeoutExpired: return {"success": False, "error": f"LiteX timed out after {timeout} s."} - tools/litex.py:11-14 (helper)Helper function _build_litex_cmd that constructs the LiteX command line invocation
def _build_litex_cmd(board: str, args: list[str] | None) -> list[str]: if not board: raise ValueError("board is required") return [sys.executable, "-m", f"litex_boards.targets.{board}"] + (args or []) - server.py:377-397 (registration)Tool registration defining litex_flow with its input schema (board, args, timeout parameters) and description
types.Tool( name="litex_flow", description="Run a generic LiteX board target with caller-provided args.", inputSchema={ "type": "object", "properties": { "board": {"type": "string", "description": "LiteX board target"}, "args": { "type": "array", "items": {"type": "string"}, "description": "Extra LiteX CLI args", }, "timeout": { "type": "integer", "default": 600, "description": "Timeout in seconds", }, }, "required": ["board"], }, ), - server.py:510-516 (handler)Tool dispatch handler that invokes litex_flow via asyncio.to_thread with arguments from the MCP request
case "litex_flow": result = await asyncio.to_thread( litex_flow, board=arguments["board"], args=arguments.get("args"), timeout=arguments.get("timeout", 600), )