Repository navigation
[Global Ask] Make authenticated MCP browser-safe and admission-bounded #269
Description
Buyer problem
Canonical MCP Global Ask is now PR #270. A browser client must preflight its authenticated Streamable HTTP request, and the ingress must bound actual request bytes before OAuth or SDK JSON parsing. Separately, a rate-limited authenticated principal needs protocol-compatible retry guidance without leaking another principal's counters.
Delivery slices
Slice A — browser and request-byte admission: PR #286
Required behavior:
- validate Host and every present Origin before OAuth;
- handle an exact allowed-Origin
OPTIONSpreflight without bearer authentication, database access, quota consumption, or tool invocation; - never accept or reflect
*,null, prefix, suffix, credential-bearing, path-bearing, query-bearing, or fragment-bearing configured Origins; - emit
Vary: Originon Origin-sensitive responses; - expose the MCP protocol/session headers and
WWW-Authenticateso an allowed browser client can read OAuth resource discovery; - retain no-Origin support for Codex and other non-browser clients;
- enforce
MCP_MAX_REQUEST_BYTESbefore OAuth and SDK JSON parsing; - reject invalid, negative, non-ASCII, duplicate, conflicting, or mismatched content length/framing;
- count streamed bodies independently of
Content-Lengthand reject over-limit data immediately; - replay an admitted body byte-for-byte once;
- return stable no-store 400/413 errors without echoing request content.
PR #286 is Draft and depends on #270. It is not accepted until reconstructed/restacked on the current #270 exact head and all exact-head gates pass.
Slice B — distributed per-principal rate limiting: not yet complete
Required behavior:
- consume quota only after a bearer token has resolved to a provisioned LineageWeave principal;
- use a distributed Valkey-backed window shared across MCP process instances;
- key counters by opaque principal/account identity and never expose another principal's counters;
- return an MCP/HTTP-compatible rate-limit failure with a bounded
Retry-Afterderived from the actual window; - successful requests and preflight/Host/Origin/body-admission failures do not carry
Retry-After; - fail closed or explicitly unavailable according to an ADR if the distributed limiter is unavailable; do not silently fall back to a process-local counter;
- preserve feat: expose authenticated MCP Global Ask #270's RBAC, ABAC, citation, source, orchestrator, and explicit external-verification boundaries.
RED→GREEN acceptance tests
- Allowed exact-Origin preflight succeeds with the exact response headers and no bearer challenge.
- Unsafe configured Origins prevent startup; unsafe request Origins fail before authentication and are not reflected.
- Allowed-Origin 401 exposes
WWW-Authenticateto browser JavaScript. - No-Origin non-browser POST still reaches the normal OAuth challenge.
- Oversized declared and streamed bodies fail before downstream parsing/tool invocation.
- Invalid/ambiguous framing and declared/actual mismatches fail with stable codes.
- An under-limit body preserves the canonical Global Ask question contract.
- A principal exceeding its distributed allowance receives bounded retry metadata; successful and pre-auth failures do not.
- Existing authorization, citations, semantic retrieval, and external-verification contracts remain unchanged.
Scope boundary
Do not mix this issue with semantic/KG retrieval and public corroboration (#276), evidence-honest knowledge-cutoff work (#271), conversation persistence, unrelated REST CORS, or provider-specific model logic.
Buyer completion signal
A browser MCP client can discover OAuth, complete preflight, submit a bounded authenticated Global Ask, and recover predictably from a principal-specific distributed rate limit without weakening exact-origin, request-framing, RBAC/ABAC, citation, or evidence boundaries.
Activity
seonghobae commentedon Aug 20, 2026
Slice A is PR #286 exact current head 65a461d with green backend/frontend checks; formal exact-head approval and protected merge remain outstanding. Keep the issue open after Slice A because the distributed per-principal rate-limit slice is intentionally still incomplete.
seonghobae commentedon Aug 23, 2026
Slice B is now implemented on the active #258 stack at exact head
52deb37294aa647e4be4b4b1c6448b52ba861e49under ADR 0146. The current path resolves a provisioneduser_account, consumes an atomic Valkey quota keyed by a SHA-256 account digest, returns bounded application-code retry metadata plus browser-readableRetry-After, and fails closed when the shared limiter is unavailable. Exact-head local MCP quota/config/server/CORS/request-admission/auth validation passed: 74 tests. This is non-main stack evidence only: #258 remains blocked by CHANGES_REQUESTED, Strix infrastructure failure, and protected approval requirements, so the issue stays open until protected-main integration.[-][Buyer Gap] Make authenticated Global Ask MCP browser-safe and admission-bounded[/-][+][Global Ask] Make authenticated MCP browser-safe and admission-bounded[/+]