# fix\(server\): hide browser and device tools when agent access is off · PR \#24314 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/24314)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: fix/issue-17202

Target branch: main

Head commit: a3424bfae625ab19759d099a36d7a601846bb170

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/24314)

[Commits](https://git.cafe/pingdotgg/t3code/pull/24314/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/24314/diffs?format=markdown)

## Description

---

## Problem

With Agent browser access and Agent device access off, a fresh agent session still discovers preview and device tools that fail when called. Reproduced in the real web dev app with a fresh Claude session: 19 preview tools, four device tools and both preview controls remained advertised.

## Change

Gate standard preview/device tools, their custom image tools and preview controls using the authenticated credential's existing capabilities at MCP registration. Discovery and calls use the same gate; hidden tools return tool-not-found. Existing handler capability checks remain in place. Other tool registrations are unchanged.

## Scope and approval

Fixes https://github.com/pingdotgg/t3code/issues/17202

GitCafe: https://git.cafe/pingdotgg/t3code/issues/17202

Triaged bug via the automated issue flow. This fixes discovery for the existing browser/device access settings without adding settings, capabilities or persisted state.

## Verification

- Red first: the real HTTP `tools/list` regression failed without the required capabilities; the preview-controls follow-up also failed before its fix. [Original red log](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/280beb53bb5558d4/17202-red-output.txt), [controls red/green](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/389803a18d849586/17202-controls-output.txt).
- After merging current main, `vp test run apps/server/src/mcp/McpHttpServer.test.ts apps/server/src/mcp/McpDeviceToolkit.test.ts apps/server/src/mcp/toolkits/previewControls/handlers.test.ts`: **26 passed across three files**. Tests cover neither capability, preview only, device only and both, including image tools, both controls and an ordinary tool. [Post-merge log](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/cd0e22123e87dec2/17202-postmerge-green.txt).
- CI follow-up: supplied the missing PreviewManager mock required by the preview-controls registration in the HTTP test fixture. Scoped server typecheck now exits 0; 48 focused tests across McpHttpServer, McpDeviceToolkit and PreviewAutomationBroker pass. Targeted lint/format pass. Production code is unchanged by this follow-up. Three rounds of isolated reviews found no remaining defects. [Proof audit closure](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/25307d09a0e31711/17202-proof-pass2-closure.md).

| Runtime evidence | Before | After |
| --- | --- | --- |
| Real isolated web dev server; fresh Claude Code 2.1.303 / Opus 5.5 session; both access settings off | [Transcript](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/2a63404c541ae920/17202-before-transcript.txt): preview/device tools advertised, calls denied. Build [3b95e7831b](https://github.com/pingdotgg/t3code/commit/3b95e7831b). | [Transcript](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/54b48fa86adf20d8/17202-final-runtime-transcript.txt) and [raw offered catalog + successful ordinary call/result](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/71023c4c3020ea10/17202-raw-session-proof.json): no preview/device tools or controls, ordinary MCP works. Build [43104e9349](https://github.com/pingdotgg/t3code/commit/43104e9349). |

All affected files are identical between the captured fixed build and merge head [a44ddee637](https://github.com/pingdotgg/t3code/commit/a44ddee637). Before-build affected files are identical to the original main base. [Evidence index](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/44fa53a1ae0ea3e3/17202-evidence.md), [fixture matrix](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/45eee589894c78fc/17202-proof-matrix-final.md).

Published head also includes the test-fixture-only service mock correction; the runtime implementation remains identical to the captured fixed build.

Visual matrix is empty: server registration and tests only, with no client render changes. No screenshot or pixel-sameness claim. Live enabled-permission sessions and every provider/transport permutation were not checked; the four capability combinations are covered over real HTTP on the shared server boundary.

Models: Claude Opus 5.5 and GPT-6.1-sol. Harness: T3 Code with Claude Code and Codex.

