Skip to main content
Glama
mcpauth.ts907 B
import { McpAuth } from "@mcpauth/auth/adapters/hono"; import { NextRequest } from "next/server"; import { auth, auth as nextAuth } from "./auth"; import type { OAuthUser } from "@mcpauth/auth"; import { PostgresAdapter } from "@mcpauth/auth/stores/postgres"; import { Context } from "hono"; export const mcpauth = (env: CloudflareBindings) => { return McpAuth({ adapter: PostgresAdapter(env.DB), issuerUrl: process.env.BASE_URL || "http://localhost:8787", issuerPath: "/api/oauth", authenticateUser: async (c: Context) => { const session = await auth(env).api.getSession({ // @ts-ignore TODO headers: new Headers(c.headers), }); return (session?.user as OAuthUser) ?? null; }, signInUrl: (request: NextRequest, callbackUrl: string) => { return process.env.BASE_URL! + "?callbackUrl=" + encodeURIComponent(callbackUrl); }, }); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcpauth/mcpauth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server