MongoDB
Deploy MongoDB 7 with persistent storage — document database with auto-generated credentials
Ink deploys MongoDB 7 as a container service with a persistent volume. Your agent provisions the database using a template — credentials are auto-generated and returned immediately.
Deploying
Your agent uses the template_deploy MCP tool:
template_deploy(
"template": "mongodb",
"name": "my-db"
){
"services": [object Object],
"outputs": [object Object]
}Or via the CLI:
ink template deploy mongodb --name my-dbAuto-generated credentials
| Variable | Value |
|---|---|
MONGO_INITDB_ROOT_USERNAME | admin |
MONGO_INITDB_ROOT_PASSWORD | Auto-generated at deploy time |
DATABASE_URL | Full connection string with generated credentials |
Passwords are randomly generated. The agent receives them as outputs — no manual password management required.
Persistent storage
A persistent volume is attached at /data/db (1 Gi default). Data survives container restarts and redeployments.
Connecting
After deployment, template_deploy returns a DATABASE_URL in the format:
mongodb://user:pass@hostname:27017/dbname?authSource=adminThe internal URL (my-db:27017) is used for service-to-service communication within the same project. Any sibling service can connect by hostname — no external networking required.
Client libraries
Node.js
npm install mongodbimport { MongoClient } from 'mongodb';
const client = new MongoClient(process.env.DATABASE_URL);
await client.connect();
const db = client.db();
const users = await db.collection('users').find().toArray();Python
pip install pymongoimport os
from pymongo import MongoClient
client = MongoClient(os.environ["DATABASE_URL"])
db = client.get_default_database()
users = list(db.users.find())Specs
| Property | Value |
|---|---|
| Engine | MongoDB 7 |
| Image | mongo:7 |
| Port | 27017 |
| Volume | /data/db |
| Default Memory | 512Mi |
| Default vCPU | 0.5 |