About MCP Server with MongoDB Integration
An MCP server for querying MongoDB databases. It offers collection listing and filtered queries, with connection settings configurable through environment variables.
Key features
- 01Query collections with filters
- 02Set a result limit
- 03List database collections
- 04Configure connection via environment variables
Use cases
- 01Inspect documents matching a MongoDB filter
- 02Check which collections exist in a database
MCP support
Exposes MongoDB collection listing and filtered queries as tools for MCP clients.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Server with MongoDB Integration
This is an MCP server that provides tools for querying MongoDB data.
Setup
- Install dependencies using uv:
uv pip install -e .
- Configure MongoDB connection:
- The server will connect to MongoDB at
mongodb://localhost:27017by default - You can change the connection details by setting environment variables:
MONGODB_URI: MongoDB connection stringMONGODB_DATABASE: Database name
- The server will connect to MongoDB at
Running the Server
python main.py
Available Tools
1. query_mongodb
Query a MongoDB collection with a filter.
Parameters:
collection(string): Name of the collection to queryquery(object): MongoDB query filterlimit(integer, optional): Maximum number of results to return (default: 10)
Example:
{
"collection": "users",
"query": {"age": {"$gt": 18}},
"limit": 5
}
2. list_collections
List all collections in the database.
No parameters required.
Development
To add new dependencies:
uv pip install <package-name>
To update dependencies:
uv pip install --upgrade <package-name>
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.