Title: MCP: list every connected browser tab and route client tool calls per tab · Issue #394 · devframes/devframe · GitHub
Open Graph Title: MCP: list every connected browser tab and route client tool calls per tab · Issue #394 · devframes/devframe
X Title: MCP: list every connected browser tab and route client tool calls per tab · Issue #394 · devframes/devframe
Description: Problem With several browser tabs of the same app open (same port), the MCP surface acts as if there were one client: devframe_connect_list-instances lists node instances keyed per (port, basePath) (packages/devframe/src/node/instance-re...
Open Graph Description: Problem With several browser tabs of the same app open (same port), the MCP surface acts as if there were one client: devframe_connect_list-instances lists node instances keyed per (port, basePath)...
X Description: Problem With several browser tabs of the same app open (same port), the MCP surface acts as if there were one client: devframe_connect_list-instances lists node instances keyed per (port, basePath)...
Opengraph URL: https://github.com/devframes/devframe/issues/394
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP: list every connected browser tab and route client tool calls per tab","articleBody":"## Problem\n\nWith several browser tabs of the same app open (same port), the MCP surface acts as if there were one client:\n\n- `devframe_connect_list-instances` lists node instances keyed per `(port, basePath)` (`packages/devframe/src/node/instance-registry.ts`), so tabs are invisible by construction — N tabs share one dev-server process.\n- The client-tool bridge from #376 (`devframe:agent:sync-client-tools` → `node/client-agent.ts`) tracks one session entry per tab, but tool ids collide across tabs and the provider loop lets the **last-synced session silently own every tool**. medula currently ships this as an uncommitted vendored patch and documents it as \"the tab you focused last\" — there is no actual focus tracking.\n\nA coding agent cannot see which tabs are connected, nor act on a specific one.\n\n## Proposal\n\nMake connected RPC clients (browser tabs) first-class on the MCP surface: list them per instance, and let a tool call target one.\n\n### 1. Stable tab identity (devframe core, browser side)\n\n- Each tab mints a sessionStorage-backed tab id (same pattern as the hub's frame-nav `tabId`, `packages/hub/src/client/frame-nav.ts`), so it survives reloads and reconnects. Caveat to handle: browser tab duplication copies sessionStorage — follow the frame-nav dedupe approach.\n- The RPC client reports tab metadata to the node: tab id, URL, title, visibility/focus state, plus the client tool manifest it already syncs.\n- Freshness: metadata is (re)sent on connect, on `focus`/`visibilitychange`, and with every client-tool re-sync. No history-API patching; URL may lag briefly after an SPA navigation until the next event.\n\n### 2. Per-tab session registry (devframe core, node side)\n\n- Extend the #376 session tracking (`node/client-agent.ts`) to keep, per RPC session: tab id, metadata, tool manifests, `connectedAt`, last-focused timestamp.\n- Cleaned up on session disconnect (existing `_emitSessionDisconnected` hook).\n\n### 3. Listing (agentic)\n\n- New built-in agent tool `devframe:agent:list-clients` on each instance's own MCP endpoint: returns the connected tabs with id, URL, title, visibility, connectedAt, and available client tool names.\n- `devframe_connect_list-instances` (`packages/agentic/src/connect/index.ts`) calls it per live instance and nests a `clients` array in each instance entry — no new gateway tool.\n\n### 4. Per-tab tool routing (agentic + core)\n\n- `tools/list` stays deduped: one entry per tool id regardless of tab count (no per-tab suffixing, no list churn).\n- Client-forwarded tools accept an optional reserved `client_id` argument, injected into their published inputSchema and stripped before forwarding. Works with any MCP client; `devframe_connect_call-tool` passes it through unchanged.\n- `client_id` given → route to that tab's session. Unknown/gone id → fail fast with an error that includes the current live client ids so the agent can re-target in one step.\n- `client_id` omitted → focus-aware default: the most-recently-focused visible tab wins, falling back to last-synced. This upstreams medula's vendored patch and makes its \"tab you focused last\" behavior actually true; stray headless tabs stop competing (a known medula pain point).\n\n## Dependencies / sequencing\n\n- Builds directly on #376 (`eager-client-script`), which is still draft and based on v0.9.18 — it predates the 0.10 move of MCP into `@devframes/agentic` and needs a rebase. Landing strategy (rebase #376 first vs. fold into one effort) intentionally left open here.\n- medula can drop its vendored `client-agent.ts` patch once this lands.\n\n## Out of scope\n\n- Forwarding WebMCP (`document.modelContext`) surfaces — untouched; this is about the #376 RPC bridge.\n- Hub-specific UI; the hub aggregate MCP benefits automatically since it sits on the same context.\n\n---\nThis issue was created with the help of an agent.\n","author":{"url":"https://github.com/antfubot","@type":"Person","name":"antfubot"},"datePublished":"2026-09-15T23:11:12Z","url":"https://github.com/devframes/devframe/issues/394"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cc4d47d3-40b4-f00b-eda0-129527356de6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A924:C876F:13323EC:1A63778:6AFB7381 |
| html-safe-nonce | 3e8ec09f27c14add07edd97886fb645eaf0b23e708786dac31818648253d5321 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTI0OkM4NzZGOjEzMzIzRUM6MUE2Mzc3ODo2QUZCNzM4MSIsInZpc2l0b3JfaWQiOiIyNjUzNjYyNjk4NzAxNzUxMDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6ba6f94d7b947410bf53f3ad0dd6bb75929cd19ee85fdbd1d987fc1b80c39856 |
| hovercard-subject-tag | issue:5468309582 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/devframes/devframe/394/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30a0fbe8761a455557972b6ba543a4e958fd86cf45b50a7905ca44870828c7f9/devframes/devframe/issues/394 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30a0fbe8761a455557972b6ba543a4e958fd86cf45b50a7905ca44870828c7f9/devframes/devframe/issues/394 |
| og:image:alt | Problem With several browser tabs of the same app open (same port), the MCP surface acts as if there were one client: devframe_connect_list-instances lists node instances keyed per (port, basePath)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | antfubot |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0e29e7974fdda2feeaf5c891efd4b23b0734b23480232b62c7bdef13f40b5b48 |
| turbo-cache-control | no-preview |
| go-import | github.com/devframes/devframe git https://github.com/devframes/devframe.git |
| octolytics-dimension-user_id | 279879373 |
| octolytics-dimension-user_login | devframes |
| octolytics-dimension-repository_id | 1231722386 |
| octolytics-dimension-repository_nwo | devframes/devframe |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1231722386 |
| octolytics-dimension-repository_network_root_nwo | devframes/devframe |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2e8872b770cc4d5d0cc1f2026afab747a268e2ce |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width