shaif-codes/Mongo-MCP-server
If you are the rightful owner of Mongo-MCP-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project provides utility tools to interact with MongoDB, including listing collections and inspecting schema details.
MongoDB MCP Server
This project provides utility tools to interact with MongoDB, including listing collections and inspecting schema details.
๐ Project Structure
.env
.gitignore
.vscode/
โโโ settings.json
package.json
server.js
src/
tools/
โโโ mongoTools.js
utils/
โโโ mongoConnection.js
โโโ responseFormate.js
โ๏ธ Environment Setup
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables:
Create a `.env` file in the root directory and add your MongoDB connection string:
MONGO_URI=<your-mongodb-connection-string>
Setup the MCP Server in Cursor
if the above three setup steps are working, then you are good to go to setup the MCP server in Cursor. Now navigate to settings > MCP then click on "+ add new global MCP server" and paste the below code:
"mongoDB": {
"command": "node",
"args": ["FULL_PATH_OF_server.js_FILE"],
"env": {
"MONGO_URI": "<YOUR_MONGODB_URI_OF_DB>"
}
}
๐ Usage
Start the Server
- For production:
```bash npm start ```
- For development with live reloading:
```bash npm run dev ```
๐ ๏ธ Available Tools
1. `list_all_mongoDB_collections()`
- Description: Lists all collections in the connected MongoDB database.
- Input: None
- Output: Array of collection names.
2. `get_schema_details_of_collection(collectionName)`
- Description: Fetches schema details of a collection by analyzing a sample document.
- Input:
- `collectionName` (string): Name of the MongoDB collection
- Output: JSON object representing schema details.
๐งช Development Notes
๐๏ธ Project Type
- Uses ES Modules (`"type": "module"` in `package.json`)
๐ Scripts
- `npm start`: Runs the server
- `npm run dev`: Runs the server with `nodemon` for live reloading
๐ฆ Dependencies
- `@modelcontextprotocol/sdk` - MCP SDK
- `dotenv` - Load environment variables
- `mongoose` - MongoDB ODM
- `zod` - Schema validation
- `nodemon` - Development auto-reloader
๐ค Contributing
Contributions are welcome!
Feel free to fork the repository and submit a pull request for any improvements or bug fixes.
๐ License
This project is licensed under the ISC License.