Skip to content

Commit 647883c

Browse files
authored
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 -->
1 parent 7acbd8d commit 647883c

33 files changed

Lines changed: 1942 additions & 369 deletions

File tree

.github/workflows/db-migration-backwards-compatibility.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ jobs:
169169
wait-for: 30s
170170
log-output-if: true
171171

172+
- name: Start stack-mcp in background
173+
uses: JarvusInnovations/background-action@v1.0.7
174+
with:
175+
run: pnpm run start:mcp --log-order=stream &
176+
wait-on: |
177+
http://localhost:8144/health
178+
tail: true
179+
wait-for: 30s
180+
log-output-if: true
181+
172182
- name: Start stack-dashboard in background
173183
uses: JarvusInnovations/background-action@v1.0.7
174184
with:
@@ -366,6 +376,16 @@ jobs:
366376
wait-for: 30s
367377
log-output-if: true
368378

379+
- name: Start stack-mcp in background
380+
uses: JarvusInnovations/background-action@v1.0.7
381+
with:
382+
run: pnpm run start:mcp --log-order=stream &
383+
wait-on: |
384+
http://localhost:8144/health
385+
tail: true
386+
wait-for: 30s
387+
log-output-if: true
388+
369389
- name: Start stack-dashboard in background
370390
uses: JarvusInnovations/background-action@v1.0.7
371391
with:

.github/workflows/e2e-api-tests-local-emulator.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ jobs:
119119
tail: true
120120
wait-for: 30s
121121
log-output-if: true
122+
- name: Start stack-mcp in background
123+
uses: JarvusInnovations/background-action@v1.0.7
124+
with:
125+
run: pnpm run start:mcp --log-order=stream &
126+
wait-on: |
127+
http://localhost:8144/health
128+
tail: true
129+
wait-for: 30s
130+
log-output-if: true
122131

123132
- name: Start stack-dashboard in background
124133
uses: JarvusInnovations/background-action@v1.0.7

.github/workflows/e2e-api-tests.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ jobs:
125125
tail: true
126126
wait-for: 30s
127127
log-output-if: true
128+
- name: Start stack-mcp in background
129+
uses: JarvusInnovations/background-action@v1.0.7
130+
with:
131+
run: pnpm run start:mcp --log-order=stream &
132+
wait-on: |
133+
http://localhost:8144/health
134+
tail: true
135+
wait-for: 30s
136+
log-output-if: true
128137
- name: Start stack-dashboard in background
129138
uses: JarvusInnovations/background-action@v1.0.7
130139
with:

.github/workflows/e2e-custom-base-port-api-tests.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ jobs:
118118
tail: true
119119
wait-for: 30s
120120
log-output-if: true
121+
- name: Start stack-mcp in background
122+
uses: JarvusInnovations/background-action@v1.0.7
123+
with:
124+
run: pnpm run start:mcp --log-order=stream &
125+
wait-on: |
126+
http://localhost:6744/health
127+
tail: true
128+
wait-for: 30s
129+
log-output-if: true
121130
- name: Start stack-dashboard in background
122131
uses: JarvusInnovations/background-action@v1.0.7
123132
with:

apps/backend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
"@stackframe/stack-shared": "workspace:*",
8888
"@upstash/qstash": "^2.8.2",
8989
"@vercel/functions": "^2.0.0",
90-
"@vercel/mcp-adapter": "^1.0.0",
9190
"@vercel/otel": "^1.10.4",
9291
"@vercel/sandbox": "^1.2.0",
9392
"ai": "^6.0.0",

apps/backend/src/app/api/internal/[transport]/route.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/(overview)/setup-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const buildInstallPrompt = (command: string) => deindent`
3737
3838
${command}
3939
40-
After it finishes, verify that the Stack Auth MCP server is registered in your AI client config — name: \`stack-auth\`, transport: \`http\`, URL: \`https://mcp.stack-auth.com/\`. The command above should handle this automatically; if for any reason it didn't, please add the MCP server manually so you have live access to Stack Auth docs and APIs.
40+
After it finishes, verify that the Stack Auth MCP server is registered in your AI client config — name: \`stack-auth\`, transport: \`http\`, URL: \`https://mcp.stack-auth.com/mcp\`. The command above should handle this automatically; if for any reason it didn't, please add the MCP server manually so you have live access to Stack Auth docs and APIs.
4141
`;
4242

4343
export default function SetupPage(props: { toMetrics: () => void }) {

apps/dev-launchpad/public/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ <h2 style="margin-top: 64px;">Background services</h2>
164164
img: "https://www.svgrepo.com/show/340122/datastore.svg",
165165
importance: 2,
166166
},
167+
{
168+
name: "MCP",
169+
portSuffix: "42",
170+
description: [
171+
"Src: ./apps/mcp",
172+
"Prod: https://mcp.stack-auth.com/mcp",
173+
],
174+
importance: 2,
175+
},
167176
{
168177
name: "Demo app",
169178
portSuffix: "03",

apps/e2e/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
STACK_DASHBOARD_BASE_URL=
22
STACK_BACKEND_BASE_URL=
3+
STACK_MCP_BASE_URL=
34
STACK_INTERNAL_PROJECT_ID=
45
STACK_INTERNAL_PROJECT_CLIENT_KEY=
56
STACK_INTERNAL_PROJECT_SERVER_KEY=

apps/e2e/.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
STACK_DASHBOARD_BASE_URL=http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}01
22
STACK_BACKEND_BASE_URL=http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}02
3+
STACK_MCP_BASE_URL=http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}44
34
STACK_INTERNAL_PROJECT_ID=internal
45
STACK_INTERNAL_PROJECT_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only
56
STACK_INTERNAL_PROJECT_SERVER_KEY=this-secret-server-key-is-for-local-development-only

0 commit comments

Comments
 (0)