Skip to main content
Glama

Convex MCP server

Official
by get-convex
mutex.ts959 B
export class Mutex { currentlyRunning: Promise<void> | null = null; waiting: Array<() => Promise<void>> = []; async runExclusive<T>(fn: () => Promise<T>): Promise<T> { const outerPromise = new Promise<T>((resolve, reject) => { const wrappedCallback: () => Promise<void> = () => { return fn() .then((v: T) => resolve(v)) .catch((e: any) => reject(e)); }; this.enqueueCallbackForMutex(wrappedCallback); }); return outerPromise; } private enqueueCallbackForMutex(callback: () => Promise<void>) { if (this.currentlyRunning === null) { this.currentlyRunning = callback().finally(() => { const nextCb = this.waiting.shift(); if (nextCb === undefined) { this.currentlyRunning = null; } else { this.enqueueCallbackForMutex(nextCb); } }); this.waiting.length = 0; } else { this.waiting.push(callback); } } }

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/get-convex/convex-backend'

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