|
1 | 1 | --- |
2 | 2 | title: Connect Microsoft Foundry Agents to MongoDB Atlas |
3 | | -description: Learn how to connect Microsoft Foundry Agents to MongoDB Atlas |
| 3 | +description: Learn how to connect Microsoft Foundry Agents to MongoDB Atlas using the MongoDB MCP Server for data retrieval and vector search. |
4 | 4 | ms.topic: how-to |
5 | | -ms.date: 03/20/20256 |
| 5 | +ms.date: 03/20/2026 |
6 | 6 | --- |
7 | 7 |
|
8 | | -# Connect Microsoft Foundry Agents to MongoDB Atlas |
| 8 | +# Connect Microsoft Foundry agents to MongoDB Atlas |
9 | 9 |
|
10 | | -This article shows how to connect Microsoft Foundry agents that can query and retrieve data from MongoDB Atlas using the MongoDB MCP Server. |
| 10 | +This article shows you how to connect Microsoft Foundry agents that can query and retrieve data from MongoDB Atlas using the MongoDB MCP Server. |
11 | 11 |
|
12 | | -## Pre-requistes |
| 12 | +## Architecture overview |
| 13 | + |
| 14 | +At a high level, the integration includes these components: |
| 15 | + |
| 16 | +- **Microsoft Foundry Agent** – Orchestrates reasoning and tool usage. |
| 17 | +- **MongoDB MCP Server** – Exposes MongoDB Atlas operations (vector search, aggregation) as agent tools. |
| 18 | +- **MongoDB Atlas** – Stores operational and vectorized data. |
| 19 | +- **Azure hosting** – Hosts the MCP Server in Azure Container Apps. |
| 20 | + |
| 21 | +The Foundry agent calls the MCP Server over HTTPS at query time, and the MCP Server executes operations against your Atlas cluster. Your data remains in MongoDB Atlas. |
| 22 | + |
| 23 | +## Prerequisites |
13 | 24 |
|
14 | 25 | Before you begin, ensure you have: |
15 | 26 |
|
16 | | -- An Azure subscription with access to Microsoft Foundry Project |
17 | | -- A MongoDB Atlas account with a project and cluster |
18 | | -- A vector index created in MongoDB Atlas (for RAG scenarios) |
19 | | -- Permission to deploy services to Azure (for MCP Server hosting) |
| 27 | +- An Azure subscription with access to a Microsoft Foundry project. |
| 28 | +- A MongoDB Atlas account with a project and cluster. |
| 29 | +- A vector search index created in MongoDB Atlas (for RAG scenarios). |
| 30 | +- Permission to deploy services to Azure (for MCP Server hosting). |
| 31 | + |
| 32 | +## Prepare MongoDB Atlas |
| 33 | + |
| 34 | +1. Create or select a MongoDB Atlas cluster. |
| 35 | +1. Load your dataset (for example, sample Airbnb or domain-specific data). |
| 36 | +1. Create a vector search index on the target collection. |
| 37 | + |
| 38 | +## Deploy the MongoDB MCP Server |
| 39 | + |
| 40 | +The [MongoDB MCP Server](https://github.com/mongodb-js/mongodb-mcp-server) acts as a bridge between Foundry agents and MongoDB Atlas. |
| 41 | + |
| 42 | +1. Deploy the MCP Server to Azure Container Apps or another Azure-hosted environment. For details on hosting, see the [MongoDB MCP Server Azure deployment guide](https://github.com/mongodb-js/mongodb-mcp-server/blob/main/deploy/azure/README.md). |
| 43 | +1. Configure the server with: |
| 44 | + - MongoDB Atlas connection details |
| 45 | + - Enabled tools (vector search, aggregation) |
| 46 | +1. Expose a remote HTTPS endpoint. |
| 47 | + |
| 48 | +## Create an agent in Microsoft Foundry |
| 49 | + |
| 50 | +1. Open the Microsoft Foundry portal. |
| 51 | +1. Create a new agent, provide system instructions, and choose a deployed Foundry model. |
| 52 | +1. Go to **Tools** > **MongoDB MCP Server** > **Connect**. |
| 53 | +1. Paste the MCP Server remote URL. |
| 54 | +1. Save the agent configuration. |
| 55 | + |
| 56 | +After you add the MCP Server, the agent can invoke MongoDB operations through the MCP tool during reasoning. |
20 | 57 |
|
21 | | -## Pre-requisites for RAG |
| 58 | +## Deploy the embedding endpoint |
22 | 59 |
|
23 | | -In retrieval-augmented generation (RAG) scenarios, Foundry agents often need to generate embeddings for user queries at runtime before invoking MongoDB Atlas Vector Search. This integration supports that pattern by exposing an embedding generation function as an OpenAPI (Swagger)–based tool that the agent can call during reasoning. |
| 60 | +In retrieval-augmented generation (RAG) scenarios, Foundry agents need to generate embeddings for user queries at runtime before invoking MongoDB Atlas Vector Search. You expose an embedding generation function as an OpenAPI-based tool that the agent calls during reasoning. |
24 | 61 |
|
25 | | -- Define the embedding function like below |
| 62 | +Define the embedding function with the following OpenAPI specification: |
26 | 63 |
|
27 | 64 | ```yaml |
28 | 65 | openapi: 3.0.1 |
@@ -57,65 +94,32 @@ paths: |
57 | 94 | items: |
58 | 95 | type: number |
59 | 96 | ``` |
60 | | -The implementation behind this API typically calls a Foundry-hosted embedding model (for example, text-embedding-3-large) and returns the vector as JSON. |
61 | 97 |
|
62 | | -## Connect Microsoft Foundry agents to MongoDB Atlas |
| 98 | +The implementation behind this API typically calls a Foundry-hosted embedding model (for example, `text-embedding-3-large`) and returns the vector as JSON. |
63 | 99 |
|
64 | | -### Step 1: Prepare MongoDB Atlas |
| 100 | +## Configure the agent for vector search |
65 | 101 |
|
66 | | -- Create or select a MongoDB Atlas cluster. |
67 | | -- Load your dataset (for example, sample Airbnb or domain-specific data). |
68 | | -- Create a vector search index on the target collection. |
| 102 | +By using the previous steps, you can perform database operations but you can't perform vector search because it requires embedding user queries. To configure the agent for vector search: |
69 | 103 |
|
70 | | -Microsoft Foundry connects to Atlas data in-place. The data remains in MongoDB Atlas, and Foundry agents retrieve it at query time. |
| 104 | +1. In the agent tools, add a new OpenAPI tool. |
| 105 | +1. Paste the OpenAPI specification from the [Deploy the embedding endpoint](#deploy-the-embedding-endpoint) step. |
| 106 | +1. In the agent instructions, guide the agent to invoke this function for vector search use cases. |
| 107 | +1. Save the agent. |
71 | 108 |
|
72 | | -### Step 2: Deploy the MongoDB MCP Server |
| 109 | +Once registered, the agent can invoke `generateEmbeddings` as part of its reasoning chain. |
73 | 110 |
|
74 | | -The [MongoDB MCP Server](https://github.com/mongodb-js/mongodb-mcp-server) acts as a bridge between Foundry agents and MongoDB Atlas. |
75 | | -
|
76 | | -- Deploy the MCP Server to Azure Container Apps or another Azure-hosted environment. For details on hosting, [visit] (https://github.com/mongodb-js/mongodb-mcp-server/blob/main/deploy/azure/README.md) |
77 | | -- Configure it with:MongoDB Atlas connection details |
78 | | -- Enabled tools (vector search, aggregation) |
79 | | -- Expose a remote HTTPS endpoint |
80 | | -
|
81 | | -### Step 3: Create an Agent in Microsoft Foundry |
82 | | -
|
83 | | -- Open the Microsoft Foundry portal |
84 | | -- Create a new agent and provide system instructions and choose a deployed Foundry model |
85 | | -- Go to Tools > MongoDB MCP Server > Connect |
86 | | -- Paste the MCP Server remote URL |
87 | | -- Save the agent configuration |
88 | | -
|
89 | | -Once added, the agent can invoke MongoDB operations through the MCP tool during reasoning. |
90 | | -
|
91 | | -### Step 4: Configure Agent for vector search |
92 | | -
|
93 | | -With the previous steps, users can perform database operations but cannot perform vector search since it requires embedding the user queries. |
94 | | -To configure the agent for vector search, follow these steps - |
95 | | -
|
96 | | -- In the Agent tools, add a new OpenAPI tool |
97 | | -- Paste the Swagger definition generated in Pre-requistes |
98 | | -- In the agent instructions, guide the agent to invoke this function in case of a vector search use-case. |
99 | | -- Save the agent |
100 | | -
|
101 | | -Once registered, the agent can invoke generateEmbeddings as part of its reasoning chain. |
102 | | -
|
103 | | -### Step 5: Test retrieval and responses |
| 111 | +## Test retrieval and responses |
104 | 112 |
|
105 | 113 | Run prompts that require: |
| 114 | + |
106 | 115 | - Semantic search over MongoDB data |
107 | 116 | - Aggregation queries |
108 | 117 | - Context-aware responses grounded in Atlas data |
109 | 118 |
|
110 | | -Successful responses confirm end-to-end connectivity between Foundry, MCP Server, and MongoDB Atlas. |
111 | | -
|
112 | | -## Architecture overview |
113 | | -
|
114 | | -At a high level, the integration includes: |
| 119 | +Successful responses confirm end-to-end connectivity between Foundry, the MCP Server, and MongoDB Atlas. |
115 | 120 |
|
116 | | -- Microsoft Foundry Agent – Orchestrates reasoning and tool usage |
117 | | -- MongoDB MCP Server – Exposes MongoDB Atlas operations (vector search, aggregation) as an agent tool |
118 | | -- MongoDB Atlas – Stores operational and vectorized data |
119 | | -- Azure hosting – Hosts the MCP server in Azure Container App |
| 121 | +## Next steps |
120 | 122 |
|
121 | | -For broader Foundry concepts, see the official Foundry documentation. |
| 123 | +- [MongoDB MCP Server](https://github.com/mongodb-js/mongodb-mcp-server) |
| 124 | +- [What is MongoDB Atlas?](overview.md) |
| 125 | +- [Manage MongoDB Atlas](manage.md) |
0 commit comments