Docs Menu
Docs Home
/

Build with AI

Give your LLM or agent context to leverage MongoDB features more effectively:

  • Work with the MongoDB MCP Server

Use the MongoDB MCP Server to access documentation and ask questions.

The MongoDB MCP Server includes tools to search MongoDB documentation using natural language:

  • list-knowledge-sources: Lists available MongoDB documentation sources and their versions. For example, manual, drivers, Atlas.

  • search-knowledge: Searches the MongoDB documentation knowledge base with a natural language query and returns relevant content chunks with links.

Example

Ask your AI agent:

"How do I create a compound index in MongoDB?"

The agent uses the search-knowledge tool to find relevant documentation and returns text excerpts with URLs to the full pages.

You can optionally filter searches by specific documentation sources or versions.

Interact with any page in MongoDB documentation as markdown to use as context for your LLM. You can copy a page as markdown using the documentation UI, or have your agent access the markdown directly from the page URL.

To copy a page as markdown using the documentation UI:

  1. Open the page in your browser.

  2. Press the Copy page button in the top right corner of the page.

You can then paste the markdown into a file for your agent to use or into a chat with your LLM.

To derive the markdown version of the page from the page URL:

  1. Remove the trailing slash from the end of the page URL.

  2. Append .md to the trimmed URL.

You can have your agent access the markdown directly from the resulting URL.

Example

The current documentation page URL is:

https://www.mongodb.com/docs/build-with-ai/

The markdown version of this page is available at:

https://www.mongodb.com/docs/build-with-ai.md

You can chat with the page directly from the documentation UI using our MongoDB AI Assistant. This feature is available on most pages in the documentation.

To chat with the page:

  1. Open the page in your browser.

  2. Press the button in the top right corner of the page next to the Copy page button.

  3. Select Ask a Question from the drop-down menu.

This opens a chat window where you can ask questions about the page. The LLM uses the page content as context to generate a response.

The MongoDB documentation provides an llms.txt file at:

https://www.mongodb.com/docs/llms.txt

This file contains a list of MongoDB documentation pages that are relevant to LLMs. You can use this file to provide your LLM with context about MongoDB concepts and use cases.

On this page