← All examples
Know your unknowns · Pre-implementation

The tweakable plan

Add a parallel MCP v2 sidecar to OmniRoute without touching the existing v1 server. The plan below is sorted by how likely you are to change each part — the judgment calls come first, the mechanical plumbing sinks to the bottom.

The prompt
Write an implementation plan for adding a parallel MCP v2 sidecar to OmniRoute, but lead with the decisions I'm most likely to tweak: protocol boundaries, scope enforcement, and the tool surface. Bury the mechanical refactoring at the bottom — I trust you on that part.
What Claude produced

Implementation plan: MCP v2 sidecar

branben/OmniRoute · add opt-in native sidecar with legacy compatibility · branch feat/mcp-v2-sidecar

Effort~4 dev-days
Files touched21 (8 new)
RiskLow–medium
Migrations0
↑ tweak ↓ trust
This plan is sorted by likelihood-of-tweaking, not execution order. Read top to bottom = most worth your attention first. Section A holds every judgment call; Section B is the build order; Section C is mechanical and safe to skip entirely.
A

Decisions you'll probably want to change

High tweak likelihood

Four areas where I made a judgment call you might disagree with. Each flagged choice shows the alternative I considered — toggle to compare.

A1 · Parallel v2 sidecar

OmniRoute MCP surface NEW
clientMCP client
v1 route/api/mcp (stream) · 37 tools
v2 route ①/api/mcp/v2 · 8 tools
① single shared route — v1 and v2 live at the same path prefix
feature flagOMNIROUTE_MCP_V2
defaultoff · requiresRestart
Choice ① Separate path vs. shared prefix
Plan's pick — separate /api/mcp/v2 path
The v2 server lives under its own route. A modern client sends MCP-Protocol-Version: 2026-07-28 and hits /api/mcp/v2; legacy clients continue hitting /api/mcp. The paths never cross.
  • Zero risk of v1 auth or scope logic accidentally serving v2.
  • Independent rollout and monitoring.

Cost: one extra route handler + feature-flag gate.

Alternative — shared /api/mcp path
Version is detected from the MCP-Protocol-Version header and routed inside one handler.
  • Fewer files, one auth surface.
  • Risk: a missing version check routes 2026-07-28 traffic to v1, which rejects it with 400.

Pick this if: you want one route to rule them both. One line to tell me: “single route, branch on header.”

A2 · Scope enforcement

// open-sse/mcp-server/v2/server.ts :144
function withScopeEnforcement(
toolName: string,
handler: (...),1
toolScopes?: string[]
) {
return async (args, extra) => {
const scopeContext = resolveCallerScopeContext(
{ authInfo: extra?.authInfo, sessionId: extra?.sessionId },2
Array.from(MCP_ALLOWED_SCOPES)
);
const scopeCheck = evaluateToolScopes(
toolName, scopeContext.scopes, isMcpScopeEnforcementEnabled(), toolScopes
);
if (!scopeCheck.allowed) {
const msg = buildScopeDenialMessage(toolName, scopeCheck.missing);3
return { content: [{ type: "text", text: msg }], isError: true };
}
return handler(args, extra);
};
}
1Each v2 tool is wrapped at registration time, before any tool logic runs.
2_meta from the client is never consulted — scopes come only from the authenticated request.
3Denial messages strip caller-influenced fields (Caller=, source=) before they reach the client.

A3 · Tool surface

Choice ② Full catalog vs. bounded 8-tool surface
Plan's pick — 8 tools only
The v2 sidecar ships a fixed set of 8 tools: health, combos, metrics, switch, quota, providers, models, and router status. All call omniRouteFetch() against real OmniRoute endpoints.
  • Reviewable surface — a security audit can enumerate every capability in one file.
  • New tools require an explicit spec decision + test.

Cost: v2 is not a drop-in replacement for v1's 37 tools. Clients that need tools outside the 8 stay on v1.

Alternative — full v1 catalog in v2
Port all 37 tools to the v2 wire format.
  • One server for all clients.
  • The diff grows by ~10 files and ~2,000 lines; review surface balloons.

Pick this if: the sidecar is the only MCP surface. One line to tell me: “port all 37.”

A4 · Stateless lifecycle

Step 1
Route guard
guardEnabled() checks settings.mcpEnabled and isMcpV2Enabled(). If either is off, the route returns 503 before any protocol work.
Step 2
Auth
requireManagementAuth(request, { acceptMcpConnectScope: true }). Same management auth as v1.
Step 3
Weakest part
Fresh server+transport
handleMcpV2Http creates a new server per request. No session state survives between calls.
Step 4
Honest discover
server/discover returns only capabilities.tools. No unregistered resources or prompts.

Why step 3 is weak: a fresh server per request means no connection-level caching. For the 8 tools we ship, that is fine — cacheTtlMs on each tool handles the hot paths. If the tool surface grows, revisit.

B

Sequencing

Execution order

The order I'd actually build it in. Every step lands green on CI; nothing user-visible ships until step 5 flips the flag.

  1. 1Scaffold v2 server. Create open-sse/mcp-server/v2/server.ts, wire V2_TOOLS array, register server/discover.0.5d
  2. 2HTTP route + feature flag. Add /api/mcp/v2 route, register OMNIROUTE_MCP_V2 (slot 85), gate on mcpEnabled + flag.0.5d
  3. 3Scope enforcement. Wrap each tool with withScopeEnforcement, route through v1's resolveCallerScopeContext, add buildScopeDenialMessage (D3/D4/D5).0.5d
  4. 4Tool handlers. Implement the 8 omniRouteFetch() handlers against real endpoints. Add outputSchema to each tool def.1.5d
  5. 5Tests. 11 test files, hermetically sealed fixture, empty plugin dir, child transports closed after each test.1d
  6. 6Docs + flag rollout. Changelog entry, feature-flag docs, internal announce. v1 is untouched throughout.0.25d
C

Mechanical work (trust me)

Low tweak likelihood

Refactors and plumbing the feature needs. No judgment calls here — collapsed on purpose.

Boring but necessary 8 tasks · ~0.5d total, folded into the estimates above
  • Port v1's withScopeEnforcement + buildScopeDenialMessage into v2. Same gate, shared implementation — tested in v1 for months.
  • Add OMNIROUTE_MCP_V2 to featureFlagDefinitions.ts (slot 85), DB-overridable, off by default, requiresRestart: true.
  • Create isolated MCP test runner config (vitest.mcp.config.ts) with empty plugin dir and repo-root isolation fixture.
  • Close child transports after each test case to prevent port leaks across the suite.
  • Add resultType and structuredContent to all tool responses so the 2026-07-28 client can skip re-serialization.
  • Add _meta passthrough on tool responses where the upstream spec requires it.
  • Wire cache TTLs (CACHE_TTL.health, CACHE_TTL.combos) onto list tools; health is cacheable, combos are cacheable, mutations are not.
  • Write the changelog entry under changelog.d/features/mcp-v2-2026-07-28.md with the 12 decisions summarized in three bullets.

Tweak these three things

The highest-leverage replies you could send. Copy one, edit, send — I'll revise the plan.

①
“Switch Choice ① to a single /api/mcp route that branches on the MCP-Protocol-Version header.”
②
“Expand the v2 tool surface beyond 8 — port the full v1 catalog.”
③
“Keep scope enforcement in v2 only; drop the v1 shared-gate dependency.”