Skip to main content
Glama

MongoDB MCP Server

Official
by mongodb-js
stdio.test.ts1.69 kB
import { describe, expect, it, beforeAll, afterAll } from "vitest"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { describeWithMongoDB } from "../tools/mongodb/mongodbHelpers.js"; describeWithMongoDB("StdioRunner", (integration) => { describe("client connects successfully", () => { let client: Client; let transport: StdioClientTransport; beforeAll(async () => { transport = new StdioClientTransport({ command: "node", args: ["dist/index.js", "--disabledTools", "atlas-local"], env: { MDB_MCP_TRANSPORT: "stdio", MDB_MCP_CONNECTION_STRING: integration.connectionString(), }, }); client = new Client({ name: "test", version: "0.0.0", }); await client.connect(transport); }); afterAll(async () => { await client.close(); await transport.close(); }); it("handles requests and sends responses", async () => { const response = await client.listTools(); expect(response).toBeDefined(); expect(response.tools).toBeDefined(); expect(response.tools).toHaveLength(22); const sortedTools = response.tools.sort((a, b) => a.name.localeCompare(b.name)); expect(sortedTools[0]?.name).toBe("aggregate"); expect(sortedTools[0]?.description).toBe("Run an aggregation against a MongoDB collection"); }); }); });

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/mongodb-js/mongodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server