- Home
- MCP servers
- MongoDB
MongoDB
- javascript
0
GitHub Stars
javascript
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"nan-qin-mcp-mongodb": {
"command": "node",
"args": [
"E:\\project\\mongodb\\build\\index2.js"
],
"env": {
"MONGO_URI": "mongodb://localhost:27017/"
}
}
}
}You can run an MCP server that connects to a local MongoDB instance and expose controlled tool-based access to your data. This server runs as a local process, accepts commands, and can perform read operations and multi-collection queries through MCP tools. It uses a MongoDB URI to connect and operates with a defined set of tools you can invoke from your MCP client.
How to use
Start the MCP MongoDB server by launching the local process defined in your configuration. Once running, you can perform actions through your MCP client by addressing the server named "mongodb" and using supported tools.
Read resources and perform multi-collection queries
<use_mcp_tool>
<server_name>mongodb</server_name>
<tool_name>read_resource</tool_name>
{
"uri": "mongodb://localhost:27017/common"
}
</use_mcp_tool>
<use_mcp_tool>
<server_name>mongodb</server_name>
<tool_name>multi_collection_query</tool_name>
{
"database": "common",
"collection": "players",
"pipeline": [
{
"$lookup": {
"from": "platform",
"localField": "platform",
"foreignField": "appKey",
"as": "platformInfo"
}
},
{
"$unwind": "$platformInfo"
},
{
"$project": {
"_id": 1,
"pid": 1,
"__v": 1,
"bank": 1,
"ip": 1,
"lobbyUrl": 1,
"platform": "$platformInfo",
"rtp": 1,
"_collection": { "$literal": "players" }
}
},
{
"$limit": 2
}
]
}
</use_mcp_tool>
How to install
Prerequisites: you need Node.js installed on your machine and a running MongoDB instance that your MCP server can connect to.
Steps to set up and run the MCP MongoDB server locally:
Install Node.js from the official source on your operating system if it is not already installed.
Ensure MongoDB is running locally on the default port 27017.
Create the MCP configuration file with the MongoDB server entry exactly as shown in this configuration snippet.
Start the MCP MongoDB server by executing the command you defined for the stdio configuration, which runs Node with the index script.
Verify the server starts without errors and is ready to accept tool calls from your MCP client.
Additional content
Configuration details from the setup show a local server named mongodb that runs with node and the script path E:\project\mongodb\build\index2.js, and it exposes an environment variable MONGO_URI set to mongodb://localhost:27017/.
Important tools you can use with this server include read_resource for read-only access to resources and multi_collection_query for joined/aggregated results across collections. You can pass a MongoDB URI through the MONGO_URI environment variable to point the MCP server at your database instance.
Example environment configuration for the server (as shown in the setup): MONGO_URI set to mongodb://localhost:27017/.
Notes and troubleshooting
If the server fails to start, check that Node.js is installed and that the script path in the command exists on your machine. Ensure MongoDB is reachable at the URI you provide in MONGO_URI. Verify that there are no port conflicts and that your environment variables are correctly loaded by the process.
Available tools
read_resource
Executes read-only reads against MongoDB resources; suitable for retrieving documents, collection metadata, and similar read operations.
multi_collection_query
Performs multi-collection joins and aggregations across MongoDB collections using a pipeline, enabling complex data retrieval like lookups and projections.