Supports environment variable configuration for connecting to different MongoDB instances (local or cloud) with various authentication methods.
Provides tools to query MongoDB databases with capabilities for searching, filtering, counting, and retrieving user collections with support for MongoDB query operators, sorting and projection.
MCP MongoDB Server
An MCP (Model Context Protocol) server that provides tools to interact with MongoDB databases, specifically designed to query user collections.
Features
- Query Users: Search and filter users with MongoDB queries
- Get User by ID: Retrieve specific users by their ID
- Count Users: Get total count of users with optional filtering
- Flexible Filtering: Support for MongoDB query operators
- Sorting and Projection: Advanced query capabilities
Prerequisites
- Node.js 18+
- MongoDB instance (local or cloud)
- TypeScript knowledge
Installation
- Install dependencies:
- Set up environment variables:Edit
.env
with your MongoDB connection details: - Build the project:
Usage
Starting the Server
Or for development with auto-reload:
Available Tools
1. query_users
Query users with optional filters, sorting, and projection.
Parameters:
filter
(object, optional): MongoDB filter objectlimit
(number, optional): Maximum results (default: 10)sort
(object, optional): Sort criteriaprojection
(object, optional): Fields to include/exclude
Example:
2. get_user_by_id
Retrieve a specific user by their ID.
Parameters:
userId
(string, required): The user ID to search for
Example:
3. count_users
Count total users with optional filtering.
Parameters:
filter
(object, optional): MongoDB filter object
Example:
MongoDB Connection
The server supports various MongoDB connection types:
Local MongoDB
MongoDB with Authentication
MongoDB Atlas
Development
Project Structure
This server cannot be installed
An MCP server that provides tools to query and interact with MongoDB user collections, supporting filtering, sorting, and retrieval operations.
Related MCP Servers
- -securityAlicense-qualityFull featured MCP Server for MongoDB database analysis.Last updated -334108JavaScriptMIT License
- -securityAlicense-qualityAn MCP server that enables users to create and manage MongoDB Atlas clusters, users, and network access through natural language commands.Last updated -7410JavaScriptMIT License
- -securityAlicense-qualityAn MCP server that enables large language models to interact directly with MongoDB databases, allowing them to query collections, inspect schemas, and manage data through natural language.Last updated -1,734MIT License
- -securityFlicense-qualityAllows interaction with MongoDB collections and documents through standardized MCP requests, supporting operations like listing collections, reading documents with filtering, and executing structured queries.Last updated -JavaScript