Repository navigation
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The bridge schema's operation enum and the FreeCAD-side handler each decide which operations exist; only assembly/varset/spreadsheet had a test tying them together (full-review 2026-09-23 #22). This reads both sides from the real source with ast: the literal types.Tool schemas against each handler's _ALLOWED_OPERATIONS (generic dispatch), the dispatch dicts of partdesign / sketch / view_control, the part_operations if/elif chain, and usage_guidance.query. It also checks every dispatch target is a callable method on its handler class, and fails if any tool with an operation enum is not covered, so a new tool cannot ship unprotected. 222 operations across 19 tools checked, no drift today. Mutation-checked: 12 mutations across every source shape, all caught. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…arity test added (35e29b3) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The handler parsed FREECAD_MCP_PORT with a bare int() at module import on
every platform, so an empty or non-numeric value raised ValueError and took
the whole addon down on Linux/macOS, where the port is never used.
Out-of-range values (0, -1, 65536) and int()-valid oddities ("+80",
"2_3456", fullwidth digits) were accepted silently and failed later, far
from the cause.
Add a strict _parse_port in the handler and the bridge (separate processes
that cannot import each other; a parity test pins that they agree):
unset/empty/whitespace -> 23456, otherwise plain ASCII digits in 1..65535,
else ValueError naming the variable. Never falls back silently on a bad
value. The handler records a bad value instead of raising at import, and
start_server()'s Windows branch reports it and refuses to start before
writing the token file or creating a socket. The bridge fails loudly at
_BridgeCtx construction on Windows and ignores the value elsewhere.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… get "Unauthorized" secrets.compare_digest raises TypeError when both arguments are str and any contains a non-ASCII character. A request carrying such a token was still rejected, but only because the generic `except Exception` in _process_command caught the TypeError and answered "Command processing error: comparing strings with non-ASCII characters is not supported" -- the wrong message, from the wrong code path, on a security check. Confirmed on a real Windows runner against both FreeCAD 1.1.4 and a 27.1.0 weekly. Factor the check into _token_matches(), which compares UTF-8 bytes. It encodes with errors="surrogatepass" because a JSON "\ud800" decodes to a lone surrogate that a plain .encode() would reject; surrogatepass round-trips it exactly, so distinct tokens cannot collide. An empty/None server secret and a non-str token still fail closed. Tests pin 17 ambiguous inputs (non-ASCII, lone surrogate, astral chars, combining mark, case, whitespace, length +/-1, empty, non-str types) to the "Unauthorized" response with nothing dispatched, plus the correct token and a direct _token_matches check. The non-ASCII/surrogate cases fail against the previous comparison. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The handler waited a fixed 30 s for each client's request frame, so the single-deadline receive behavior (PR #121 / issue #120) could not be exercised end to end through the real server in any reasonable time. Add FREECAD_MCP_RECV_TIMEOUT: seconds to wait for one complete request frame per connection (header and body share one deadline). Unset, empty or whitespace-only keeps the 30 s default. Otherwise it must be a plain ASCII decimal greater than 0 and at most 3600. Zero (which socket code treats as non-blocking, not "no timeout"), negatives, NaN/inf, exponents, underscores and non-ASCII digits are rejected. A bad value never silently becomes the default: the module still imports (so a typo cannot take the whole addon down), and start_server() reports the error on every platform and refuses to start. The value is passed to the handler's only receive_message() call site. Documented in AGENT-INSTALL.md. Tests pin both sides of the 0 and 3600 boundaries, the ambiguous number forms, import safety, that the default matches receive_message()'s own default, that the configured value actually reaches receive_message, and that a bad value refuses to start with Windows both on and off. Verified against a real FreeCAD handler: with PR #121's change applied and the timeout at 1.0, a request trickled over ~10 s is dropped at ~1.0 s and the next request is served; without it the same request completes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… Windows A real Windows run (GitHub windows-latest, 2026-11-09) showed 225 of 2766 unit tests failing (185 failed, 40 errors). 57 of 76 modules were already fully green. Most failures are tests assuming POSIX, not product bugs: 52 exec POSIX scripts, 51 need socket.AF_UNIX (absent from Python on Windows), 21 need os.getpgid, 16 use literal /tmp paths, 25 hit open-handle teardown errors, plus POSIX mode-bit and signal assumptions. - Register a `windows_safe` pytest marker (opt-in: new tests do not silently join a platform that is only partially supported) and apply it, via module `pytestmark`, to the 57 fully-green modules plus test_bridge_framing and test_freecad_mcp_handler, which this commit makes portable. The advisory Windows job will run `-m windows_safe`. - test_bridge_framing / TestServerFraming: build the connected pair with socket.socketpair() (AF_UNIX on POSIX, loopback TCP on Windows) instead of binding a /tmp unix socket. This alone makes 30 tests portable. - `server` fixture pins IS_WINDOWS to False (a no-op on Linux/macOS): on a real Windows host it was True, so every generic _process_command test was answered "Unauthorized". Tests of the Windows branch already set it explicitly. - The two TestStartServerMonitorSocketPath tests shim socket.AF_UNIX (raising=False), mirroring how SO_EXCLUSIVEADDRUSE is already shimmed. No production code changes. Linux/macOS: the full suite still passes (2879); `-m windows_safe` selects 1984 of them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ws workflow The handler has a distinct Windows code path (loopback TCP listener, per-launch auth token with an icacls ACL, SO_EXCLUSIVEADDRUSE, pid liveness, instance stop) that had never run on a real Windows host in CI. Add: - tests/windows/: a harness that launches the real headless_server.py under a real FreeCADCmd, fully isolated, and drives it over TCP with the project's own framing. Each server gets its OWN temp tree (and so its own token file); stdout/stderr go to files, not pipes (a Windows pipe holds 4096 bytes); an autouse session gate aborts the run before any test if FreeCAD ignored the profile redirect (it would otherwise use the real profile, or a cwd-relative dir inside the checkout). - Tests: token file, ACL signature (real Windows), a 9-way auth matrix incl. non-ASCII and lone-surrogate tokens, sync/async/poll round trip, exclusive bind (real Windows), token rotation, pid liveness boundaries (real Windows; W-7 and W-9b as strict xfails), framing at MAX-1/MAX/MAX+1 plus zero-length, truncated and short frames, the FREECAD_MCP_RECV_TIMEOUT receive deadline, and a stop/orphan check. - Fake mode (FREECAD_MCP_WINDOWS_TESTS_FAKE=1): tests/windows/fakewin_headless.py forces the handler's Windows branch on Linux/macOS so the harness and the platform-independent tests can be developed locally. It proves logic only; Windows-only tests are skipped and fake results never count as Windows coverage. - .github/workflows/windows-tests.yml: advisory (not in all-tests-pass). tier1 runs `-m windows_safe`; tier2 downloads the pinned FreeCAD, verifies the release-API digest (weekly builds publish no -SHA256.txt), and always runs bin\FreeCADCmd.exe, never the 1.1.x root-level launcher shim. assert_tests_ran.py fails an all-skipped run. Known-failing-by-design: test_slow_trickle_is_dropped_at_the_single_deadline is a strict xfail until PR #121 lands (verified: applying #121 flips it to XPASS(strict)). Mutation check: replacing the token check with `return True` fails all 9 bad-token tests. Local fake-mode run: 23 passed, 13 Windows-only skipped, 1 xfailed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Both files are pure logic (env parsing, import safety, parity) with no POSIX assumptions; they run in the advisory Windows job. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s at dev main is release-only. PRs and Dependabot bumps opened against the default branch (main) can't be merged as-is, and Dependabot auto-merges had left main ahead of dev. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
"mcp-events>=0.1.0" had no upper bound, so a fresh pip install could resolve to a new major with no change in this repo. ~=0.1.0 means >=0.1.0,<0.2; raise it deliberately when adopting a newer mcp-events. uv.lock specifier updated to match (resolved version unchanged, 0.1.0). Closes #119 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replace the elapsed-time bound in test_receive_timeout_bounds_entire_frame with an assertion that the receive gives up before the peer has delivered the full frame, and drive the shared header/body deadline test with a fake monotonic clock. Remove the strict xfail on the Windows slow-trickle test, which this change makes pass.
…kle oracle Add test_receive_deadline_boundary (fake clock; just-below/exactly-at/ just-above the deadline, both framing implementations). Exactly-at must give up and must never hand the socket a non-positive timeout. Mutating 'remaining_time <= 0' to '< 0' in either file now fails it. test_receive_timeout_bounds_entire_frame now also asserts the receiver held on for ~the whole budget (lower bound only, so it cannot flake under load), so a None caused by a disconnect/decode error no longer passes vacuously. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v8.7.0
Changes
FREECAD_MCP_RECV_TIMEOUT(default 30 s, number > 0 and <= 3600) sets how long the FreeCAD side waits for one complete request frame per connection. An invalid value makesstart_server()refuse to start.recv(), so a peer trickling bytes just under the per-read timeout can no longer hold a connection open past the budget. Thanks to @cw-jlu for the fix. Boundary tests pin the exactly-at-deadline case.FREECAD_MCP_PORTis validated instead of crashing on import, and the Windows auth token is compared as bytes so a non-ASCII token gets "Unauthorized" instead of an error.tests/windows) with an advisory Windows workflow,windows_safemarkers, an operation-enum parity test across all 19 tools with anoperationargument, and Python 3.14 in the unit-test matrix.mcp-eventsbounded to the 0.1 series.dev; Dependabot version updates now point atdev.Notes
maincarries Dependabot's own commits for the two ruff bumps and pytest 9.2.0;devhas equivalent cherry-picks (git cherryshows them patch-equivalent), so the trees should match apart from this release's changes. Run~/.claude/scripts/sync-dev-after-release.shright after merging.pyproject.toml,server.json,AICopilot/freecad_mcp_handler.pyanduv.lock. Unit suite ondev: 2909 passed, ruff clean (run locally). The Windows tier-2 job ran green on fix(bridge): enforce one receive deadline per frame #121 before it merged.🤖 Generated with Claude Code