Skip to main content
Glama

Convex MCP server

Official
by get-convex
atomicMutators.ts1.82 kB
import { FunctionReference, createFunctionHandle, internalMutationGeneric, } from "convex/server"; import { v } from "convex/values"; export function atomicMutators(table: string) { return { atomicInsert: internalMutationGeneric({ args: { value: v.any() }, handler: async (ctx, { value }) => { const id = await ctx.db.insert(table, value); const newDoc = await ctx.db.get(id); return { newDoc }; }, }), atomicPatch: internalMutationGeneric({ args: { id: v.id(table), value: v.any() }, handler: async (ctx, { id, value }) => { const oldDoc = await ctx.db.get(id); await ctx.db.patch(id, value); const newDoc = await ctx.db.get(id); return { oldDoc, newDoc }; }, }), atomicReplace: internalMutationGeneric({ args: { id: v.id(table), value: v.any() }, handler: async (ctx, { id, value }) => { const oldDoc = await ctx.db.get(id); await ctx.db.replace(id, value); const newDoc = await ctx.db.get(id); return { oldDoc, newDoc }; }, }), atomicDelete: internalMutationGeneric({ args: { id: v.id(table) }, handler: async (ctx, { id }) => { const oldDoc = await ctx.db.get(id); await ctx.db.delete(id); return { oldDoc }; }, }), }; } export type AtomicMutators = { [k in keyof ReturnType<typeof atomicMutators>]: FunctionReference< "mutation", "internal" >; }; export async function watchTable(table: string, api: AtomicMutators) { return { table, insert: await createFunctionHandle(api.atomicInsert), patch: await createFunctionHandle(api.atomicPatch), replace: await createFunctionHandle(api.atomicReplace), delete: await createFunctionHandle(api.atomicDelete), }; }

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