Skip to content

feat: union/intersect/difference app tools — polygon ops on a map#195

Open
mattpodwysocki wants to merge 3 commits into
feat/ground-location-app-toolfrom
feat/polygon-ops-app-tools
Open

feat: union/intersect/difference app tools — polygon ops on a map#195
mattpodwysocki wants to merge 3 commits into
feat/ground-location-app-toolfrom
feat/polygon-ops-app-tools

Conversation

@mattpodwysocki
Copy link
Copy Markdown
Contributor

@mattpodwysocki mattpodwysocki commented May 27, 2026

Summary

Final tools in the MCP Apps pattern series. Three offline Turf.js-based polygon-operation tools — `union_app_tool`, `intersect_app_tool`, `difference_app_tool` — share a single `PolygonOpsAppUIResource` (`ui://mapbox/polygon-ops-app/index.html`) that renders the input polygons in muted blue and overlays the result in an operation-keyed color.

Color key

  • union: green result fill
  • intersect: purple result fill
  • difference: orange result fill

A small bottom-left legend swaps in the right swatch + label per operation.

Graceful no-result

When `intersect` or `difference` produces no overlapping geometry, the tool still returns `isError: false` — the agent gets a "no overlapping geometry" summary, and the UI just shows the input polygons (which makes the empty-result case visually obvious).

Stacked on #194

Final PR in the stack. After everything upstream merges, this will retarget to main.

Test plan

  • 7 new tests covering all three operations, overlapping + non-overlapping cases, and shared resourceUri
  • Updated `annotations.test.ts` offline-tool list to include the three new offline app tools
  • Full suite: 782 tests passing across 67 files
  • Build, lint, format clean
Screenshot 2026-05-27 at 11 46 43

🤖 Generated with Claude Code

Seventh-through-ninth tools in the MCP Apps series. Three Turf.js-based
offline polygon-operation tools share a single PolygonOpsAppUIResource
that renders the input polygons in muted blue and overlays the result
in an operation-keyed color (green=union, purple=intersect,
orange=difference).

When intersect/difference produces no overlapping geometry, the tool
still succeeds (isError=false) and the UI shows just the inputs with a
"no overlapping geometry" summary.

Also adds the three new offline tools to the annotations test's
offlineTools list so the open-world-hint test continues to pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner May 27, 2026 15:30
mattpodwysocki and others added 2 commits May 27, 2026 11:45
Final resource in the series. Same pattern: send size-changed first,
delay 60ms, then map.resize() + fitBounds so polygons fill the
viewport instead of appearing as tiny dots.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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