diff --git a/be/cmake/thirdparty.cmake b/be/cmake/thirdparty.cmake
index 6fddbea795bae7..fb09947e262e89 100644
--- a/be/cmake/thirdparty.cmake
+++ b/be/cmake/thirdparty.cmake
@@ -201,3 +201,24 @@ add_thirdparty(icudata LIB64)
add_thirdparty(pugixml LIB64)
+
+# Prepare explicit targets without enabling a reader or requiring new prebuilt libraries yet.
+# For example, existing BE targets keep working until a MongoDB reader links mongoc2/bson2.
+add_thirdparty(bson2 LIB64 NOTADD)
+set_target_properties(bson2 PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/include/bson-2.0"
+ INTERFACE_COMPILE_DEFINITIONS BSON_STATIC)
+add_thirdparty(mongoc2 LIB64 NOTADD)
+set_target_properties(mongoc2 PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/include/mongoc-2.0"
+ INTERFACE_COMPILE_DEFINITIONS MONGOC_STATIC)
+# Threads and the platform DNS resolver are OS/toolchain components, not vendored libraries.
+find_package(Threads REQUIRED)
+target_link_libraries(mongoc2 INTERFACE
+ bson2 snappy zstd libz cyrus-sasl gssapi_krb5 krb5 k5crypto com_err krb5support
+ openssl crypto Threads::Threads ${CMAKE_DL_LIBS})
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ target_link_libraries(mongoc2 INTERFACE m resolv)
+elseif(OS_MACOSX)
+ target_link_libraries(mongoc2 INTERFACE resolv)
+endif()
diff --git a/build.sh b/build.sh
index 5615b1423b50be..279a6f0ad2ca69 100755
--- a/build.sh
+++ b/build.sh
@@ -838,6 +838,8 @@ if [[ "${BUILD_FE}" -eq 1 ]]; then
fi
done
unset _conn_mod
+ # Build the dependency bundle before the native connector provider is implemented.
+ modules+=("fe-connector/fe-connector-mongodb")
# Authorization plugin modules (loaded at runtime from plugins/authorization/). Keep this list
# identical to the deploy loop's (search AUTHZ_PLUGIN_DIR), for the same reason as the connectors:
# the deploy step unzips whatever archive is left in the module's target/, so a module built here
@@ -1348,6 +1350,10 @@ if [[ "${BUILD_FE}" -eq 1 ]]; then
# Deploy connector provider plugins as independent plugin directories.
# Each sub-directory is one connector backend loaded at runtime by ConnectorPluginManager.
CONN_PLUGIN_DIR="${DORIS_OUTPUT}/fe/plugins/connector"
+ # Keep this dependency-only archive out of auto-discovery, which requires a provider class.
+ mkdir -p "${CONN_PLUGIN_DIR}"
+ cp -p "${DORIS_HOME}/fe/fe-connector/fe-connector-mongodb/target/doris-fe-connector-mongodb.zip" \
+ "${CONN_PLUGIN_DIR}/mongodb.zip"
for conn_module in es jdbc maxcompute trino hms hive paimon hudi iceberg adbc fluss; do
conn_plugin_target="${CONN_PLUGIN_DIR}/${conn_module}"
conn_module_dir="${DORIS_HOME}/fe/fe-connector/fe-connector-${conn_module}"
diff --git a/dist/LICENSE-dist.txt b/dist/LICENSE-dist.txt
index 82e932999bc978..153c799845d4d4 100644
--- a/dist/LICENSE-dist.txt
+++ b/dist/LICENSE-dist.txt
@@ -1515,3 +1515,8 @@ Other dependencies:
* pugixml 1.15 -- licenses/LICENSE-pugixml.txt
* darts-clone (double-array trie, compiled into the kuromoji dictionary) -- licenses/LICENSE-darts-clone.txt
* mecab-ipadic (IPADIC) 2.7.0-20250920 (Japanese dictionary data shipped under be/dict/kuromoji) -- licenses/LICENSE-ipadic.txt
+
+ * MongoDB C Driver (libmongoc/libbson): 2.5.8 -- Apache License 2.0; bundled notices in licenses/LICENSE-mongo-c-driver.txt
+ * MongoDB Java Sync Driver (sync/core/bson/bson-record-codec): 5.14.0 -- Apache License 2.0
+ * snappy-java (MongoDB bundle): 1.1.10.10 -- Apache License 2.0
+ * zstd-jni (MongoDB bundle): 1.5.7-25 -- licenses/LICENSE-zstd-jni.txt
diff --git a/dist/licenses/LICENSE-mongo-c-driver.txt b/dist/licenses/LICENSE-mongo-c-driver.txt
new file mode 100644
index 00000000000000..dbab9f4dc0ef32
--- /dev/null
+++ b/dist/licenses/LICENSE-mongo-c-driver.txt
@@ -0,0 +1,184 @@
+The MongoDB C Driver uses third-party code distributed under different licenses.
+
+License notice for uthash
+-------------------------------------------------------------------------------
+
+Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.com/uthash/
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+License notice for common-b64.c
+-------------------------------------------------------------------------------
+
+ISC License
+
+Copyright: 1996, 1998 Internet Software Consortium
+ 1995 International Business Machines, Inc.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+Portions Copyright (c) 1995 by International Business Machines, Inc.
+
+International Business Machines, Inc. (hereinafter called IBM) grants
+permission under its copyrights to use, copy, modify, and distribute this
+Software with or without fee, provided that the above copyright notice and
+all paragraphs of this notice appear in all copies, and that the name of IBM
+not be used in connection with the marketing of any product incorporating
+the Software or modifications thereof, without specific, written prior
+permission.
+
+To the extent it has a right to do so, IBM grants an immunity from suit
+under its patents, if any, for the use, sale or manufacture of products to
+the extent that such products are used for performing Domain Name System
+dynamic updates in TCP/IP networks by means of the Software. No immunity is
+granted for any product per se or for any other function of any product.
+
+THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+License notice for mongoc.css_t
+-------------------------------------------------------------------------------
+
+MIT License
+
+Portions Copyright 2013 by Ignacy Sokolowski.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+License notice for zlib
+-------------------------------------------------------------------------------
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+ version 1.2.11, January 15th, 2017
+
+ Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ jloup@gzip.org madler@alumni.caltech.edu
+
+
+ The data format used by the zlib library is described by RFCs (Request for
+ Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+ (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
+*/
+
+License notice for common-md5.c
+-------------------------------------------------------------------------------
+
+ZLib License
+
+Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+L. Peter Deutsch
+ghost@aladdin.com
+
+License notice for utf8proc
+-------------------------------------------------------------------------------
+
+**utf8proc** is a software package originally developed
+by Jan Behrens and the rest of the Public Software Group, who
+deserve nearly all of the credit for this library, that is now maintained by the Julia-language developers. Like the original utf8proc,
+whose copyright and license statements are reproduced below, all new
+work on the utf8proc library is licensed under the [MIT "expat"
+license](http://opensource.org/licenses/MIT):
+
+*Copyright © 2014-2021 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.*
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/fe/fe-connector/fe-connector-mongodb/README.md b/fe/fe-connector/fe-connector-mongodb/README.md
new file mode 100644
index 00000000000000..47d7064cb95567
--- /dev/null
+++ b/fe/fe-connector/fe-connector-mongodb/README.md
@@ -0,0 +1,28 @@
+# Native MongoDB client dependencies
+
+This module prepares the Java dependencies for the native MongoDB connector. It
+bundles the official synchronous driver, its core, BSON, and BSON record codec
+at one version, using a module-local BOM so other connector plugins keep their
+own dependencies. The archive also carries the Snappy and Zstandard Java providers
+so FE metadata reads accept the same compression URI options as the native BE.
+The FE host supplies logging APIs and bindings.
+
+The dependency-only archive does not register a `ConnectorProvider` and cannot
+create a MongoDB catalog. The FE build stages it as
+`plugins/connector/mongodb.zip`, without unpacking it into an auto-loaded plugin
+directory. A later connector implementation will add the provider and enable the
+normal plugin deployment path.
+
+The BE uses the MongoDB C Driver (`libmongoc` and `libbson`) built together by:
+
+```sh
+bash thirdparty/build-thirdparty.sh mongo_c_driver
+```
+
+The native build produces PIC static archives with OpenSSL, Cyrus SASL, SRV DNS,
+Snappy, zstd and zlib support. It reuses Doris-managed dependencies and the driver's
+bundled utf8proc for SCRAM-SHA-256. It does not require the C++ driver, a BE JVM,
+Reactive Streams, or client-side encryption libraries. The reader and BSON
+`DataTypeSerDe` implementation are separate changes. The BE CMake targets `bson2`
+and `mongoc2` expose the static headers, definitions and dependency closure; they
+are not added to the common BE link set until a reader consumes them.
diff --git a/fe/fe-connector/fe-connector-mongodb/pom.xml b/fe/fe-connector/fe-connector-mongodb/pom.xml
new file mode 100644
index 00000000000000..d98638186a11e2
--- /dev/null
+++ b/fe/fe-connector/fe-connector-mongodb/pom.xml
@@ -0,0 +1,92 @@
+
+
+
+ 4.0.0
+
+ org.apache.doris
+ fe-connector
+ ${revision}
+ ../pom.xml
+
+ fe-connector-mongodb
+ jar
+ Doris FE Connector - MongoDB Dependencies
+ Client dependency bundle for the native MongoDB connector.
+
+ 5.14.0
+
+ 1.1.10.10
+ 1.5.7-25
+
+
+
+
+
+ org.mongodb
+ mongodb-driver-bom
+ ${mongodb.driver.version}
+ pom
+ import
+
+
+
+
+
+ org.mongodb
+ mongodb-driver-sync
+
+
+
+ org.xerial.snappy
+ snappy-java
+ ${mongodb.snappy-java.version}
+ runtime
+
+
+ com.github.luben
+ zstd-jni
+ ${mongodb.zstd-jni.version}
+ runtime
+
+
+
+ doris-fe-connector-mongodb
+
+
+ maven-assembly-plugin
+
+ false
+
+ src/main/assembly/plugin-zip.xml
+
+
+
+
+ make-assembly
+ package
+ single
+
+
+
+
+
+
diff --git a/fe/fe-connector/fe-connector-mongodb/src/main/assembly/plugin-zip.xml b/fe/fe-connector/fe-connector-mongodb/src/main/assembly/plugin-zip.xml
new file mode 100644
index 00000000000000..9fc745f112632d
--- /dev/null
+++ b/fe/fe-connector/fe-connector-mongodb/src/main/assembly/plugin-zip.xml
@@ -0,0 +1,48 @@
+
+
+
+ plugin
+ zip
+ false
+
+
+ ${project.build.directory}/${project.build.finalName}.jar
+ /
+
+
+ README.md
+ /
+
+
+
+
+ /lib
+ false
+ runtime
+
+
+ org.apache.logging.log4j:*
+ org.slf4j:*
+
+
+
+
diff --git a/fe/fe-connector/pom.xml b/fe/fe-connector/pom.xml
index a5555398e7ed18..270bfd30e2a813 100644
--- a/fe/fe-connector/pom.xml
+++ b/fe/fe-connector/pom.xml
@@ -69,6 +69,7 @@ under the License.
fe-connector-metastore-iceberg
fe-connector-metastore-hms
fe-connector-es
+ fe-connector-mongodb
fe-connector-trino
fe-connector-maxcompute
fe-connector-jdbc
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index c751afc94911d4..22f5b9ee737446 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -1034,6 +1034,40 @@ build_cyrus_sasl() {
fi
}
+# MongoDB C Driver: keep libbson and libmongoc at the same release and ABI.
+build_mongo_c_driver() {
+ check_if_source_exist "${MONGO_C_DRIVER_SOURCE}"
+ cd "${TP_SOURCE_DIR}/${MONGO_C_DRIVER_SOURCE}"
+ rm -rf "${BUILD_DIR}"
+ mkdir -p "${BUILD_DIR}"
+ cd "${BUILD_DIR}"
+
+ # Re-root relocatable pkg-config files from prebuilt archives, and exclude host packages.
+ PKG_CONFIG_PATH="${TP_LIB_DIR}/pkgconfig" \
+ PKG_CONFIG_LIBDIR="${TP_LIB_DIR}/pkgconfig" \
+ "${CMAKE_CMD}" -G "${GENERATOR}" \
+ -DCMAKE_INSTALL_PREFIX="${TP_INSTALL_DIR}" \
+ -C "${TP_DIR}/cmake/mongo-c-driver-cache.cmake" \
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DCMAKE_INSTALL_LIBDIR=lib64 \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+ -DPKG_CONFIG_ARGN="--define-variable=prefix=${TP_INSTALL_DIR}" \
+ -DENABLE_STATIC=ON -DENABLE_SHARED=OFF -DENABLE_PIC=ON \
+ -DENABLE_TESTS=OFF -DENABLE_EXAMPLES=OFF \
+ -DENABLE_MAN_PAGES=OFF -DENABLE_HTML_DOCS=OFF -DENABLE_UNINSTALL=OFF \
+ -DENABLE_SSL=OPENSSL -DENABLE_SASL=CYRUS -DENABLE_SRV=ON \
+ -DENABLE_SNAPPY=ON -DENABLE_ZSTD=ON -DENABLE_ZLIB=SYSTEM \
+ -DUSE_BUNDLED_UTF8PROC=ON \
+ -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF -DENABLE_MONGODB_AWS_AUTH=OFF \
+ -DENABLE_SHM_COUNTERS=OFF -DENABLE_MAINTAINER_FLAGS=OFF \
+ -DBSON_INSTALL_INCLUDEDIR=include/bson-2.0 \
+ -DMONGOC_INSTALL_INCLUDEDIR=include/mongoc-2.0 ..
+ "${CMAKE_CMD}" --build . --parallel "${PARALLEL}"
+ "${CMAKE_CMD}" --install .
+ strip_lib libbson2.a
+ strip_lib libmongoc2.a
+}
+
# librdkafka
build_librdkafka() {
check_if_source_exist "${LIBRDKAFKA_SOURCE}"
@@ -2695,6 +2729,7 @@ if [[ "${#packages[@]}" -eq 0 ]]; then
rocksdb
krb5 # before cyrus_sasl
cyrus_sasl
+ mongo_c_driver # after OpenSSL, zlib, zstd, Snappy and Cyrus SASL
librdkafka
flatbuffers
orc
@@ -2793,6 +2828,7 @@ cleanup_package_source() {
brpc) src_var="BRPC_SOURCE" ;;
rocksdb) src_var="ROCKSDB_SOURCE" ;;
cyrus_sasl) src_var="CYRUS_SASL_SOURCE" ;;
+ mongo_c_driver) src_var="MONGO_C_DRIVER_SOURCE" ;;
librdkafka) src_var="LIBRDKAFKA_SOURCE" ;;
flatbuffers) src_var="FLATBUFFERS_SOURCE" ;;
arrow) src_var="ARROW_SOURCE" ;;
diff --git a/thirdparty/cmake/mongo-c-driver-cache.cmake b/thirdparty/cmake/mongo-c-driver-cache.cmake
new file mode 100644
index 00000000000000..7ee795b7839d9a
--- /dev/null
+++ b/thirdparty/cmake/mongo-c-driver-cache.cmake
@@ -0,0 +1,44 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This initial cache is loaded after -DCMAKE_INSTALL_PREFIX and before upstream configuration.
+# Upstream find modules reuse these forced values instead of resolving host libraries or stale caches.
+function(doris_mongo_include cache_key header)
+ find_path(DORIS_MONGO_INCLUDE NAMES "${header}"
+ PATHS "${CMAKE_INSTALL_PREFIX}/include"
+ NO_DEFAULT_PATH NO_CACHE REQUIRED)
+ set(${cache_key} "${DORIS_MONGO_INCLUDE}" CACHE PATH "Doris MongoDB dependency" FORCE)
+endfunction()
+
+function(doris_mongo_library cache_key archive)
+ find_library(DORIS_MONGO_LIBRARY NAMES "${archive}"
+ PATHS "${CMAKE_INSTALL_PREFIX}/lib64" "${CMAKE_INSTALL_PREFIX}/lib"
+ NO_DEFAULT_PATH NO_CACHE REQUIRED)
+ set(${cache_key} "${DORIS_MONGO_LIBRARY}" CACHE FILEPATH "Doris MongoDB dependency" FORCE)
+endfunction()
+
+doris_mongo_include(OPENSSL_INCLUDE_DIR openssl/ssl.h)
+doris_mongo_library(OPENSSL_SSL_LIBRARY libssl.a)
+doris_mongo_library(OPENSSL_CRYPTO_LIBRARY libcrypto.a)
+doris_mongo_include(SASL2_INCLUDE_DIR sasl/sasl.h)
+doris_mongo_library(SASL2_LIBRARY libsasl2.a)
+doris_mongo_include(SNAPPY_INCLUDE_DIRS snappy-c.h)
+doris_mongo_library(SNAPPY_LIBRARIES libsnappy.a)
+doris_mongo_include(ZLIB_INCLUDE_DIR zlib.h)
+doris_mongo_library(ZLIB_LIBRARY libz.a)
+doris_mongo_include(DORIS_MONGO_ZSTD_INCLUDE_DIR zstd.h)
+doris_mongo_library(pkgcfg_lib_ZSTD_zstd libzstd.a)
diff --git a/thirdparty/vars.sh b/thirdparty/vars.sh
index 76c00f8c2506f8..d402827e6ccf95 100644
--- a/thirdparty/vars.sh
+++ b/thirdparty/vars.sh
@@ -228,6 +228,13 @@ LIBRDKAFKA_NAME=librdkafka-2.16.0.tar.gz
LIBRDKAFKA_SOURCE=librdkafka-2.16.0
LIBRDKAFKA_MD5SUM="6d2c62921241863d2bc95c58be27af6f"
+# MongoDB C Driver (libmongoc and libbson are released and built together).
+# 2.5.8 fixes malformed cursor namespaces and compressed-reply buffer leaks.
+MONGO_C_DRIVER_DOWNLOAD="https://github.com/mongodb/mongo-c-driver/releases/download/2.5.8/mongo-c-driver-2.5.8.tar.gz"
+MONGO_C_DRIVER_NAME=mongo-c-driver-2.5.8.tar.gz
+MONGO_C_DRIVER_SOURCE=mongo-c-driver-2.5.8
+MONGO_C_DRIVER_MD5SUM="e088246c56b3de5c658aff8e00f166ed"
+
# zstd
ZSTD_DOWNLOAD="https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz"
ZSTD_NAME=zstd-1.5.7.tar.gz
@@ -660,6 +667,7 @@ export TP_ARCHIVES=(
'BRPC'
'ROCKSDB'
'CYRUS_SASL'
+ 'MONGO_C_DRIVER'
'LIBRDKAFKA'
'FLATBUFFERS'
'ARROW'