feat: add chrome_move_tab tool for state-preserving tab moves#335
Open
pooyak wants to merge 1 commit into
Open
feat: add chrome_move_tab tool for state-preserving tab moves#335pooyak wants to merge 1 commit into
pooyak wants to merge 1 commit into
Conversation
Adds a new MCP tool that moves an existing tab between windows
(or detaches it into a new window) using chrome.tabs.move and
chrome.windows.create({ tabId }). Unlike workarounds that read
the URL and reopen it elsewhere, this preserves the tab renderer:
scroll position, navigation history, form input, and any in-page
state remain intact.
API: { tabId, windowId? | newWindow?, index?, focused? }
- windowId and newWindow are mutually exclusive (one is required)
- index defaults to -1 (append) when moving into an existing window
- focused defaults to true
- packages/shared: register MOVE_TAB tool name and schema
- app/chrome-extension: implement MoveTabTool, wire export
a6c0fdf to
6daf44f
Compare
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.
Summary
Adds a new MCP tool
chrome_move_tabthat moves an existing tab between windows (or detaches it into a brand-new window) without reloading the page. Tab state — scroll position, navigation history, form input, and any in-page renderer state — is preserved, because the underlyingchrome.tabs.move/chrome.windows.create({ tabId })APIs reattach the existing renderer rather than recreating it.Motivation
There's currently no MCP tool exposed for moving tabs. Achieving the equivalent today requires reading the URL, opening a new tab in the destination window, then closing the original — which causes a full page reload, a network round-trip, and loss of all in-page state. For users orchestrating tab layouts across many windows (the original motivating use case), this is both lossy and slow.
The Chrome extension API already provides
chrome.tabs.movefor this exact purpose; this PR just exposes it.API
Validation:
tabIdis required.windowId/newWindow=truemust be provided.indexis ignored whennewWindow=true.Changes
packages/shared/src/tools.ts— registerTOOL_NAMES.BROWSER.MOVE_TABand add aTOOL_SCHEMASentry.app/chrome-extension/entrypoints/background/tools/browser/move-tab.ts— newMoveTabToolextendingBaseBrowserToolExecutor.app/chrome-extension/entrypoints/background/tools/browser/index.ts— re-export so the dispatcher picks it up.The tool follows the same shape as
SwitchTabTooland reuses existing error-handling conventions.Test plan
pnpm build:shared— passespnpm build:extension(wxt build) — passes;chrome_move_tabappears in the bundled background.jsnpx eslint <changed files>— clean (the 4 unrelated lint errors onmasterare not in changed paths)npx prettier --check <changed files>— cleanchrome_move_tabwith{ tabId, newWindow: true }and{ tabId, windowId }from an MCP client, confirm tab moves without reload (scroll/form state preserved).Notes
🤖 Generated with Claude Code