Skip to main content
Glama

MongoDB MCP Server for LLMs

by vivek1612
MIT License
109
  • Apple
list-collections.ts925 B
import { db } from "../../mongodb/client.js"; import { BaseTool, ToolParams } from "../base/tool.js"; type ListCollectionsParams = ToolParams; export class ListCollectionsTool extends BaseTool<ListCollectionsParams> { name = "listCollections"; description = "List all available collections in the database"; inputSchema = { type: "object" as const, properties: {}, }; async execute(_params: ListCollectionsParams) { try { const collections = await db.listCollections().toArray(); return { content: [ { type: "text" as const, text: JSON.stringify( collections.map((c) => ({ name: c.name, type: c.type, })), null, 2 ), }, ], isError: false, }; } catch (error) { return this.handleError(error); } } }

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

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