Skip to main content
Glama

Convex MCP server

Official
by get-convex
messages.ts1.3 kB
import { v, ConvexError } from "convex/values"; // @snippet start query import { mutation, query } from "./_generated/server"; const MESSAGES_LIMIT = 20; const MESSAGE_CHARS_LIMIT = 50; export const list = query({ args: {}, handler: async (ctx) => { const messages = await ctx.db.query("messages").collect(); if (messages.length > MESSAGES_LIMIT) { throw new ConvexError({ message: "Too many messages!", length: messages.length, code: "MESSAGE_LIMIT", }); } return Promise.all( messages.map(async (message) => ({ ...message, })), ); }, }); // @snippet end query export const sendMessage = mutation({ args: { body: v.string(), author: v.string() }, handler: async (ctx, args) => { const { body, author } = args; if (body.length > MESSAGE_CHARS_LIMIT) { throw new ConvexError("Message is over 50 characters."); } await ctx.db.insert("messages", { body, author, format: "text" }); }, }); export const clearMessages = mutation({ handler: async (ctx) => { const messages = await ctx.db.query("messages").collect(); return Promise.all( messages.map(async (message) => { const id = message._id; await ctx.db.delete(id); return id; }), ); }, });

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