Skip to main content
Glama

HTTP OAuth MCP Server

by NapthaAI
in-memory.ts1.6 kB
import { randomBytes } from "node:crypto"; /** * This file presents a simple in-memory storage implementation for the OAuth proxy. useful if you are locally debugging * or don't want to set up a database or something. don't use this in production */ import type { OAuthClientInformationFull } from "@modelcontextprotocol/sdk/shared/auth.js"; import type { GetAccessTokenFunction, OAuthProxyStorageManager, } from "../types"; // Local storage for the OAuth Proxy const clients: Record<string, OAuthClientInformationFull> = {}; const accessTokens: Record< string, Awaited<ReturnType<GetAccessTokenFunction>> > = {}; export const InMemoryStorage: OAuthProxyStorageManager = { saveClient: async (clientId: string, data: OAuthClientInformationFull) => { clients[clientId] = data; }, getClient: async (clientId: string) => { return clients[clientId]; }, saveAccessToken: async ( { accessToken, idToken, clientId, scope }, expiresInSeconds: number, ) => { const locallyIssuedAccessToken = randomBytes(64).toString("hex"); // save the read access token and other information under the "proxied" access token accessTokens[locallyIssuedAccessToken] = { scopes: scope?.split(" ") ?? [], clientId, idToken: idToken ?? "", accessToken: accessToken, expiresInSeconds, }; setTimeout(() => { delete accessTokens[locallyIssuedAccessToken]; }, expiresInSeconds * 1000); return locallyIssuedAccessToken; }, getAccessToken: async (locallyIssuedAccessToken: string) => { return accessTokens[locallyIssuedAccessToken]; }, }; export default InMemoryStorage;

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/NapthaAI/http-oauth-mcp-server'

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