Skip to main content
Glama

Convex MCP server

Official
by get-convex
patchDocumentsFields.ts1.33 kB
import { Value, v, GenericId, ConvexError } from "convex/values"; import { mutationGeneric } from "../server"; import { UNDEFINED_PLACEHOLDER } from "./lib/values"; export default mutationGeneric({ args: { table: v.string(), fields: v.any(), ids: v.optional(v.array(v.string())), componentId: v.optional(v.union(v.string(), v.null())), }, handler: async ( ctx, args, ): Promise<{ success: false; error: string } | { success: true }> => { const fields = args.fields as Record< string, Value | typeof UNDEFINED_PLACEHOLDER >; const ids = args.ids as GenericId<string>[] | undefined; const documents = ids !== undefined ? await Promise.all(ids.map((id) => ctx.db.get(id))) : await ctx.db.query(args.table).collect(); try { const patchFields: Record<string, Value | undefined> = {}; for (const key in fields) { const value = fields[key]; patchFields[key] = value === UNDEFINED_PLACEHOLDER ? undefined : value; } await Promise.all( documents.map((document) => ctx.db.patch(document._id, patchFields)), ); } catch (e: any) { // Rewrapping this error because it could be a schema validation error. throw new ConvexError(e.message); } return { success: true }; }, });

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