Skip to main content
Glama

Karakeep MCP server

by karakeep-app
auth.ts1.5 kB
import { createMiddleware } from "hono/factory"; import { HTTPException } from "hono/http-exception"; import { AuthedContext, Context, createCallerFactory } from "@karakeep/trpc"; import { appRouter } from "@karakeep/trpc/routers/_app"; const createCaller = createCallerFactory(appRouter); export const unauthedMiddleware = createMiddleware<{ Variables: { ctx: Context; api: ReturnType<typeof createCaller>; }; }>(async (c, next) => { if (!c.var.ctx) { throw new HTTPException(401, { message: "Unauthorized", }); } c.set("api", createCaller(c.get("ctx"))); await next(); }); export const authMiddleware = createMiddleware<{ Variables: { ctx: AuthedContext; api: ReturnType<typeof createCaller>; }; }>(async (c, next) => { if (!c.var.ctx || !c.var.ctx.user || c.var.ctx.user === null) { throw new HTTPException(401, { message: "Unauthorized", }); } c.set("api", createCaller(c.get("ctx"))); await next(); }); export const adminAuthMiddleware = createMiddleware<{ Variables: { ctx: AuthedContext; api: ReturnType<typeof createCaller>; }; }>(async (c, next) => { if (!c.var.ctx || !c.var.ctx.user || c.var.ctx.user === null) { throw new HTTPException(401, { message: "Unauthorized", }); } if (c.var.ctx.user.role !== "admin") { throw new HTTPException(403, { message: "Forbidden - Admin access required", }); } c.set("api", createCaller(c.get("ctx"))); await next(); });

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/karakeep-app/karakeep'

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