Skip to main content
Glama

Convex MCP server

Official
by get-convex
messages.ts1.27 kB
import { query } from "./_generated/server"; // @snippet start current-user import { v } from "convex/values"; import { mutation } from "./_generated/server"; import { getCurrentUserOrThrow } from "./users"; export const send = mutation({ args: { body: v.string() }, handler: async (ctx, args) => { const user = await getCurrentUserOrThrow(ctx); await ctx.db.insert("messages", { body: args.body, userId: user._id }); }, }); // @snippet end current-user export const list = query({ args: {}, handler: async (ctx) => { const messages = await ctx.db.query("messages").collect(); return Promise.all( messages.map(async (message) => { // For each message in this channel, fetch the `User` who wrote it and // insert their name into the `author` field. const user = await ctx.db.get(message.userId); return { author: user?.name ?? "deleted user", ...message, }; }), ); }, }); export const sentCount = query({ args: {}, handler: async (ctx) => { const user = await getCurrentUserOrThrow(ctx); const sent = await ctx.db .query("messages") .withIndex("byUserId", (q) => q.eq("userId", user._id)) .collect(); return sent.length; }, });

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