How to Give an Agent a Query Language Instead of a Code Interpreter
A four-step pattern for letting a document agent write validated aggregation pipelines instead of arbitrary code, so results come back shaped and tenancy stays enforced.
Loading…
Topic
80 posts about MongoDB. Every summary links to the original.
See the idea
A four-step pattern for letting a document agent write validated aggregation pipelines instead of arbitrary code, so results come back shaped and tenancy stays enforced.
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
Newest first
This tutorial walks through connecting a Node.js script to a MongoDB database, listing the cluster’s databases, and printing the results to the console. It begins with prerequisites: a supported Node.js version, the MongoDB Node.js Driver installed via npm, and a free MongoDB Atlas cluster loaded with sample data. The Atlas connection wizard adds the current IP address, creates a MongoDB user, and supplies a connection string for Node.js driver version 3.6 or later. The script imports MongoClient, defines an asynchronous main function, creates a client with the connection URI, and awaits client.connect(). Database calls sit inside try/catch, with a finally block closing the connection, and a listDatabases function retrieves and prints the database names before the script runs with node connection.js.
MongoDB Atlas Resource Policies are organization-level controls that enforce infrastructure governance rules using the open-source Cedar policy language, acting as intelligent guardrails that constrain configuration options while maintaining developer flexibility. Two key policies are Restrict Cloud Hyperscaler, which controls which cloud platforms can be used, and Restrict Cloud Hyperscaler Region, which restricts deployments to specific geographic regions. These policies ensure compliance with data residency regulations like GDPR and CCPA and prevent cost overruns. A global financial services company combined hyperscaler and region policies with network security controls to keep customer data in GDPR-compliant AWS regions, achieving zero compliance violations in a subsequent audit. Resource policies are enforced automatically, preventing noncompliant configurations before creation while existing noncompliant clusters continue running, and can be managed through the Atlas UI, API, Terraform, or AWS CloudFormation at no additional cost.
MongoDB Atlas IP access lists control which IP addresses or CIDR blocks can connect to clusters in a project, and each project supports up to 200 entries. Manual management drifts as teams add convenience entries, leaving security teams without visibility until an audit or incident. MongoDB Atlas Resource Policies operate at the organization level and automatically apply to all projects and clusters, blocking insecure configurations before deployment. Two examples are an IP address allowlist that permits only specified addresses and an empty IP access list policy that forces access through private endpoints or VPC peering. Enforcement is consistent across teams, generates activity feed events for auditability, and is included with all Atlas deployments at no additional cost.
The article describes an agentic AI pipeline for enhanced due diligence (EDD) in financial crime case management, built with LangGraph and MongoDB. It aims to replace manual, rule-based AML workflows with specialized agents that triage suspicious activity, gather evidence, and draft Suspicious Activity Report (SAR) narratives. The pipeline uses a team of agents for notification, data gathering, case analysis, SAR authorship, and compliance quality assurance. A human-in-the-loop pattern ensures each decision can be traced for auditability. MongoDB serves as the durable state backbone, while LangGraph handles orchestration and dynamic routing. The author emphasizes that enterprise agentic AI must centralize state in a persistent store rather than rely on the agent as the source of truth.
This quick start guide demonstrates the initial setup for connecting C# applications to MongoDB. The demonstration uses Visual Studio 2019 on Windows 10 and connects to a MongoDB Atlas cluster that has the sample dataset pre-installed. Setup involves creating a .NET Core console application named MongoDBConnectionDemo and installing the MongoDB.Driver version 2.9.1 via NuGet’s Manage Packages for Solution. The code adds a using MongoDB.Driver directive, creates a MongoClient with the Atlas connection string, retrieves the list of databases using ListDatabaseNames, and prints each database name to the console in just over 20 lines. This article is the first in a Quick Start series that will cover creating, reading, updating, and deleting documents, mapping MongoDB documents to C# objects, using the MongoDB aggregation pipeline, and integrating LINQ queries with MongoDB.
MongoDB introduced Automated Embedding in MongoDB Vector Search, now in Public Preview in Community Edition, to remove the complexity of manual vector embedding generation and synchronization. The feature lets developers select an embedding model, including state-of-the-art Voyage AI models such as voyage-4-large and voyage-code-3, directly when creating a vector search index. The system automatically generates and synchronizes embeddings during index creation, document writes, and queries, eliminating the need for external embedding APIs and custom MLOps pipelines. Asynchronous dynamic batch processing and built-in retries handle large-scale ingestion without blocking database operations. Customers testing the feature reported converting weeks of engineering work into low-maintenance production workflows and seeing immediate performance improvements.
As applications grow, database teams face complex decisions about data distribution and scaling, and MongoDB Atlas Sharding Advisor helps by bringing sharding insights, recommendations, and shard key analysis into a unified view for dedicated Atlas deployments running MongoDB 8.0 or later. Sharding Insights consolidates shard-level, collection-level, and mongos metrics using existing Atlas infrastructure, requiring no additional agents or separate telemetry pipelines. Sharding Recommendations flag conditions such as a collection growing beyond a single shard’s capacity, uneven load across shards, or shards approaching capacity, and provide context and suggested next steps without automatic remediation. The Shard Key Analyzer evaluates candidate keys on cardinality, frequency, and monotonicity using the analyzeShardKey command, and can incorporate read and write distribution data when query sampling is configured. It supports single-field, compound, and hashed shard-key analysis, helping teams compare candidates with evidence rather than assumptions alone, and enabling more informed decisions about their sharded deployments.
False payment declines cost global businesses over $50 billion annually, with 45% of shoppers abandoning purchases after a single checkout decline. Scripted routing rules fall short due to dimensionality explosion, unstructured error interpretation, and multi-constraint trade-offs. The proposed architecture separates an asynchronous multi-agent control plane, which continuously analyzes telemetry, simulates rerouting options, and enforces cost guardrails, from a fast execution data plane that queries deterministic JSON rules in milliseconds. Specialized agents automate a five-step optimization loop: baseline analysis, segment performance, routing simulation, cost impact, and recommendation with human approval. MongoDB stores flexible payment context documents, enables vector search for similar scenarios, and serves active rules for low-latency execution, supporting the control-execution separation.
Global businesses lose 1.5% to 2.2% of annual revenue to poor payment performance and false declines, with 45% of shoppers abandoning purchases after a single checkout decline, yet payment ops teams remain trapped in manual CSV and spreadsheet cycles. Traditional scripted routing fails due to three limitations: dimensionality explosion from complex intersections of rail, jurisdiction, and asset type; unstructured error interpretation from inconsistent decline codes; and multi-constraint trade-offs between authorization rates and processing fees. An agentic architecture decouples routing intelligence from checkout execution using an asynchronous multi-agent control plane and a high-speed execution data plane. The control plane automates a five-step optimization loop—baseline analysis, segment performance, routing simulation, cost impact, and recommendation—while the data plane deterministically queries active declarative rules in milliseconds. MongoDB stores telemetry, vectors, and active JSON rules, and Atlas Agent Engine manages the agent lifecycle with native memory, safety controls, and support for MCP and A2A standards.
AWS CodeWhisperer, now part of Amazon Q Developer, is an AI code assistant trained on billions of lines of code that generates real-time suggestions from snippets to full functions. MongoDB collaborated with AWS Data Science to fine-tune CodeWhisperer’s foundational models specifically for MongoDB, improving code suggestion quality for developers. This tutorial focuses on setting up CodeWhisperer in VS Code via the AWS Toolkit extension, though it also supports other IDEs like AWS Cloud9 and JupyterLab. Users can start without an AWS account, and the service is currently free for individual users. The guide covers installation, authorization with a Builder ID, navigating suggestions with TAB and arrow keys, and best practices like writing descriptive comments and using import statements.
MongoDB.local London 2024 marked the nineteenth stop of the 2024 tour, where MongoDB announced the general availability of MongoDB 8.0. The new version delivers 36% better read throughput, 56% faster bulk writes, and 20% faster concurrent writes during data replication. Atlas Vector Search introduced vector quantization, reducing memory by up to 96% and enabling higher-scale AI applications at lower cost. The MongoDB Copilot Participant for GitHub Copilot entered public preview, providing domain-specific AI assistance within VS Code. Additional updates included multicluster support for the Enterprise Kubernetes Operator and general availability of Atlas Search and Vector Search via the Atlas CLI and Docker.
JetBrains released a new version of DataGrip that includes support for MongoDB and ships with the MongoDB Shell out of the box. Users of other JetBrains IDEs can install the Database Tools plugin to work with MongoDB inside their existing development environment. The integration uses an embeddable MongoDB Shell as the engine behind database consoles, providing a console experience consistent with the terminal and other MongoDB developer tools. DataGrip also works with Atlas Data Lake, allowing users to query data stored in Amazon S3 using MQL. Users can connect to a free Atlas cluster by grabbing a connection string from the Atlas UI and adding a new data source in DataGrip.
The European Commission awarded sovereign-cloud contracts in April 2026 under the Cloud III DPS, using SEAL-2 and SEAL-3 from the CSF as benchmarks. Three provider groups achieved SEAL-3 and one attained SEAL-2, showing sovereignty as a spectrum rather than a binary threshold. Infrastructure certification under such frameworks does not cover the database tier, which requires separate evaluation for data paths, encryption, key management, and control-plane dependencies. MongoDB fits into this ecosystem through three deployment models: Certified DBaaS on SEAL-3 providers, MongoDB Atlas with client-side and queryable encryption, and Enterprise Advanced for self-managed deployment. Each model preserves the same core document model and query semantics, enabling workload portability across tiers without redesign effort.
The Claude Agent SDK embeds Claude Code’s agent loop into applications, providing tools like web search and MCP connections without manual tool definition. It automatically persists session transcripts to the local file system, but this is unsuitable for stateless deployments like Lambda functions where each invocation is a disposable instance. The MongoDB Claude SDK Session Adapter solves this by implementing the SDK’s SessionStore interface to mirror every conversation turn to MongoDB in real time. This enables cross-environment continuity, resilience to host failures, and auditability under existing access controls, without requiring a separate system for agent memory. The adapter can be configured with a few lines of code, making agent sessions portable across any instance with access to the MongoDB cluster.
Large language models must reliably translate natural language requests into database query languages, but MQL, MongoDB’s query language, has lacked a dedicated benchmark. The authors introduce AptMQL-Bench, a Text-to-MQL benchmark derived from the BIRD Text-to-SQL dataset, comprising 21 MongoDB databases and 3,186 natural-language requests across domains like commerce and science. They present an agent-driven conversion pipeline that treats schema design as a first-class step, using access-pattern analysis to produce schemas that follow MongoDB’s golden rule of storing accessed-together data together. The pipeline includes automated validation checks and a second optimization pass that rewrote 45% of translated MQL queries to use embedded fields and precomputed aggregates. Evaluations of eight LLMs show the benchmark is challenging, with the best model (Claude Opus 4.5) achieving 70.34% soft execution accuracy with external knowledge, and the authors propose Soft-EX as a more appropriate metric for MQL than strict execution accuracy.
Teams increasingly want agents that handle routine database work—such as checking cluster alerts, reviewing slow queries, and answering questions about a schema—but building agents takes much more than a prompt, including credential handling, access scoping, tool orchestration, approval flows, and more. Today MongoDB launched MongoDB Agents, a collection of open source agent templates that combine the MongoDB MCP Server and MongoDB Agent Skills with the plumbing you would otherwise build yourself. Each template includes scoped MongoDB Atlas credentials, approval flows for writes, and a ready-to-run deployment configuration for Atlas Agent Engine. Built-in guardrails give each agent its own Atlas identity, default read-only access, require human approval for every write tool, block outbound traffic to unallowed hosts, and prevent shell execution. You can use the agents in the Agent Engine Playground, via the agentengine CLI, or integrate with Slack using the optional bot to ask questions, approve writes, and schedule reports.
Legacy mainframe systems using COBOL and CICS still dominate core insurance functions, creating high maintenance costs and slow innovation due to data trapped in outdated 21-table relational schemas. This tutorial demonstrates how the document model simplifies insurance data models by refactoring the Object Management Group’s Party Role model, which defines how people and organizations are involved in policies, claims, and insurable objects. MongoDB’s Relational Migrator transforms the 21-table relational schema into a lean five-collection MongoDB model for Party, Policy, Claim, Litigation, and roles. The process covers connecting to PostgreSQL, replicating the Party Role model via psql and pg_restore, and using Relational Migrator’s schema design and data migration to refactor and migrate data. After migration, insurers gain faster product launches, swift regulatory adaptation, and enhanced customer experiences through a modernized data infrastructure.
Legacy payment architectures in financial institutions are fragmented, rigid, and deeply siloed, making adaptation to new payment rails and AI operations difficult. Banks can overcome this by adopting a composable business-capability architecture based on the BIAN standard, decoupling payment logic from tightly coupled systems. A canonical payment model gives each payment a common business vocabulary and identity throughout its lifecycle, accumulating context from validations, enrichments, and exceptions. MongoDB’s flexible document model, with search, vector search, change streams, and multi-document transactions, provides the unified data layer that enables these capabilities and agentic operations. For example, a cutoff-exception event allows an agent to read canonical context and recommend same-day processing with human review, and new rails like ACH are added by extending the canonical model rather than creating new silos.
LangGraph checkpoints persist agent state, including user messages and tool results, as plaintext BSON in MongoDB by default, leaving sensitive data accessible to anyone who can read the database. MongoDB Client-Side Field Level Encryption (CSFLE) encrypts data on the client before transmission, ensuring the database engine never sees plaintext values and protecting against privileged database users or data breaches. This post demonstrates implementing a custom CipherProtocol for LangGraph’s EncryptedSerializer that uses explicit CSFLE with randomized encryption, configured with AWS KMS and a data encryption key stored in a key vault collection for envelope encryption. The encrypted payload replaces the default Base64 encoding, while only thread IDs, checkpoint IDs, and namespaces remain unencrypted to support runtime lookups without exposing sensitive content. This approach aligns with enterprise security and compliance requirements for customer-facing AI agents, preserving resumable sessions and human-in-the-loop workflows while preventing database administrators or attackers from reading the state.
AI agents are transforming retail discovery, requiring product catalogs to be machine-readable and context-rich for systematic retrieval, with McKinsey estimating AI agents could orchestrate $3 trillion to $5 trillion globally by 2030. Retailers need a single enriched catalog that projects consistently to three surfaces: outbound product feeds, agentic commerce endpoints via REST APIs or MCP, and product detail pages with schema.org JSON-LD. MongoDB’s document model supports three tiers of enrichment—identity and transactability, filterable attributes, and agentic context such as use cases and semantic embeddings—to help AI agents reason over products. Change streams and aggregation pipelines keep projections current across surfaces, ensuring consistency that AI agents cross-check. MongoDB Search and Vector Search enable hybrid retrieval for intent-based queries, helping retailers improve discoverability and gain a competitive advantage in the agentic commerce era.
The best engineering reads, once a week.