Skip to main content
Glama

Convex MCP server

Official
by get-convex
logging.test.ts3.28 kB
import { ConvexHttpClient } from "convex/browser"; import { api } from "./convex/_generated/api"; import { adminKey, deploymentUrl } from "./common"; type TestCase = { name: string; call: () => Promise<unknown>; }; describe("ConvexHttpClient", () => { let httpClient: ConvexHttpClient; beforeEach(() => { httpClient = new ConvexHttpClient(deploymentUrl); httpClient.setAdminAuth(adminKey); }); test.each<TestCase>(testCases())(`$name`, async ({ call }) => { const logSpy = jest.spyOn(console, "log"); try { await call(); } catch (error: any) { expect(error.message).toEqual(expect.stringContaining("oopsie")); } expect(logSpy).toHaveBeenCalledWith( expect.stringContaining("[LOG]"), expect.stringContaining("color"), expect.stringContaining("Important logged stuff"), ); logSpy.mockClear(); }); function testCases(): TestCase[] { return [ { name: "query succeeding and logging", call: () => httpClient.query(api.logging.queryLogging), }, { name: "query throwing and logging", call: () => httpClient.query(api.logging.queryLoggingAndThrowing), }, { name: "mutation succeeding and logging", call: () => httpClient.mutation(api.logging.mutationLogging), }, { name: "mutation throwing and logging", call: () => httpClient.mutation(api.logging.mutationLoggingAndThrowing), }, { name: "action succeeding and logging", call: () => httpClient.action(api.logging.actionLogging), }, { name: "action throwing and logging", call: () => httpClient.action(api.logging.actionLoggingAndThrowing), }, { name: "query succeeding and logging via function", call: () => httpClient.function(api.logging.queryLogging), }, { name: "query throwing and logging via function", call: () => httpClient.function(api.logging.queryLoggingAndThrowing), }, { name: "mutation succeeding and logging via function", call: () => httpClient.function(api.logging.mutationLogging), }, { name: "mutation throwing and logging via function", call: () => httpClient.function(api.logging.mutationLoggingAndThrowing), }, { name: "action succeeding and logging via function", call: () => httpClient.function(api.logging.actionLogging), }, { name: "action throwing and logging via function", call: () => httpClient.function(api.logging.actionLoggingAndThrowing), }, ]; } test("node action consoleTime", async () => { const logSpy = jest.spyOn(console, "log"); const messages: string[] = []; logSpy.mockImplementation((_prefix, _color, message) => messages.push(message), ); await httpClient.action(api.actions.simple.consoleTime); expect(messages.length).toEqual(5); expect(messages[0]).toMatch(/default: [0-9]+ms/); expect(messages[1]).toMatch(/default: [0-9]+ms/); expect(messages[2]).toMatch(/Timer 'foo' already exists/); expect(messages[3]).toMatch(/'foo: [0-9]+ms' 'bar' 'baz'/); expect(messages[4]).toMatch(/foo: [0-9]+ms/); }); });

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