Skip to content

MongoDB Toolkit fails with Firestore MongoDB-compatible endpoint due to unsupported authorizedCollections option #36609

@deepa-invisibl

Description

@deepa-invisibl

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

Reproduction Steps / Example Code (Python)

from langchain_mongodb.agent_toolkit import MongoDBDatabase, MongoDBDatabaseToolkit 
# Connection configuration 
MONGO_URI = "mongodb://<USERNAME>:<PASSWORD>@<PROJECT_ID>.us-central1.firestore.goog:443/?loadBalanced=true&tls=true&authMechanism=SCRAM-SHA-256&retryWrites=false" 
DB_NAME = "<DATABASE_NAME>" 
# Initialize MongoDB database 
db = MongoDBDatabase.from_connection_string( MONGO_URI, database=DB_NAME, ) 
# Initialize toolkit 
toolkit = MongoDBDatabaseToolkit( db=db, llm=llm, ) 
tools = toolkit.get_tools()

Error Message and Stack Trace (if applicable)

pymongo.errors.OperationFailure: authorizedCollections is not supported
full error: {
  'ok': 0.0,
  'errmsg': 'authorizedCollections is not supported',
  'code': 2,
  'codeName': 'InvalidArgument'
}

Description

Issue

MongoDB Toolkit fails when used with a Firestore MongoDB-compatible endpoint because the authorizedCollections option is not supported.

Description

When initializing MongoDBDatabase, LangChain internally executes a listCollections command via PyMongo. The MongoDB driver includes the option authorizedCollections=true.

Firestore's MongoDB-compatible endpoint rejects this option and returns the following error:

pymongo.errors.OperationFailure: authorizedCollections is not supported
full error: {
  'ok': 0.0,
  'errmsg': 'authorizedCollections is not supported',
  'code': 2,
  'codeName': 'InvalidArgument'
}

Because of this, MongoDBDatabase initialization fails and the MongoDB Toolkit cannot be used with the Firestore MongoDB-compatible endpoint.

Behavior Observed
The MongoDB Toolkit works correctly when connecting to a standard MongoDB instance.
When connecting to a Firestore MongoDB-compatible endpoint, initialization fails due to the unsupported authorizedCollections parameter.

What I Tested
Tested in a local environment -> same error
Deployed in Google Cloud Run -> same error

Since the error occurs in both environments, it appears to be related to compatibility with Firestore’s MongoDB-compatible layer rather than a networking issue.

Expected Behavior

One of the following would help:

  • MongoDB Toolkit should gracefully handle MongoDB-compatible endpoints that do not support authorizedCollections, or
  • Documentation should clarify that the MongoDB Toolkit only supports full MongoDB deployments.

Additional Context

Firestore provides a MongoDB-compatible API but does not implement the full MongoDB command set. I could not find documentation indicating whether LangChain MongoDB Toolkit supports this compatibility layer.

Environment

  • LangChain version: 1.2.15
  • langchain-mongodb version: 0.11.0
  • PyMongo version: 4.16.0
  • Python version: 3.13

Deployment:

Local machine
Google Cloud Run

Database:
Firestore MongoDB-compatible endpoint

System Info

System Information

OS: Linux
OS Version: #106~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 6 08:44:59 UTC
Python Version: 3.10.12 (main, Mar 3 2026, 11:56:32) [GCC 11.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featureexternallangchain`langchain` package issues & PRs

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions