Architecture
anymrkt is a Next.js 15 application with the App Router, backed by Supabase Postgres. Authentication is handled by NextAuth v5 (Google OAuth + credentials). The MCP server is a first-class HTTP endpoint at /mcp that exposes 90+ tools across six products.
Request flow
- Incoming HTTP request hits proxy.ts (not middleware.ts — renamed in Next 16).
- proxy.ts checks the public-route allowlist. Paths not on the list redirect to /auth/signin.
- Authenticated routes resolve the session via NextAuth, then query Supabase with next_auth.uid() as the RLS identity.
- MCP endpoint resolves the bearer token, validates DPoP if bound, and builds a per-connection server instance.
Key components
| Component | Path | Description |
|---|---|---|
| Routing gate | proxy.ts | Public allowlist; redirect to signin for protected routes. |
| MCP server | app/mcp/route.ts | SSE/HTTP endpoint; builds per-request server. |
| MCP auth | lib/mcp/auth.ts | Token resolution, DPoP, permission checks. |
| MCP builder | lib/mcp/server.ts | Tool registration; filtering per token. |