Skip to main content
Glama

Convex MCP server

Official
by get-convex
messages.ts1.38 kB
import { v } from "convex/values"; // @snippet start query import { query } from "./_generated/server"; export const list = query({ args: {}, handler: async (ctx) => { const messages = await ctx.db.query("messages").collect(); return Promise.all( messages.map(async (message) => ({ ...message, // If the message is an "image" its `body` is an `Id<"_storage">` ...(message.format === "image" ? { url: await ctx.storage.getUrl(message.body) } : {}), })), ); }, }); // @snippet end query // @snippet start generateUploadUrl import { mutation } from "./_generated/server"; export const generateUploadUrl = mutation({ handler: async (ctx) => { return await ctx.storage.generateUploadUrl(); }, }); // @snippet end generateUploadUrl // @snippet start saveStorageId export const sendImage = mutation({ args: { storageId: v.id("_storage"), author: v.string() }, handler: async (ctx, args) => { await ctx.db.insert("messages", { body: args.storageId, author: args.author, format: "image", }); }, }); // @snippet end saveStorageId export const sendMessage = mutation({ args: { body: v.string(), author: v.string() }, handler: async (ctx, args) => { const { body, author } = args; await ctx.db.insert("messages", { body, author, format: "text" }); }, });

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