stack/docs
Mantra 647883c7ac
Move MCP server into a standalone apps/mcp app (#1405)
## Summary

Splits the Stack Auth MCP server out of `apps/backend` and into a
dedicated Next.js app at `apps/mcp/`, served on port `:42` (suffixed via
`NEXT_PUBLIC_STACK_PORT_PREFIX`) and exposed in production at
`https://mcp.stack-auth.com/mcp`. The backend no longer carries the MCP
transport route; clients now point at the new host.

Base: `dev` → Head: `chore/move-mcp-to-a-sep-app`
Scope: 34 files, +1425 / −353

## What changed

- **New app** `apps/mcp/` — standalone Next.js + `@vercel/mcp-adapter`,
with:
- `src/app/api/internal/[transport]/route.ts` — MCP transport handler
(moved from backend)
- `src/app/mcp/route.ts`, `src/app/route.ts` — public landing + setup
page
  - `src/app/health/route.ts` — health check
  - `src/mcp-handler.ts`, `src/setup-page.ts`, `src/analytics.ts`
- **Backend** drops
`apps/backend/src/app/api/internal/[transport]/route.ts` (−105) — MCP
code is gone from the backend image.
- **Dashboard** install hint updated to point at
`https://mcp.stack-auth.com/mcp` (was `/`).
- **Dev launchpad** gets an MCP tile so the new service shows up
alongside the rest of the local stack.
- **CI** workflows (`db-migration-backwards-compatibility`,
`e2e-api-tests*`) start the MCP service in the background before running
tests.
- **Docs** (`docs-mintlify`, `docs/`) and `init-stack` / `init-prompt`
updated to reference the new URL.
- **E2E** `apps/e2e/tests/backend/endpoints/api/v1/internal/mcp.test.ts`
reworked to hit the new host; `helpers.ts` and env files gain an MCP
base-URL var.

## Visuals

### New `apps/mcp` setup page (`https://mcp.stack-auth.com/`)

The standalone app's root now serves a self-contained MCP setup guide
with per-client instructions (Cursor, VS Code, Codex, Claude Code,
Claude Desktop, Windsurf, ChatGPT, Gemini CLI):

![MCP setup
page](https://gist.githubusercontent.com/mantrakp04/892b45cb1b4e0d65d6c73a0c8771fe7d/raw/mcp-setup-page.png)

### Dev launchpad now lists the MCP service

New tile at port suffix `:42`, importance 2, alongside Backend /
Dashboard / Demo app:

![Dev launchpad with MCP
tile](https://gist.githubusercontent.com/mantrakp04/892b45cb1b4e0d65d6c73a0c8771fe7d/raw/launchpad-light-full.png)

## Notes for reviewers

- The MCP transport endpoint moved path: it was mounted under
`/api/internal/[transport]` in the backend; in the new app it's at the
same path but on the dedicated host. The public-facing URL is
`https://mcp.stack-auth.com/mcp`.
- `apps/mcp` ships its own PostHog analytics client (`src/analytics.ts`)
so the backend doesn't have to proxy events for it anymore.
- Port allocation: `${PORT_PREFIX}42` (default `8142` in dev). Picked to
fit the existing dev-launchpad importance-2 row.
- No DB migrations.

## Test plan

- [x] `apps/mcp` builds and `pnpm dev` serves on `:8142`
- [x] Dev launchpad renders the new MCP tile (screenshot above)
- [x] MCP setup page renders client tabs (screenshot above)
- [x] E2E `mcp.test.ts` updated to hit the new host
- [ ] CI green on `e2e-api-tests*` and
`db-migration-backwards-compatibility` workflows (they were touched to
start the MCP service)
- [ ] `init-stack` / `mcp.ts` install flow lands users on the new URL


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Standalone MCP app added with a public /mcp endpoint and health check.
  * MCP appears in the dev-launchpad apps list.

* **Documentation**
* MCP endpoint updated to https://mcp.stack-auth.com/mcp in all setup
guides and installer snippets.
* Setup page enhanced with detailed client install tabs and
instructions.

* **Chores**
  * MCP service integrated into CI/e2e workflows and local env configs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-07 15:22:44 -07:00
..
code-examples prompt fix 2026-03-13 13:20:25 -07:00
content/docs Move MCP server into a standalone apps/mcp app (#1405) 2026-05-07 15:22:44 -07:00
lib [Docs] - Full cleanup (#1105) 2026-01-27 00:38:51 -06:00
public [Docs][Content] - MCP installation instructions (#915) 2025-10-10 13:31:48 -05:00
scripts Fix Docker build 2025-12-28 19:38:17 +01:00
src Update GitHub URL 2026-05-06 15:17:01 -07:00
templates-api [Docs] Fix dead links on api overview page (#1115) 2026-01-16 15:23:58 -06:00
.env mcp / tools update + internal tool (#1283) 2026-04-12 23:32:22 +00:00
.env.development [Docs] Update docs to openrouter usage for ai chat (#1112) 2026-02-11 10:16:43 -06:00
.eslintrc.json Upgrade ESLint 2026-02-27 10:58:28 -08:00
.gitignore [Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869) 2025-10-30 20:01:30 -05:00
cli.json New docs (#698) 2025-06-20 13:30:01 -07:00
instrumentation-client.ts Upgrade PostHog 2026-01-30 23:38:06 -08:00
next.config.mjs [Docs] - Full cleanup (#1105) 2026-01-27 00:38:51 -06:00
package.json Update GitHub URL 2026-05-06 15:17:01 -07:00
postcss.config.mjs New docs (#698) 2025-06-20 13:30:01 -07:00
README.md [Docs] - Full cleanup (#1105) 2026-01-27 00:38:51 -06:00
source.config.ts [Docs] - Full cleanup (#1105) 2026-01-27 00:38:51 -06:00
tsconfig.json New docs (#698) 2025-06-20 13:30:01 -07:00

Stack Auth Documentation

This is the documentation site for Stack Auth, built with Next.js and Fumadocs.

Development

pnpm dev

The docs server runs on port 8104 by default (or ${NEXT_PUBLIC_STACK_PORT_PREFIX}04).

Project Structure

Content (/content)

Directory Description
content/docs/ Main documentation (guides, SDK reference, components)
content/api/ REST API reference documentation

App Routes (/src/app)

Route Description
/docs Main documentation pages
/api API reference pages (rendered from OpenAPI specs)
/docs-embed Embedded docs for dashboard companion widget
/api-embed Embedded API docs for dashboard companion widget
/mcp-browser MCP documentation browser
/handler/[...stack] Stack Auth handler route
/api/search Search API endpoint
/api/chat AI documentation chat endpoint
/llms.txt LLM-friendly documentation (plain text)
/llms.mdx LLM-friendly documentation (MDX format)

SDK Route Handlers

These routes serve SDK-specific documentation:

  • /js/[...path] - JavaScript SDK
  • /next/[...path] - Next.js SDK
  • /react/[...path] - React SDK
  • /python/[...path] - Python SDK
  • /rest-api/[...path] - REST API

Key Files

File Description
lib/source.ts Content source adapter using Fumadocs loader()
source.config.ts Fumadocs MDX configuration (frontmatter schema, etc.)
app/layout.config.tsx Shared layout options
lib/platform-config.ts Platform/framework configuration for code examples

Components (/src/components)

Directory Description
api/ API playground components
chat/ AI chat interface
layout/ Layout UI components (search, navigation)
layouts/ Page layouts (docs, API)
mdx/ Custom MDX components
stack-auth/ Stack Auth demo components
ui/ Base UI components (button, etc.)

OpenAPI Specs (/openapi)

Contains OpenAPI JSON specifications organized by access level:

  • client-*.json - Client-side API endpoints
  • server-*.json - Server-side API endpoints
  • admin-*.json - Admin API endpoints
  • webhooks-*.json - Webhook event schemas

Scripts

# Generate API docs from OpenAPI specs
pnpm generate-openapi-docs

# Clear generated docs
pnpm clear-docs

Learn More