Production MCP Client Pitfalls Across Claude Mobile, Desktop Chat, Code, Cowork & OpenWebUI
Why MCP servers that pass local Inspector tests fail in enterprise production: Claude Mobile OAuth brokers, Supabase global signOut kills, silent structuredContent drops, and the OpenWebUI 5-tool cliff.
- 01Static
Authorization: Bearerheaders configured via local CLI/mcp-remotepipes fail completely on Claude Mobile and cloud connectors, requiring anIdP (Entra/Okta) ↔ MCP OAuth 2.1 Brokerwith deterministic session binding. - 02Calling
supabase.auth.signOut()in a companion web app defaults toscope: 'global', silently killing users’ active Claude Desktop and Claude Code MCP sessions (signOut({ scope: 'local' })is mandatory). - 03Returning tool data solely inside
result.structuredContentworks in Claude Code yet vanishes silently in Claude Desktop Chat unless mirrored intoresult.contenttext blocks. - 04OpenWebUI degrades sharply past
5–6tools without a two-stage domain router;TOP 1000guards trigger 11-page context explosions on11,000-row queries; and80K-char base64 uploads require 5-minute TTL presigned URLs with origin-pinned reads.
1. Cross-Client MCP Compatibility Matrix: One Spec, Five Divergent Runtimes
On paper, the Model Context Protocol (MCP) defines a unified JSON-RPC and Streamable HTTP contract. In enterprise production, however, no organization runs a single MCP host: executives check KPIs on Claude Mobile, operations analysts live in Claude Desktop Chat and Claude Cowork, engineers automate workflows in Claude Code, and air-gapped business units deploy OpenWebUI or LM Studio.
An MCP server validated solely against MCP Inspector or Claude Code on a developer laptop breaks silently across six operational dimensions the moment real multi-client traffic hits.
| Capability / Surface | Claude Desktop Chat | Claude Code | Claude Cowork | Claude Mobile | OpenWebUI / LM Studio | Defensive Server Pattern |
|---|---|---|---|---|---|---|
Custom Static Bearer Headers | Only via local mcp-remote stdio bridge | Full support (--header & local config) | Unsupported on cloud connectors | Unsupported; zero local process pipe | Supported via server/user connector config | RFC 9728 + OAuth 2.1 Broker + CLI PAT fallback |
| OAuth 2.1 Broker / DCR / CIMD | Required for remote HTTPS connectors | Supported with PKCE + localhost callback | Required for cloud-synced workspaces | Mandatory; inherits synced OAuth connector | Partial / version-dependent; prefers Bearer | IdP (Entra/Okta) ↔ MCP OAuth Broker + token-bound session |
structuredContent Rendering | Silently dropped if content text omitted | Reads structuredContent JSON natively | Inconsistent unless mirrored in content | Depends on content text blocks | Forwards content[].text only to LLM | Dual-emit both structuredContent and content text |
notifications/tools/list_changed | Frequently cached until host restart | Subscribes live and refreshes catalog | Delayed refresh across cloud worker turns | Dropped across stateless HTTP requests | Ignored in most builds; static tool cache | Emit post-auth notification + enforce hard RBAC per tools/call |
| Direct Upload vs Presigned URLs | Sandbox blocks remote file://; base64 bloats chat | Local FS access; remote MCP still needs HTTP | Cloud sandbox path invisible to remote MCP | No raw binary MCP argument transport | Base64 arguments overflow context window | 5-min TTL Presigned PUT URL + origin-pinned read |
Tool-Selector Scaling (5 vs 50+) | Stable to ~25–40 tools before latency climbs | Scales to 50+ tools via deferred tool search | Moderate (30+ tools benefit from grouping) | Tight context budget; concise catalog needed | Sharp accuracy cliff past 5–6 tools | Two-stage ontology domain router (<= 5 top-level tools) |
Validating an enterprise MCP server exclusively in Claude Code masks silent structuredContent drops in Claude Desktop Chat, OAuth broker requirements on Claude Mobile, and the 5-tool selector cliff in OpenWebUI.
2. Auth & Session Divergences: Claude Mobile OAuth Broker, Supabase Global signOut & Restart Leaks
During prototyping, engineers routinely wire remote servers via npx mcp-remote https://mcp.corp.example/mcp --header "Authorization: Bearer <TOKEN>" inside claude_desktop_config.json or claude mcp add. That static header pipe works on laptops—and fails 100% of the time on Claude Mobile and cloud connectors, where no local stdio wrapper exists and RFC 9728 Protected Resource Metadata + OAuth 2.1 Authorization Code + PKCE (DCR / CIMD) is strictly mandatory.
Because enterprise Microsoft Entra ID and Okta tenants rarely allow arbitrary public Dynamic Client Registration out of the box, production deployments require an IdP (Entra/Okta) ↔ MCP OAuth 2.1 Broker that authenticates corporate SSO upstream and issues standards-compliant MCP OAuth tokens downstream. Once live, teams immediately hit three subtle session lifecycle bugs:
- OAuth State /
Mcp-Session-IdMismatches Triggering Per-Message Re-Init Storms: If multi-replica load balancers fail to persist or deterministically bindMcp-Session-Idto the OAuth principal across pods (returning mismatched state or404on follow-up turns), clients fall into a pathological recovery loop where every single chat message triggers a brand-newinitialize+tools/listhandshake, tripling turn latency. - The
supabase.auth.signOut()Global Scope Kill-Switch: When a companion web dashboard shares Supabase Auth with your MCP OAuth broker and callsawait supabase.auth.signOut(), the Supabase JS SDK defaults toscope: 'global'—revoking every refresh token for that user across all devices and silently killing their activeClaude DesktopandClaude CodeMCP sessions! Always callsupabase.auth.signOut({ scope: 'local' })on web logout. - Dangling Desktop Restart Sessions & Post-Auth RBAC
notifications/tools/list_changed:Claude Desktopsleeps and restarts frequently abandon Streamable HTTP/SSE sessions without sendingHTTP DELETE, requiring server-side idle TTL reapers. Furthermore, whenever post-auth RBAC narrows or expands a user’s permitted tools, emitnotifications/tools/list_changedfor live clients (Claude Code) while still enforcing strict per-call RBAC for clients that cachetools/list.
import { createHash } from 'node:crypto';
import type { SupabaseClient } from '@supabase/supabase-js';
// 1. Companion Web Logout: MUST pass scope: 'local' so active Claude Desktop & Code MCP sessions survive!
export async function safeCompanionWebLogout(supabase: SupabaseClient) {
const { error } = await supabase.auth.signOut({ scope: 'local' });
if (error) throw error;
}
// 2. Prevent Per-Message Re-Initialization Storms Across Multi-Replica MCP Pods
export function resolveDeterministicMcpSession(
incomingSessionId: string | undefined,
verifiedJwtSub: string,
oauthClientId: string,
): string {
const bindingPrefix = createHash('sha256')
.update(`${verifiedJwtSub}:${oauthClientId}`)
.digest('hex')
.slice(0, 24);
// Preserve valid principal-bound session ID across replicas instead of forcing 404 re-init on every turn
return incomingSessionId?.startsWith(`mcp_${bindingPrefix}_`)
? incomingSessionId
: `mcp_${bindingPrefix}_v1`;
}
// 3. Notify Live Clients After Post-Auth RBAC Filtering (While Keeping Hard Enforcement on tools/call)
export async function notifyPostAuthRbacUpdate(
mcpServer: { sendToolListChanged: () => Promise<void> },
previousRole: string | null,
resolvedRole: string,
) {
if (previousRole !== resolvedRole) {
await mcpServer.sendToolListChanged();
}
}3. Payload & Catalog Divergences: Silent structuredContent Drop, OpenWebUI 5-Tool Cliff & --read-only Leaks
Modern MCP specifications allow tools to return typed objects inside result.structuredContent alongside outputSchema. Engineers who populate result.structuredContent = { metrics, rows } while leaving result.content empty (or returning a terse "Success" label) encounter a baffling production failure: Claude Code ingests structuredContent cleanly, whereas Claude Desktop Chat silently drops it!
No error banner appears in Claude Desktop Chat—the model simply sees an empty tool response, either hallucinating that zero database records exist or entering a retry loop. Defensive MCP servers must always mirror structured payloads into result.content text blocks.
Meanwhile, self-hosted OpenWebUI and LM Studio deployments expose two catalog pitfalls: attaching more than 5–6 MCP tools causes tool-selection accuracy on mid-sized models to fall off a cliff due to schema prompt crowding. Worse, wrapping a child SQL MCP server with --read-only blocks mutations at execution time yet still leaks the child server’s hardcoded "Executes raw SQL" description in tools/list, causing safety-tuned models either to refuse benign read queries or waste turns attempting writes.
- Mandatory Dual-Channel Serialization (
structuredContent+content): Emit typed JSON instructuredContentforClaude Codeand programmatic UI consumers while serializing deterministic summary + JSON/Markdown blocks insideresult.content: [{ type: "text", text }]forClaude Desktop Chat,Claude Mobile, andOpenWebUI. - Two-Stage Ontology Domain Router for
OpenWebUI: Collapse 50 granular table tools behind4top-level tools (discover_domains,inspect_ontology_entity,run_governed_query,stage_action) so tool-selector accuracy stays above95%. - Sanitizing
--read-onlyChild Wrapper Metadata: When proxying an upstream SQL MCP server in--read-onlymode, explicitly overridetool.descriptionand stampannotations: { readOnlyHint: true, destructiveHint: false }before returningtools/list.
interface CrossClientToolResult<T extends Record<string, unknown>> {
content: Array<{ type: 'text'; text: string }>;
structuredContent: T;
isError?: boolean;
}
// Prevents silent data loss in Claude Desktop Chat & OpenWebUI while preserving typed data for Claude Code
export function serializeCrossClientToolResult<T extends Record<string, unknown>>(
summaryHeader: string,
payload: T,
): CrossClientToolResult<T> {
const canonicalJson = JSON.stringify(payload, null, 2);
return {
structuredContent: payload,
content: [
{
type: 'text',
text: `${summaryHeader}\n\n\`\`\`json\n${canonicalJson}\n\`\`\``,
},
],
};
}
// Overrides misleading "executes raw SQL" descriptions leaked by --read-only child MCP servers
export function sanitizeReadOnlyChildTools<
T extends { name: string; description?: string; annotations?: Record<string, unknown> },
>(childTools: T[]): T[] {
return childTools
.filter((t) => !/^(insert|update|delete|drop|alter)_/i.test(t.name))
.map((tool) => ({
...tool,
description:
'Executes governed READ-ONLY analytical queries. All write/DDL statements (INSERT, UPDATE, DELETE, DROP) are strictly disabled.',
annotations: {
...tool.annotations,
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
},
}));
}4. 11,000-Row TOP 1000 Pagination Loops & 80,000-Char Base64 Upload Bloat (Presigned URLs + Origin Reads)
Adding SELECT TOP 1000 (or LIMIT 1000) plus a next_cursor token looks like responsible MCP engineering—until an executive asks an ambiguous prompt ("How did steel coil shipments perform this quarter?") over an 11,000-row ledger. Conscientious agents in Claude Code and Claude Cowork refuse to summarize partial slices, autonomously looping across all 11 pages (11 x 1,000 rows) until 200K+ tokens blow up the context window!
A parallel context disaster strikes binary file ingestion. Because Claude Chat sandboxes block remote MCP servers from reading local attachment paths, naive workflows instruct the model to base64-encode PDFs, spreadsheets, or CAD drawings into tool arguments—injecting 80,000+ characters of base64 tokens into chat history, burning token quotas, and truncating bytes mid-stream.
Production MCP servers eliminate both failure modes via Aggregate-First Ontology Guards for high-cardinality queries and 5-Minute TTL Presigned Upload URLs paired with Origin-Pinned Reads to defeat 60-second CDN stale-read races.
- Aggregate-First Ontology Cardinality Guard: When matched row count exceeds
max_detail_rows(e.g.,200) on a broad prompt, suppressnext_cursorpaging completely—return server-computed ontology dimensional rollups (SUM,COUNT,GROUP BY) alongside narrow filter hints. - 5-Minute TTL Presigned Upload URLs: Expose a lightweight
request_upload_urltool returning a short-lived (300sTTL) S3/R2/MinIOPUTlink so the user uploads binary files out-of-band with zero base64 tokens entering LLM context. - Origin-Pinned Reads Beating
60sCDN Stale-Read Races: If a user uploads a file and immediately messages "Done, parse it," reading via a CDN-fronted URL frequently serves a cached404or stale negative-cache hit for up to60seconds. Always read uploaded objects directly from the storage origin (Cache-Control: no-store/ direct S3 API) using versioned keys.
// 1. Aggregate-First Guard: Stops 11-Page x TOP 1000 Agent Loops Before Context Explodes
export async function executeCardinalityGuardedQuery(
totalMatchingRows: number,
fetchRollupSummary: () => Promise<Record<string, unknown>>,
fetchDetailRows: (limit: number) => Promise<Record<string, unknown>[]>,
) {
const MAX_DETAIL_ROWS = 200;
if (totalMatchingRows > MAX_DETAIL_ROWS) {
const rollup = await fetchRollupSummary();
return serializeCrossClientToolResult(
`Query matched ${totalMatchingRows} rows (> ${MAX_DETAIL_ROWS} detail cap). Raw cursor paging disabled to protect context; returning verified ontology dimensional rollup. Supply narrower date/plant/status filters for line-item rows.`,
{ mode: 'AGGREGATED_ROLLUP', totalMatchingRows, rollup, nextCursor: null },
);
}
const rows = await fetchDetailRows(MAX_DETAIL_ROWS);
return serializeCrossClientToolResult(`Returned ${rows.length} detail rows.`, {
mode: 'DETAIL_ROWS',
totalMatchingRows,
rows,
});
}
// 2. Origin-Pinned Storage Read: Beats 60-Second Edge CDN Negative/Stale Cache Races After Presigned Upload
export async function readUploadedArtifactFromOrigin(
s3OriginClient: { send: (cmd: unknown) => Promise<{ Body?: { transformToByteArray(): Promise<Uint8Array> } }> },
buildGetObjectCommand: (input: { Bucket: string; Key: string; ResponseCacheControl: string }) => unknown,
bucket: string,
objectKey: string,
): Promise<Uint8Array> {
// NEVER fetch() via public CDN hostname right after a 5-min TTL presigned PUT (60s stale 404 race).
// Read directly against origin bucket endpoint with no-store headers:
const response = await s3OriginClient.send(
buildGetObjectCommand({
Bucket: bucket,
Key: objectKey,
ResponseCacheControl: 'no-store, no-cache, max-age=0',
}),
);
if (!response.Body) {
throw new Error('Upload object not yet committed at origin; confirm presigned PUT completed.');
}
return response.Body.transformToByteArray();
}Never use the LLM context window as an ETL cursor buffer or binary file transport. Aggregate >200-row analytical sets inside SQL via ontology rollups, and route binary payloads out-of-band via 5-minute presigned URLs backed by origin-pinned reads.
Frequently Asked Technical Questions
Why does an MCP server configured with static Bearer headers work on Claude Desktop CLI pipes yet fail on Claude Mobile?
Local claude_desktop_config.json bridges like mcp-remote spawn a local Node.js subprocess on your laptop to inject static Authorization: Bearer headers. Claude Mobile and cloud connectors execute remotely with zero access to your laptop’s local config or stdio pipes—they strictly require an HTTPS MCP endpoint implementing RFC 9728 Protected Resource Metadata and OAuth 2.1 + PKCE.
Why does signing out of our companion web portal abruptly disconnect users from Claude Desktop and Claude Code?
In @supabase/supabase-js, calling supabase.auth.signOut() with no arguments defaults to scope: 'global', which revokes every active refresh token for that user across all devices and OAuth clients. Switching your web portal’s sign-out handler to supabase.auth.signOut({ scope: 'local' }) terminates only the browser session while keeping Desktop and CLI MCP tokens alive.
Why does Claude Desktop Chat act as if my tool returned empty output when Claude Code reads structuredContent fine?
Host handling of CallToolResult.structuredContent varies sharply: Claude Code feeds structuredContent into model context, whereas Claude Desktop Chat and OpenWebUI rely on result.content text blocks ({ type: 'text', text: '...' }). Always dual-emit both structuredContent and a serialized text block inside result.content.
How do we expose 40+ enterprise workflows to OpenWebUI without hitting the 5–6 tool-selector accuracy cliff?
OpenWebUI injects every attached tool’s JSON Schema into the prompt on each turn, crowding model attention past 5–6 tools. Replace flat tool catalogs with a two-stage ontology router exposing only 3–4 top-level tools (discover_ontology_domains, inspect_domain_schema, execute_governed_query, stage_action) that load domain parameters dynamically.
Glossary Concepts Referenced in This Guide
Agent = Model + Harness) responsible for tool-calling loops, context compaction, retries, sandboxing, and execution traces.Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.
[Production MCP Client Pitfalls Across Claude Mobile, Desktop Chat, Code, Cowork & OpenWebUI — Ontoloji.org](https://ontoloji.org/en/guides/claude-mobile-desktop-code-and-openwebui-mcp-client-bugs)