MongoDB Extension
The MongoDB MCP Server extension allows Goose to interact directly with your MongoDB databases, enabling comprehensive database operations including querying, document manipulation, collection management, and database administration. This makes it easy to work with your MongoDB databases through natural language interactions.
- Goose Desktop
- Goose CLI
Command
npx -y mongodb-mcp-server --connection-string mongodb://localhost:27017
Customizing Your Connection
The MongoDB MCP server connects to a single MongoDB database instance using a connection string. The connection string must be specified using the --connection-string
flag. We're using mongodb://localhost:27017
as an example here to access a local MongoDB instance, but you can configure this for your own environment.
The MongoDB connection string follows this format:
mongodb://username:password@hostname:27017/database
Where:
username
: Your MongoDB user (optional for local development)password
: Your MongoDB password (optional for local development)hostname
: The host where MongoDB is running (e.g., localhost, IP address, or domain)27017
: The default MongoDB port (change if using a different port)database
: The name of your database (optional, will connect to default)
Examples:
- Local database:
mongodb://localhost:27017
- Local with credentials:
mongodb://myuser:mypass@localhost:27017/mydb
- MongoDB Atlas:
mongodb+srv://user:pass@cluster.mongodb.net/database
Never commit connection strings with credentials to version control! Use environment variables or secure configuration management. For MongoDB Atlas, ensure your IP address is whitelisted and use strong passwords.
Configuration
Note that you'll need Node.js installed on your system to run this command, as it uses npx
. You'll also need a running MongoDB instance or access to MongoDB Atlas.
- Goose Desktop
- Goose CLI
- Launch the installer
- Press
Yes
to confirm the installation - Enter your MongoDB connection string in the format:
mongodb://username:password@hostname:27017/database
- Click
Save Configuration
- Scroll to the top and click
Exit
from the upper left corner
- Run the
configure
command:
goose configure
- Choose to add a
Command-line Extension
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension (Connect to a new extension)
│
◆ What type of extension would you like to add?
│ ○ Built-in Extension
│ ● Command-line Extension (Run a local command or script)
│ ○ Remote Extension
└
- Name your extension
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension (Connect to a new extension)
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◆ What would you like to call this extension?
│ MongoDB
└
- Enter the command with your database connection string
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension (Connect to a new extension)
│
◇ What would you like to call this extension?
│ MongoDB
│
◆ What command should be run?
│ npx -y mongodb-mcp-server --connection-string mongodb://localhost:27017
└
- Set the timeout (default 300s is usually sufficient)
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension (Connect to a new extension)
│
◇ What would you like to call this extension?
│ MongoDB
│
◇ What command should be run?
│ npx -y mongodb-mcp-server --connection-string mongodb://localhost:27017
│
◆ Please set the timeout for this tool (in secs):
│ 300
└
- Choose to add a description. If you select "Yes" here, you will be prompted to enter a description for the extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension (Connect to a new extension)
│
◇ What would you like to call this extension?
│ MongoDB
│
◇ What command should be run?
│ npx -y mongodb-mcp-server --connection-string mongodb://localhost:27017
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◆ Would you like to add a description?
│ No
└
- Complete the configuration
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension (Connect to a new extension)
│
◇ What would you like to call this extension?
│ MongoDB
│
◇ What command should be run?
│ npx -y mongodb-mcp-server --connection-string mongodb://localhost:27017
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◇ Would you like to add a description?
│ No
│
◆ Would you like to add environment variables?
│ No
└ Added MongoDB extension
Available Operations
The MongoDB extension provides comprehensive database management capabilities through natural language interactions. You can perform a wide range of operations including:
Query Operations
- Find documents with complex filters and sorting
- Aggregate data using MongoDB's powerful aggregation pipeline
- Count documents in collections with optional filtering
Document Management
- Insert single or multiple documents
- Update one or many documents with specified criteria
- Delete specific documents or bulk deletions
Collection & Database Administration
- Create indexes to optimize query performance
- Rename collections for better organization
- Drop collections when no longer needed
- Drop entire databases (use with caution!)
Schema & Analytics
- Analyze collection schemas to understand document structure
- List databases and collections for exploration
- View collection indexes and their configurations
- Check database statistics and collection storage sizes
Just describe what you want to accomplish in natural language, and Goose will help you execute the appropriate MongoDB operations safely and efficiently.
Example Usage
Goose Prompt
Update all users in the premium tier who haven't logged in for more than 90 days - set their status to 'inactive' and add a note about when this change was made.
Goose Output
I've successfully updated inactive premium users using updateMany:
db.users.updateMany(
{
subscriptionTier: "premium",
lastLogin: { $lt: new Date(Date.now() - 90 * 24 * 60 * 60 * 1000) }
},
{
$set: {
status: "inactive",
inactiveNote: "Auto-updated to inactive on 2025-05-25 due to 90+ days of inactivity",
lastModified: new Date()
}
}
)
Operation Result:
{
acknowledged: true,
matchedCount: 23,
modifiedCount: 23,
upsertedId: null,
upsertedCount: 0
}
Updated 23 premium tier users who hadn't logged in since February 24, 2025. Each document now has:
• status: "inactive"
• inactiveNote: explains the automatic status change
• lastModified: timestamp of this operation
Consider sending re-engagement emails to these users or reviewing their subscription status.