feat: MCP tools for the map-layers widget#1602
Open
jean-luc-deziel wants to merge 15 commits intoiTwin:masterfrom
Open
feat: MCP tools for the map-layers widget#1602jean-luc-deziel wants to merge 15 commits intoiTwin:masterfrom
jean-luc-deziel wants to merge 15 commits intoiTwin:masterfrom
Conversation
78b8dc8 to
b47f7eb
Compare
marcalap
reviewed
Feb 19, 2026
Contributor
There was a problem hiding this comment.
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/mcpand 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
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:
Attach a new map layerRemoved for now for security concernOpen 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:
