import { AsyncLocalStorage } from 'node:async_hooks';
interface RequestContext {
apiKey?: string;
sessionId?: string;
}
// Create AsyncLocalStorage instance to track request context
export const requestContextStorage = new AsyncLocalStorage<RequestContext>();
/**
* Get the current request's API key
*/
export function getCurrentApiKey(): string | undefined {
const context = requestContextStorage.getStore();
return context?.apiKey || process.env.GOOGLE_MAPS_API_KEY;
}
/**
* Run a function with a specific request context
*/
export function runWithContext<T>(context: RequestContext, fn: () => T | Promise<T>): T | Promise<T> {
return requestContextStorage.run(context, fn);
}
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/cablate/mcp-google-map'
If you have feedback or need assistance with the MCP directory API, please join our Discord server