Skip to content

Fix Number Slider routing + id param name in get_component_info#6

Open
TWAWEI wants to merge 1 commit into
alfredatnycu:masterfrom
TWAWEI:bugfix/fuzzy-match-and-id-param
Open

Fix Number Slider routing + id param name in get_component_info#6
TWAWEI wants to merge 1 commit into
alfredatnycu:masterfrom
TWAWEI:bugfix/fuzzy-match-and-id-param

Conversation

@TWAWEI

@TWAWEI TWAWEI commented Apr 24, 2026

Copy link
Copy Markdown

Summary

Two independent bug fixes I hit while testing the MCP on macOS. Both affect Windows too — the second one means get_component_info (and everything that calls it, like connect_components smart-routing) has never worked.

Bug 1 — add_component('slider') creates MD Slider instead of Number Slider

Repro: send {\"type\":\"add_component\",\"parameters\":{\"type\":\"slider\",\"x\":0,\"y\":0}} to the .gha.
Actual: returns GH_MultiDimensionalSlider.
Expected: returns GH_NumberSlider.

Root cause: FuzzyMatcher.ComponentNameMap normalizes \"slider\"\"Number Slider\". The switch in ComponentCommandHandler.AddComponent has case \"slider\" / \"numberslider\" / \"gh_numberslider\" but not \"number slider\" (with space). So the normalized value falls through to the default branch, which does a partial name match using the original (non-normalized) input \"slider\" — the first proxy whose name contains \"slider\" wins, which happens to be \"MD Slider\".

Fix: add case \"number slider\": alongside the existing slider cases so the post-normalization value is matched directly.

Bug 2 — get_component_info parameter name mismatch

Repro: call the get_component_info MCP tool from any client.
Actual: \"Error executing command 'get_component_info': Component ID is required\".

Root cause: bridge.py sends the ID under key componentId, but the C# handler reads command.GetParameter<string>(\"id\"). Every call has been failing with "Component ID is required". This also breaks connect_components' auto-routing logic (for multi-input components like Addition), which internally calls get_component_info.

Fix: change bridge.py to send \"id\" in all 3 call sites.

Test plan

On Mac (Rhino 8.21 for Mac, net7.0 build of the .gha), verified via direct TCP:

Input Before After
\"slider\" GH_MultiDimensionalSlider ❌ GH_NumberSlider ✅
\"Number Slider\" GH_MultiDimensionalSlider ❌ GH_NumberSlider ✅
\"numberslider\" GH_MultiDimensionalSlider ❌ GH_NumberSlider ✅

And get_component_info now returns the full component metadata (inputs, outputs, dataType, descriptions) instead of the "Component ID is required" error.

Notes

Nothing Mac-specific in either fix — they both affect Windows identically. The upstream csproj already multi-targets net7.0-windows;net7.0;net48, so the C# change rebuilds cleanly for all three without any platform conditionals.

1. AddComponent switch: FuzzyMatcher normalizes 'slider' → 'Number Slider',
   but the switch only had 'slider' / 'numberslider' / 'gh_numberslider' cases.
   The normalized 'number slider' (with space) fell through to the default
   branch, which then partial-name-matched to 'MD Slider' (alphabetical first).
   Added 'number slider' case so the normalized output is matched directly.

2. get_component_info param name: bridge.py sent 'componentId' but the C#
   handler reads GetParameter<string>("id"). Every call to get_component_info
   was erroring 'Component ID is required'. Changed bridge.py to send 'id'
   in all 3 call sites.

Verified via direct TCP:
  slider         → GH_NumberSlider  (was MD Slider)
  Number Slider  → GH_NumberSlider
  numberslider   → GH_NumberSlider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant