2026-05-15 07:04:11 -07:00
|
|
|
import { NextResponse } from "next/server";
|
2026-09-16 16:08:06 -07:00
|
|
|
import { buildResourceMetadata, publicOrigin } from "@/lib/auth/resource-metadata";
|
2026-05-15 07:04:11 -07:00
|
|
|
|
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* RFC 9728 — OAuth 2.0 Protected Resource Metadata.
|
|
|
|
|
*
|
|
|
|
|
* MCP clients discover the authorization server (Authentik) via this
|
|
|
|
|
* endpoint after receiving a 401 with `WWW-Authenticate: resource_metadata=...`.
|
2026-09-16 16:08:06 -07:00
|
|
|
*
|
|
|
|
|
* This is the root form of the document, describing the deployment origin as
|
|
|
|
|
* the protected resource. Clients that derive the metadata URL from the MCP
|
|
|
|
|
* endpoint URL instead of following the header land on the path-suffixed form
|
|
|
|
|
* (§3.1) served by the sibling `[...path]` route.
|
2026-05-15 07:04:11 -07:00
|
|
|
*/
|
|
|
|
|
export function GET() {
|
2026-09-16 16:08:06 -07:00
|
|
|
return NextResponse.json(buildResourceMetadata(publicOrigin()));
|
2026-05-15 07:04:11 -07:00
|
|
|
}
|