Skip to main content
Glama

Convex MCP server

Official
by get-convex
internal.ts1.64 kB
import { internal } from "./_generated/api"; import { Id } from "./_generated/dataModel"; import { mutation, internalMutation, query } from "./_generated/server"; function formatMessage(body: string, secondsLeft: number) { return `${body} (This message will self-destruct in ${secondsLeft} seconds)`; } export const getMessage = query( async ({ db }, { messageId }: { messageId: Id<"messages"> }) => { return await db.get(messageId); }, ); export const sendMessage = mutation( async ({ db }, { body, channel }: { body: string; channel: string }) => { const id = await db.insert("messages", { text: body, channel: channel, }); return id; }, ); export const sendExpiringMessage = mutation( async ( { db, scheduler }, { body, channel }: { body: string; channel: string }, ) => { const id = await db.insert("messages", { text: formatMessage(body, 1), channel: channel, }); await scheduler.runAfter(1000, internal.internal.update, { messageId: id, body, secondsLeft: 0, }); return id; }, ); export const update = internalMutation( async ( { db, scheduler }, { messageId, body, secondsLeft, }: { messageId: Id<"messages">; body: string; secondsLeft: number; }, ) => { if (secondsLeft > 0) { await db.patch(messageId, { text: formatMessage(body, secondsLeft) }); await scheduler.runAfter(1000, internal.internal.update, { messageId, body, secondsLeft: secondsLeft - 1, }); } else { await db.delete(messageId); } }, );

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