MCP Server for MongoDB in Golang
This project implements a MongoDB-compatible server in Golang, allowing clients to connect and interact with it as if it were a standard MongoDB server. The server supports basic CRUD operations, authentication, and other MongoDB features.
Features
The following mongodb features are supported:
- Aggregate
- CountDocuments
- DeleteMany
- DeleteOne
- FindOneAndDelete
- FindOneAndReplace
- FindOneAndUpdate
- FindOne
- Find
- InsertMany
- InsertOne
- UpdateMany
- UpdateOne
- ListCollections
Configurations
The server can be configured to run with the following environment variables:
DB_URL=
DB_NAME=
READ_ONLY=false
ALLOW_AGGREGATES=false
Usage
To run the server, use the following command:
go run main.go
Testing with MCP
Install the MCP Inspector using the following command:
npm install -g @modelcontextprotocol/inspector
Now, set your environment variables and run the server:
mcp-inspector go run .
Installing and running the project for production
Install the project with the following command:
go install github.com/CdTgr/mongodb_go_mcp/cmd/mongodb_go_mcp@latest
Now, you can freely connect your favourite MCP client to the server with the following execution command:
mongodb_go_mcp
Note: Make sure to set the required environment variables before running the server.