Detects wire segments with at least one dangling endpoint — an endpoint
not connected to a component pin, net label, or another wire. These
cause ERC 'wire end unconnected' violations and are a common symptom of
incomplete routing or stray stub wires.
Algorithm uses exact KiCad IU (10 000 IU/mm) coordinate matching,
consistent with wire_connectivity.py:
1. Build an endpoint-frequency map for all wires (IU precision)
2. Collect anchored IU points: component pins (via PinLocator),
net labels / global_labels, power symbol pins
(via _parse_virtual_connections)
3. An endpoint is dangling when it is touched by exactly one wire AND
is not an anchored point; the containing wire is reported
Does not require the KiCad UI to be running.
Changes:
python/commands/schematic_analysis.py — find_orphaned_wires() function
python/kicad_interface.py — handler + route registration
python/schemas/tool_schemas.py — MCP schema entry
src/tools/schematic.ts — TypeScript server.tool() call
tests/test_schematic_analysis.py — 7 integration tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add_schematic_net_label: document new optional componentRef/pinNumber
snap-to-pin mode, labelType/orientation params, response fields
(actual_position, snapped_to_pin), and updated position to optional
- connect_to_net: document new response fields (pin_location,
label_location, wire_stub)
- get_schematic_pin_locations: update cross-reference to reflect that
direct pin snapping is now available in add_schematic_net_label
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
add_schematic_net_label now accepts optional componentRef + pinNumber to
snap the label directly to the exact pin endpoint via PinLocator, removing
all approximation risk. The response always includes actual_position and,
when snapping was used, snapped_to_pin — so the caller gets confirmation
of exactly where the label landed.
connect_to_net return type changed from bool to Dict, returning
pin_location, label_location, and wire_stub on success so agents no
longer need a separate verification call to confirm placement.
connect_passthrough updated to check result.get("success") against the
new dict return. tool_schemas.py and schematic.ts updated to match
(position is now optional, componentRef/pinNumber/labelType/orientation
added, connect_to_net schema field names corrected).
17 new unit tests in tests/test_net_label_pin_snapping.py.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move all Python test files from python/tests/ to the top-level tests/
directory to match the project's CONTRIBUTING.md guidelines. Update
sys.path inserts and template path references to reflect the new
location.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix incorrect default Claude Desktop config path — macOS uses
~/Library/Application Support/Claude/claude_desktop_config.json,
not ~/.config/Claude/claude_desktop_config.json.
Capture stderr in merge_config subshell (2>&1) so Python tracebacks
and interpreter errors are surfaced instead of silently dropped when
the command substitution fails under set -e.
Update README.md and docs/PLATFORM_GUIDE.md to reflect the corrected
macOS config path, and split the combined Linux/macOS config location
reference into separate per-platform entries.
Add trailing newline at the end.
Add setup-macos.sh, a shell script that automates Claude Desktop MCP
configuration on macOS. The script detects KiCad's bundled Python,
resolves PYTHONPATH, generates the correct MCP server config, and
safely merges it into the existing Claude Desktop configuration with
backup support. Supports --verify, --dry-run, and --apply modes.
Update README.md with documentation for the automated setup workflow,
including usage examples, parameter reference, and post-setup steps.
Extend docs/PLATFORM_GUIDE.md with macOS-specific sections covering
installation, path handling, Python environment, troubleshooting,
best practices, cross-platform migration, and support resources.
Update docs/STATUS_SUMMARY.md to reflect the new macOS automation
capabilities and bump the last-updated date.
Add type annotations to all previously untyped functions and remove 9
suppressed error codes (call-arg, assignment, return-value, operator,
has-type, dict-item, misc, list-item, annotation-unchecked) by fixing
the underlying type issues.
Add [[tool.mypy.overrides]] with ignore_missing_imports for KiCAD-specific
modules (pcbnew, sexpdata, skip, cairosvg, kipy, PIL) so the pre-commit
mypy hook passes in its isolated venv. Add types-requests and pytest to
additional_dependencies in .pre-commit-config.yaml.
Also fixes several real bugs uncovered by stricter checks: incorrect static
calls to instance methods in swig_backend, wrong return type on get_size,
missing value param in BoardAPI.place_component, variable shadowing in
kicad_process.py, unqualified LibraryManager reference in kicad_interface,
and missing top-level Path import.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
With --system-site-packages, mypy can resolve pcbnew, skip, and sexpdata
directly from the system/venv, so per-module ignore_missing_imports
overrides are no longer needed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These packages are not imported anywhere in the codebase, so their
ignore_missing_imports overrides were unnecessary.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove global ignore_missing_imports and the import-untyped disable,
replacing them with targeted per-package overrides for third-party
libraries that lack stubs (pcbnew, skip, sexpdata, cairosvg, kipy,
schematic). Also add python/ to mypy_path so internal modules resolve.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add list_schematic_nets, list_schematic_labels, and get_schematic_view
to the longRunningCommands list so they use the 10-minute timeout
instead of the default 30 seconds. These commands regularly exceed
the 30s limit on larger schematic files.
The TS<->Python communication channel uses stdout for JSON responses.
pcbnew's C++ SWIG layer can write warnings and diagnostics directly to
C-level stdout (fd 1), corrupting the JSON framing. The TS parser then
never sees valid JSON and the command times out after 30 seconds.
Three changes fix this:
1. Python stdout redirect: In main(), save the original stdout fd for
exclusive JSON response use, then redirect fd 1 to stderr so all
pcbnew C++ output goes to logs instead of the response pipe.
2. Robust TS JSON parser: tryParseResponse() now uses newline-delimited
parsing as a fallback. The Python side writes single-line JSON
terminated by \n; the parser uses this as the completion signal
instead of brace-matching, which prevents premature resolution of
truncated chunked responses. Non-JSON preamble lines are logged
and stripped.
3. Fix stray print() calls: Converted print() to logger in
component_schematic.py and library_schematic.py so they don't
leak to stdout during normal operations.
Also adds sync_schematic_to_board to the longRunningCommands list for
an appropriate timeout value.
Restore the tool registration order so move_schematic_component appears
before rotate_schematic_component, matching the pre-PR location.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The PR added a second server.tool("move_schematic_component", ...) at line 1127
without removing the original registration at line 722, causing the server to
fail on startup with "Tool move_schematic_component is already registered".
Also adds tests/test_ts_tool_registry.py which scans all src/tools/**/*.ts files
for duplicate server.tool() names so this class of bug is caught automatically.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When moving a schematic component whose pins directly touch pins of
stationary components (no wire segment, just pin-to-pin contact),
synthesize bridge wires to preserve the electrical connection after
the move. Also fixes duplicate-pin-position collision in old_to_new
map and updates symbol reference assignment to use setAllReferences.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When moving a schematic component, connected wires are stretched/shifted
to follow the component (like KiCAD's drag behaviour), preserving
connectivity instead of leaving dangling wire stubs.
Also fixes property labels (value, reference, etc.) so they shift with
the symbol rather than staying at their original positions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace mirrors-prettier alpha (v4.0.0-alpha.8) with local hook using
the stable prettier installed via package.json
- Remove .prettierignore entries already handled by the hook's exclude pattern
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix mypy duplicate module conflict by excluding python/commands/board.py
- Add import-untyped to mypy disabled error codes
- Use explicit_package_bases for proper module resolution
- Auto-format root-level download_jlcpcb.py and test-router.js
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Install eslint, @eslint/js, and typescript-eslint as dev dependencies.
Add eslint.config.js (flat config) with rules tuned to zero errors on
the current codebase, add ESLint local hook to .pre-commit-config.yaml,
and update the lint:ts npm script to use ESLint directly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds [tool.mypy] section to pyproject.toml with permissive baseline settings
and disables error codes that fire against the existing untyped codebase.
Adds the mirrors-mypy pre-commit hook (v1.19.1) running over python/ at once.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds .flake8 config and registers the flake8 pre-commit hook scoped to
python/ at rev 7.3.0. Baseline ignore rules (E501, F401, F541, F841,
E722, E402, E741, F811, F821, F824, E231) suppress existing violations
so the hook passes cleanly on the current codebase.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Prettier as a dev dependency with .prettierrc.json config and
.prettierignore. Hook added via mirrors-prettier in pre-commit config.
All TypeScript, JSON, Markdown, and YAML files auto-formatted.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add isort configuration (profile=black, line_length=100) to pyproject.toml,
add isort pre-commit hook, and auto-sort imports across all Python source files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add [tool.black] config to pyproject.toml and Black hook to
.pre-commit-config.yaml (rev 26.3.1), then auto-format all Python
source and test files with line-length=100, target-version=py310.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add .pre-commit-config.yaml with pre-commit-hooks v5.0.0 (trailing
whitespace, end-of-file fixer, yaml/json checks, large file guard,
merge conflict detection). Add minimal pyproject.toml. Auto-fix
trailing whitespace and missing end-of-file newlines across the
codebase.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace /home/chris/... absolute paths with Path(__file__)-relative
equivalents in wire_manager.py and pin_locator.py so the test
scripts work on any machine.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace inline Symbol() allocations with the existing _SYM_WIRE/_SYM_PTS/_SYM_XY
constants and new _SYM_AT/_SYM_LABEL constants for consistency.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds an optional `layer` parameter (e.g., 'F.Cu', 'B.Cu') to the
move_component tool. When specified, the component is flipped to
the target layer if it's not already on it. The response now also
includes the component's layer after the move.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: JLCPCB database download and FTS search
Thanks! you rock. JLCPCB parts things has been a headache. I will look over the whole implementation this weekend.
- Rename add_schematic_connection → add_schematic_wire with waypoints[] parameter
- Add snapToPins (default true) to snap wire endpoints to nearest pin
- Expose add_schematic_junction as an MCP tool
- Break existing wires at new wire endpoints for T-junction support
- Remove orphaned add_connection / add_wire / get_pin_location from ConnectionManager
- Update tool registry to reflect renamed schematic tools in TS layer
- Add 76 tests for wire/junction handler dispatch, schema validation, and WireManager corner cases
- Apply Black and Prettier formatting to changed files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the 0.5mm query tolerance in favour of exact integer-unit matching
on all coordinate lookups (seed, label bridging, pin matching), mirroring
KiCad's own connectivity algorithm. Callers must supply exact wire endpoint
coordinates (e.g. from list_schematic_wires).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>