Skip to main content
Glama

Convex MCP server

Official
by get-convex
clearTablePage.ts1.53 kB
import { Cursor } from "convex/server"; import { mutationGeneric } from "../server"; import { v } from "convex/values"; export const MAX_CLEAR_ROWS = 4000; export default mutationGeneric({ args: { componentId: v.optional(v.union(v.string(), v.null())), tableName: v.string(), cursor: v.union(v.string(), v.null()), }, handler: async ( ctx, args, ): Promise<{ deleted: number; hasMore: boolean; continueCursor: Cursor; }> => { const { db } = ctx; const { tableName, cursor } = args; // Delete from oldest to newest to avoid repeatedly invalidating the query // run by the data page const { page: documents, continueCursor, isDone, } = await db .query(tableName) .withIndex("by_creation_time") .order("asc") .paginate({ numItems: MAX_CLEAR_ROWS, cursor, // We can read up to 8MiB, but we're currently double counting the docs // when they're read in this query and also when they're deleted. // And we allow `maximumBytesRead` to be exceeded by a single document, // and a single document maxes out at 1MiB. // To ensure (maximumBytesRead + 1MiB) * 2 < 8MiB, we need // this limit conservative to avoid hitting limits and crashing. maximumBytesRead: 3000000, }); await Promise.all(documents.map((doc) => db.delete(doc._id))); return { deleted: documents.length, continueCursor, hasMore: !isDone, }; }, });

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