Case study 01
Twin MCP servers, one schema
Local desktop CC needs sub-millisecond access to the chat tools, but external clients on other machines still need to attach over the internet with proper auth.
Split the surface in two: a Streamable HTTP MCP at /api/mcp on Vercel (OAuth + RFC 8707 audience-bound bearers) and a stateless local MCP at 127.0.0.1:9000 inside the Electron host.
Every chat-write tool is implemented twice — the handler code is duplicated, but the schema and Supabase project are shared so RLS is the single source of truth.
A non-negotiable line in the repo guide reminds future-me to fix bugs in both copies. The CI lint enforces export const runtime = "nodejs" on every API route so node:crypto + jose imports do not crash the edge bundle.
// app/api/mcp/route.ts
export const runtime = 'nodejs'
const server = createMcpServer({
tools: [chat_send, chat_respond,
chat_respond_begin, chat_respond_chunk, chat_respond_finish],
authenticate: bearerDispatch, // pm_* | oat_* | raw JWT
})
export const POST = streamableHttp(server, { enableJsonResponse: true })