{"library":"mongodb-mcp-server","title":"MongoDB MCP Server","description":"The MongoDB MCP Server is the official implementation of the Model Context Protocol (MCP) designed to enable AI agents and large language models (LLMs) to interact with MongoDB databases using natural language. It connects various MongoDB deployments (Atlas, Community Edition, Enterprise Advanced) to MCP-supported AI clients such as Cursor, GitHub Copilot, and Claude Desktop. The server provides a rich set of tools for data exploration, database operations (including querying, indexing, and CRUD operations), Atlas management tasks, and performance optimization via integrated Performance Advisor tools. The current stable version is 1.9.0, with a cadence of frequent pre-releases and regular minor version updates. Key differentiators include its seamless integration with MongoDB Atlas, support for local Atlas deployments (requiring Docker), a simplified setup utility (`npx mongodb-mcp-server setup`), and advanced features like automatic vector embedding generation when configured with a Voyage AI API key.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mongodb-mcp-server"],"cli":{"name":"mongodb-mcp-server","version":null}},"imports":["import { startServer } from 'mongodb-mcp-server';","import { type Config } from 'mongodb-mcp-server';","import { Server } from 'mongodb-mcp-server';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { startServer } from 'mongodb-mcp-server';\n\n// To run the server programmatically, you must provide a MongoDB connection string.\n// This can be via environment variables (MONGODB_URI, ATLAS_CLIENT_ID, ATLAS_PRIVATE_KEY)\n// or passed directly in the configuration object.\n\n// Ensure you have a MongoDB connection string set as an environment variable\n// or replace process.env.MONGODB_URI with your actual connection string.\n// For Atlas API credentials, set ATLAS_CLIENT_ID and ATLAS_PRIVATE_KEY.\n\nconst connectionString = process.env.MONGODB_URI ?? 'mongodb://localhost:27017/mcp-db';\n\nconst serverConfig = {\n  connectionString: connectionString,\n  port: 3000,\n  readOnly: false, // Set to true to disable write operations\n  logLevel: 'info' // 'debug', 'info', 'warn', 'error'\n};\n\nasync function main() {\n  try {\n    console.log('Starting MongoDB MCP Server...');\n    const server = await startServer(serverConfig);\n    console.log(`MongoDB MCP Server listening on port ${serverConfig.port}`);\n\n    // Example: Graceful shutdown\n    process.on('SIGINT', async () => {\n      console.log('SIGINT received, shutting down server...');\n      await server.stop();\n      process.exit(0);\n    });\n    process.on('SIGTERM', async () => {\n      console.log('SIGTERM received, shutting down server...');\n      await server.stop();\n      process.exit(0);\n    });\n  } catch (error) {\n    console.error('Failed to start MongoDB MCP Server:', error);\n    process.exit(1);\n  }\n}\n\nmain();\n\n// Alternative quick setup via CLI (recommended for initial setup):\n// npx mongodb-mcp-server setup\n// This command guides you through configuration and starts the server.","lang":"typescript","description":"This quickstart demonstrates how to programmatically start the MongoDB MCP Server, configure it with a connection string, and handle graceful shutdowns. It also mentions the easier CLI-based setup.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}