Mongo-MCP-server

shaif-codes/Mongo-MCP-server

3.1

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.

Tools
2
Resources
0
Prompts
0

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

  1. Clone the repository
  2. Install dependencies:
npm install
  1. 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


๐Ÿค 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.