Skip to content

feat: MCP tools for the map-layers widget#1602

Open
jean-luc-deziel wants to merge 15 commits intoiTwin:masterfrom
jean-luc-deziel:feat/map-layers-mcp
Open

feat: MCP tools for the map-layers widget#1602
jean-luc-deziel wants to merge 15 commits intoiTwin:masterfrom
jean-luc-deziel:feat/map-layers-mcp

Conversation

@jean-luc-deziel
Copy link

@jean-luc-deziel jean-luc-deziel commented Feb 19, 2026

Expose a set of MCP tools for the Bentley copilot to be able to interact with the map-layers widget. This is part of the initiative to enable the Bentley Copilot to interact with everything the user can. Including the map-layers widget. See this RFC (still in PR) for details.

The 9 tools will let the Bentley Copilot perform these actions:

  • Open the map layers widget
  • Toggle on/off background map
  • Set base map type
  • Set map transparency
  • Toggle on/off terrain
  • Get map layer info
  • Attach a new map layer Removed for now for security concern
  • Detach a map layer
  • Set map layer visibility

Open question : Do we want a set of unit tests that ensure the tools are aligned with the widget. In practice, this would prevent someone from modifying the widget without updating the MCP tooling accordingly in the same PR.

In action, it would look something like that:
Capture d’écran 2026-02-10 142324

@CLAassistant
Copy link

CLAassistant commented Feb 19, 2026

CLA assistant check
All committers have signed the CLA.

@jean-luc-deziel jean-luc-deziel marked this pull request as ready for review March 19, 2026 17:03
Copilot AI review requested due to automatic review settings March 19, 2026 17:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new MCP (Model Context Protocol) integration layer to @itwin/map-layers, enabling a Bentley copilot (via MCP) to interact with the Map Layers widget and an active iTwin.js ScreenViewport.

Changes:

  • Added MCP tool functions for common map-layer/viewport operations (toggle background map, set basemap, attach/detach layers, etc.).
  • Added an MCP server definition that registers those tools (stdio-oriented) and a shared viewport accessor mechanism.
  • Exposed a new public subpath export @itwin/map-layers/mcp and added dependencies (@modelcontextprotocol/sdk, zod).

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/itwin/map-layers/src/mcp/viewport.ts Adds shared, settable accessor to reach the live viewport from MCP handlers.
packages/itwin/map-layers/src/mcp/tools.ts Implements MCP-facing viewport/map-layer operations.
packages/itwin/map-layers/src/mcp/server.ts Registers MCP tools on an McpServer and defines request schemas with Zod.
packages/itwin/map-layers/src/mcp/index.ts Public barrel export for MCP API surface.
packages/itwin/map-layers/package.json Adds exports entry for ./mcp and new runtime deps.
packages/itwin/map-layers/pnpm-lock.yaml Locks new dependency graph for MCP SDK + Zod.
change/@itwin-map-layers-2eb91816-915b-4597-b434-ae4c0b597ea9.json Declares a minor change for release notes/versioning.
Files not reviewed (1)
  • packages/itwin/map-layers/pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

jean-luc-deziel and others added 3 commits March 19, 2026 13:14
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@jean-luc-deziel jean-luc-deziel changed the title feat: MCP server for the map-layers widget feat: MCP tools for the map-layers widget Mar 20, 2026
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.

4 participants