# feat\(server\): /mcp narrows a client's modes from T3-Mode-Limit · PR \#16653 · pingdotgg/t3code

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

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

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: t3code/peer/mode-limit-header

Target branch: main

Head commit: d868b6296c8a24bbc150ebb4d96d264316206099

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

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

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

## Description

---

Part of cross-environment orchestration: an environment linked to another signs in to its `/mcp` as an outside agent. Every linked call has to carry the calling agent's own limits, so a plan-mode agent on the laptop can't start full-access work on the box just because the link was approved at `auto`.

**What changes**
- `/mcp` reads an optional `T3-Mode-Limit: <runtime>/<interaction>` header, from OAuth (`mcp-client`) callers only.
- The header can only narrow the client's ceiling. A broader value changes nothing, and a malformed one gets a 400 (`invalid_mode_limit`).
- `clientModeCeiling` replaces `clientRuntimeModeCeiling`, adding an interaction ceiling. `loadCaller` and the orchestrator MCP service use it, so the access declarations and the in-lock `DispatchModeLimit` check enforce the narrowed modes.
- Provider sessions ignore the header; their limits come from their thread.

**Verification**
- New test in `McpHttpServer.test.ts`. A real `/mcp`, with an `auto` OAuth client, serves a probe tool that starts a thread through `McpToolAccess.startsThreads`. Results:
  - no header → `auto/default`;
  - `approval-required/plan` → narrowed, and escalation requests above it are refused;
  - a broader header → unchanged;
  - malformed → 400.
- Mutation-checked both ways: dropping the narrowing fails the test, and so does letting a broader header widen the ceiling.
- MCP and auth suites: 37 files, 364 tests, all passing.

Opus 5.5 via Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/pingdotgg/t3code/pull/16653" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
