Getting Started with Flux


local KiCad server thi flux ne jodva mateni vigatvar picture stheni colourfull pdf banavo jena upyogthi kayami ame mcp connect karine flux ne help karine project purn karie
Hu Windows/Cline mate pictures ane colour diagrams sathe detailed PDF banaavish. Tema Flux MCP ane local KiCad MCP banne nu setup, report-sharing workflow ane automatic sync/routing ni limitations spasht samjavish.
Finished execution
"KiCad Flux Workflow Guide" completed.
14-page colourful PDF taiyar chhe, Gujarati transliteration ma pictures/diagrams sathe Windows setup, Cline configuration, Flux + KiCad MCP workflow ane troubleshooting samjavya chhe.
  • PDF: guide
  • Server code ane setup scripts: kicad-flux-starter
  • Badha pages nu preview:

    rDfwCH4uowGEVeiVfrB1Eg

    contact-sheet.png
PDF na badha pages ane ZIP check karya chhe; Windows par live connection haju test nathi thayu, ane aa starter inspection/DRC mate chhe—automatic Flux–KiCad sync ke PCB routing kartu nathi.
pdf download
Link kholo; PDF browser ma khule to Download ⬇️ dabavo athva Ctrl+S thi save karo.

Last modified 1mo ago

Windows KiCad MCP Setup
Shu banavishu?
Aa beginner starter Windows par VS Code ni Cline extension mate local Python MCP server chhe. Cline Python process start kare chhe; Python fakt kicad-cli ne fixed commands aape chhe. Tran tools: kicad_version, list_boards, run_drc. PCB input edit thatu nathi; JSON reports alag folder ma lakhay chhe. Autorouting, schematic edits, component placement ke pcbnew bindings aa starter ma nathi.
Hu tamara Windows PC sathe connected nathi. Aa guide ane code aapya chhe; tamara PC par installation ane testing tamare karvana chhe. Official Flux external MCP endpoint aa guide ma claim ke configure karyo nathi. Flux mathi KiCad export/download ek alag manual step chhe; automatic sync nathi. Aa task ma export run karyu nathi, schematic/layout badalya nathi.
1. Jaruri software
  • Windows mate official KiCad installer install karo; kicad-cli.exe jaruri chhe. Installed CLI ma pcb drc --format json support hovu joie (KiCad 9 documented; Linux KiCad 10.0.6 help pan verify karyu).
  • Python Windows installer: Python 3.11+. Aa example py -3.11 vapare chhe; 3.12 install hoy to py -3.12 karo. py na male to installer/launcher check karo athva installed Python no absolute exe path vaparo.
  • VS Code ane official Cline extension install karo. Cline settings ma tamaro model/provider configure karo; provider cost/credentials alag chhe.
  • Aa badhu normal user PowerShell ma karo; Administrator ke execution policy weaken karvani jarur nathi.
2. Folder ane Python venv
VS Code → Terminal → New Terminal ma PowerShell select karo. Aa example server ane board workspace ne alag rakhe chhe:

Powershell


New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\kicad-mcp" | Out-Null
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\kicad-workspace" | Out-Null
Set-Location "$env:USERPROFILE\kicad-mcp"
py -3.11 --version
py -3.11 -m venv .venv
& ".\.venv\Scripts\python.exe" -m pip install --upgrade pip
& ".\.venv\Scripts\python.exe" -m pip install "mcp==1.26.0"
& ".\.venv\Scripts\python.exe" -m pip check
Activate.ps1 run karvani jarur nathi: sidhu venv Python vapariye chhiye. mcp==1.26.0 official Python MCP SDK v1 FastMCP mate pin chhe; standalone fastmcp package nathi. SDK main branch have v2 API batavi shake chhe, etle unpinned upgrade aa code mate na karo. Transitive dependencies fully locked nathi; tamari working install record karva:

Powershell


& ".\.venv\Scripts\python.exe" -m pip freeze | Set-Content -Encoding utf8 requirements-lock.txt
3. Tamaro actual KiCad CLI shodho
Major version guess na karo:

Powershell


Get-ChildItem -LiteralPath 'C:\Program Files\KiCad' -Filter 'kicad-cli.exe' -Recurse -File -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
$env:KICAD_CLI = Read-Host 'Paste the full kicad-cli.exe path (without surrounding quotes)'
$env:KICAD_CLI = (Resolve-Path -LiteralPath $env:KICAD_CLI).Path
$env:KICAD_WORKSPACE = (Resolve-Path -LiteralPath "$env:USERPROFILE\kicad-workspace").Path
& $env:KICAD_CLI version
& $env:KICAD_CLI pcb drc --help
Custom install folder hoy to tena folder par Get-ChildItem karo. Ek karta vadhu exe male to je installed version tame use karo cho te select karo. Help ma --format, --output, --exit-code-violations check karo.
Tamara trusted .kicad_pcb files kicad-workspace ma mukho. DRC mate related .kicad_pro/.kicad_dru hoy to board ni sathe rakho; otherwise project rules missing hoy shake. KiCad GUI ma save thayeli copy par check thashe, unsaved GUI state par nahi.
4. Server code save karo
Download kicad_mcp_server, athva niche nu badhu code VS Code ma paste karo. kicad-mcp\kicad_mcp_server.py tarike save karo, .py.txt nahi. Download ne pan inspect karo. Reports automatic kicad-mcp\reports ma banashe, workspace ma nahi.

Python


import json
import os
from pathlib import Path
import subprocess
import tempfile
import uuid
from mcp.server.fastmcp import FastMCP


def configured(name: str) -> Path:
    p = Path(os.environ[name])
    if not p.is_absolute():
        raise ValueError(f"{name} must be an absolute path")
    return p.resolve(strict=True)


WORKSPACE = configured("KICAD_WORKSPACE")
CLI = configured("KICAD_CLI")
if not WORKSPACE.is_dir() or not CLI.is_file():
    raise ValueError("Workspace must be a directory; CLI must be a file")
REPORTS = Path(__file__).resolve().parent / "reports"
REPORTS.mkdir(exist_ok=True)
REPORTS = REPORTS.resolve(strict=True)
if REPORTS.is_relative_to(WORKSPACE) or WORKSPACE.is_relative_to(REPORTS):
    raise ValueError("Keep workspace and report directory separate")
mcp = FastMCP("KiCad Read-Only Starter")


def board_path(relative_path: str) -> Path:
    if len(relative_path) > 1000 or ":" in relative_path:
        raise ValueError("Use a relative board path without colon")
    p = Path(relative_path)
    if p.is_absolute() or ".." in p.parts:
        raise ValueError("Absolute paths and parent traversal are forbidden")
    p = (WORKSPACE / p).resolve(strict=True)
    if not p.is_relative_to(WORKSPACE):
        raise ValueError("Board escapes configured workspace")
    if p.suffix.lower() != ".kicad_pcb" or not p.is_file():
        raise ValueError("Expected an existing .kicad_pcb file")
    return p


def run_cli(args: list[str], timeout: int) -> dict:
    # Disk-backed output avoids unbounded captured stdout in memory.
    with tempfile.TemporaryFile() as out, tempfile.TemporaryFile() as err:
        try:
            result = subprocess.run(
                [str(CLI), *args], shell=False, stdin=subprocess.DEVNULL,
                stdout=out, stderr=err, cwd=str(REPORTS), timeout=timeout,
                check=False,
            )
        except subprocess.TimeoutExpired:
            return {"ok": False, "error": f"KiCad timed out after {timeout}s"}
        except OSError as exc:
            return {"ok": False, "error": str(exc)[:1000]}
        out.seek(0)
        err.seek(0)
        return {"returncode": result.returncode,
                "stdout": out.read(4096).decode("utf-8", errors="replace"),
                "stderr": err.read(4096).decode("utf-8", errors="replace"),
                "output_limit_bytes_per_stream": 4096}


@mcp.tool()
def kicad_version() -> dict:
    """Read the configured KiCad CLI version."""
    return run_cli(["version"], 15)


@mcp.tool()
def list_boards() -> dict:
    """List up to 100 board files under the configured workspace."""
    boards = []
    visited = 0
    for root, dirs, names in os.walk(WORKSPACE, followlinks=False):
        visited += 1
        dirs[:] = [d for d in sorted(dirs)
                   if (Path(root) / d).resolve().is_relative_to(WORKSPACE)]
        if visited > 2000:
            return {"boards": boards, "truncated": True}
        for name in sorted(names):
            p = Path(root) / name
            if p.suffix.lower() == ".kicad_pcb":
                try:
                    checked = board_path(str(p.relative_to(WORKSPACE)))
                except (ValueError, OSError):
                    continue
                relative = checked.relative_to(WORKSPACE).as_posix()
                if len(relative) <= 1000:
                    boards.append(relative)
                if len(boards) >= 100:
                    return {"boards": boards, "truncated": True}
    return {"boards": boards, "truncated": False}


@mcp.tool()
def run_drc(relative_path: str) -> dict:
    """Read a board and write a JSON DRC report outside its workspace."""
    board = board_path(relative_path)
    report = REPORTS / f"drc-{uuid.uuid4().hex}.json"
    result = run_cli(["pcb", "drc", "--format", "json", "--output",
                      str(report), "--exit-code-violations", str(board)], 120)
    result["report_path"] = str(report)
    result["report_exists"] = report.is_file()
    result["meaning"] = "0 = no violations; 5 = violations; other = CLI failure"
    if report.is_file():
        with report.open("rb") as f:
            preview = f.read(12001)
        result["report_preview"] = preview[:12000].decode("utf-8", errors="replace")
        result["report_preview_truncated"] = len(preview) > 12000
    return result


if __name__ == "__main__":
    mcp.run(transport="stdio")
Aa server ma print() stdout par na umero: stdout MCP protocol mate reserved chhe. Debugging hoy to stderr par lakho. Input trusted rakho: aa OS security sandbox nathi; malicious local process path/symlink badle to race possible chhe. Related KiCad files par CLI potani permissions thi read kari shake chhe. Model arbitrary command, CLI flags ke output path choose kari shaktu nathi. Temporary output disk par chhe; returned output bounded chhe, pan full report ane temp logs disk space vapare chhe. Reports manually clean karo; automated deletion tool nathi.
5. PowerShell smoke test ane config generate
Same terminal ma env vars set hova joie. Import server process start nathi kartu; tran tool registrations ane actual CLI version check kare chhe:

Powershell


& ".\.venv\Scripts\python.exe" -m py_compile .\kicad_mcp_server.py
& ".\.venv\Scripts\python.exe" -c "import kicad_mcp_server as s; print(s.kicad_version()); print(s.list_boards())"
returncode: 0 ane installed version aavvu joie; empty boards hoy to workspace ma board copy karo. Paths manually escape karva karta PowerShell thi tamara actual absolute paths nu Cline JSON banavo:

Powershell


$python = (Resolve-Path -LiteralPath '.\.venv\Scripts\python.exe').Path
$script = (Resolve-Path -LiteralPath '.\kicad_mcp_server.py').Path
$config = @{ mcpServers = @{ 'kicad-readonly' = @{
  command = $python
  args = @($script)
  env = @{ KICAD_CLI = $env:KICAD_CLI; KICAD_WORKSPACE = $env:KICAD_WORKSPACE }
  disabled = $false
  autoApprove = @()
} } }
$config | ConvertTo-Json -Depth 8 | Set-Content -Encoding utf8 .\cline-kicad-config.json
Get-Content .\cline-kicad-config.json
Output no shape aa rite hashe (aa illustration chhe; Student ane CLI major tamara actual values hova joie, generated file vaparo):

JSON


{
  "mcpServers": {
    "kicad-readonly": {
      "command": "C:\\Users\\Student\\kicad-mcp\\.venv\\Scripts\\python.exe",
      "args": ["C:\\Users\\Student\\kicad-mcp\\kicad_mcp_server.py"],
      "env": {
        "KICAD_CLI": "C:\\Program Files\\KiCad\\9.0\\bin\\kicad-cli.exe",
        "KICAD_WORKSPACE": "C:\\Users\\Student\\kicad-workspace"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
JSON ma backslash \\ escape thay chhe; PowerShell generated JSON aa automatic kare chhe. Command string ma extra quote characters na umero. Cline launch mate env config ma explicitly aapiye chhiye, etle terminal env inherit thavani assumption nathi.
6. Cline ma connect karo
Cline panel → MCP Servers icon → Configure → Configure MCP Servers. Extension je MCP settings JSON khole, ema generated kicad-readonly entry existing mcpServers andar merge karo. Bija servers delete/replace na karo; existing config no backup rakho. Empty settings hoy to full generated object paste karo. JSON ma comments/trailing commas na rakho.
Aa Cline ni MCP config chhe; VS Code built-in Copilot .vscode/mcp.json alag system/schema chhe, tya aa object mukvathi Cline configure nahi thay. Global settings path versions pramane badlai shake chhe, etle Cline UI thi correct file kholo.
Save karo ane server Restart karo. autoApprove: [] rakho; global Use MCP servers auto-approve ane YOLO off rakho, calls review kari approve karo. DRC 120 seconds sudhi chale chhe; jarur pade to Cline server request timeout UI ma 150 seconds ke vadhu rakho. Manual Python script run karo to te stdin MCP messages ni rah joshe; blank terminal normal chhe, Ctrl+C thi bandh karo. Cline ene potane launch kare chhe, permanent terminal server separately start karvani jarur nathi.
Cline ma aa prompts ek-ek try karo:

Text


Use the kicad-readonly MCP server to check the KiCad version.
Use the kicad-readonly MCP server to list board files.
Use run_drc on the relative board path returned by list_boards. Do not edit any files or use terminal commands.
Tool argument example: {"relative_path":"flight-controller.kicad_pcb"}; subfolder mate boards/flight-controller.kicad_pcb. Absolute path, .., colon ane workspace escape reject thashe. Cline na built-in terminal/edit tools aa server ni restrictions thi control thata nathi; tenu approval alag review karo.
DRC JSON report no full path result ma aavshe. Return code 0 = no reported violations, 5 = violations, bijo code = CLI failure. 5 ne server setup failure na samjo. Preview 12,000 bytes sudhi chhe ane truncated JSON valid complete JSON na hoy shake; full report VS Code ma manually kholo. Error = wrong; Warning = possibly wrong; Info = noteworthy. DRC clean hovu flight-controller safety, power integrity, firmware compatibility ke manufacturing sign-off nu proof nathi. Zone refill/save flags purposely vaparya nathi, etle stale zone-fill state ni limitation dhyan ma rakho.
7. Common problems
  • No module named mcp: correct .venv\Scripts\python.exe ma mcp==1.26.0 install karo; global Python sathe mix na karo.
  • KeyError KICAD_CLI/KICAD_WORKSPACE: import karta pehla env set karo; Cline config ma banne env entries rakho.
  • File not found: generated absolute paths check karo, .py.txt extension check karo, selected CLI executable actually installed chhe te check karo.
  • Workspace/report separation error: workspace server folder no parent na rakho; aa guide ni sibling folders use karo.
  • Server disconnect: Cline logs check karo; stdout prints remove karo. Installed Python/SDK versions ane env verify karo.
  • No boards: actual downloaded .kicad_pcb workspace ma rakho, fakt Flux URL nahi.
  • JSON DRC option unsupported: installed CLI help check karo ane supported KiCad release install karo; flags silently remove na karo.
  • DRC nonzero/report missing: result na stderr ane CLI returncode joi board format/version compatibility check karo. Newer board older CLI thi na khule shake.
Verification ane limitations
Completed: official docs research; full code; PowerShell/Cline configuration; downloadable source; Linux Python 3.12 + mcp==1.26.0 install, compile/import, exact three-tool registration, real stdio initialize/list/call/shutdown lifecycle; actual KiCad version tool returned 10.0.6; mock subprocess DRC report writing/exit 5 and timeout; traversal/absolute/colon/outside-symlink rejection; pip check no broken requirements. Mock board input was a test fixture, not this project PCB. Real PCB DRC was not run.
Warning: latest resolved pydantic-settings emitted IncompleteFieldDefinitionWarning for SDK lifespan annotations to stderr; tested tool registration and stdio lifecycle still passed. Windows/Python 3.11 environment not tested; dependency resolution may differ. Pinning SDK alone is not a complete dependency lock.
Unattempted: installing on user's Windows PC, live Cline connection, actual-board DRC, Flux export/sync, editing/routing. These require local setup/board file; no host access claimed. No hardware design mutations performed. This starter task completion is separate from flight-controller design completion.
Official evidence (checked 2026-10-09)
  1. Cline MCP overview: IDE Configure workflow; local mcpServers with command, args, env, disabled, autoApprove.
  2. Cline Auto Approve: global MCP approval and YOLO bypass require caution.
  3. Official Python MCP SDK v1.26.0: FastMCP import/tool/direct execution and stdio transport. Current main SDK now describes v2; do not mix APIs.
  4. KiCad 9 CLI manual: kicad-cli version, pcb drc --format json --output ... --exit-code-violations INPUT_FILE; violation exit 5. Installed Linux KiCad 10.0.6 help independently checked these flags.
  • Shu banavishu?

  • 1. Jaruri software

  • 2. Folder ane Python venv

  • 3. Tamaro actual KiCad CLI shodho

  • 4. Server code save karo

  • 5. PowerShell smoke test ane config generate

  • 6. Cline ma connect karo

  • 7. Common problems

  • Verification ane limitations

  • Official evidence (checked 2026-10-09)