MongoDB + gRPC = MongoRPC
A high-performance gRPC proxy for MongoDB, enabling seamless database access from any platform.
- ✅ Full MongoDB Type Support - ObjectId, Decimal128, GeoPoint, UUID, Regex, and more
- ✅ gRPC API - High-performance, strongly-typed API with streaming support
- ✅ Aggregation Pipelines - Full MongoDB aggregation framework support
- ✅ Transactions - ACID transaction support
- ✅ Change Streams - Real-time data change notifications
- ✅ Modern Go - Built with Go 1.22+, mongo-driver v2, and structured logging
- Go 1.22+
- MongoDB 6.0+
- buf (for proto generation)
# Clone the repository
git clone https://github.com/mongorpc/mongorpc.git
cd mongorpc
# Install dependencies
go mod download
# Build the server
go build -o bin/mongorpc ./cmd/server# Start MongoDB (if not running)
docker run -d -p 27017:27017 --name mongodb mongo:7.0
# Run MongoRPC server
./bin/mongorpc --address localhost:50051 --mongodb-uri mongodb://localhost:27017| Flag | Environment | Default | Description |
|---|---|---|---|
--address |
SERVER_ADDRESS |
localhost:50051 |
gRPC server address |
--mongodb-uri |
MONGODB_URI |
mongodb://localhost:27017 |
MongoDB connection URI |
--database |
MONGODB_DATABASE |
mongorpc |
Default database |
--debug |
DEBUG |
false |
Enable debug logging |
- Web/JavaScript: mongorpc-js
- Dart/Flutter: mongorpc-dart
const client = new MongoRPC("http://localhost:50051");
const document = await client
.database("sample_mflix")
.collection("movies")
.document("573a13b0f29313caabd35231")
.get();var client = await mongorpc("localhost", port: 50051);
var collection = client.database("sample_mflix").collection("movies");
var documents = await collection
.documents()
.limit(10)
.sort(by: "title")
.get();mongorpc/
├── cmd/server/ # Server entry point
├── gen/ # Generated protobuf/gRPC code
├── internal/
│ ├── api/mongorpc/ # gRPC service implementations
│ ├── config/ # Configuration management
│ └── repository/ # Data access layer
│ └── mongodb/ # MongoDB client
├── proto/ # Protocol buffer definitions
│ └── mongorpc/v1/ # v1 API protos
├── buf.yaml # Buf configuration
└── buf.gen.yaml # Code generation config
buf generate protogo build -o bin/mongorpc ./cmd/server# List services
grpcurl -plaintext localhost:50051 list
# Create a document
grpcurl -plaintext -d '{
"database": "test",
"collection": "users",
"document": {
"fields": {
"name": {"string_value": "Alice"},
"age": {"int32_value": 30}
}
}
}' localhost:50051 mongorpc.v1.MongoRPC/CreateDocumentGetDocument- Get a single document by IDListDocuments- List documents with filtering and paginationCreateDocument- Create a new documentUpdateDocument- Update an existing documentDeleteDocument- Delete a documentBatchGetDocuments- Get multiple documents (streaming)
RunQuery- Execute queries with streaming resultsAggregate- Run aggregation pipelinesCountDocuments- Count matching documentsDistinct- Get distinct field values
BeginTransaction- Start a new transactionCommitTransaction- Commit a transactionAbortTransaction- Abort a transaction
Watch- Watch collection for changesWatchDatabase- Watch database for changes
Copyright 2021-2025 MongoRPC
Licensed under the Apache License, Version 2.0