continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.42k stars 1.68k forks source link

Support for MongoDb for Database Context Provider #2559

Open abhinit21 opened 1 month ago

abhinit21 commented 1 month ago

Validations

Problem

Description:

Currently, the database context provider supports Sqlite, Postgres, and MySQL databases. To enhance its versatility and accommodate a wider range of use cases, it is proposed to add support for MongoDB.

Solution

Proposed Changes:

  1. Extend the connection_type enum:

    • Add the mongodb option to the connection_type enum.
  2. Define MongoDB-specific connection parameters:

    • Introduce the following parameters within the mongodb connection object:
      • host (string): The hostname or IP address of the MongoDB server.
      • port (number): The port number on which the MongoDB server is listening.
      • username (string): The username for authentication.
      • password (string): The password for authentication.
      • database (string): The name of the database to connect to.
      • authSource (string): The name of the authentication database (optional).
      • replicaSet (string): The name of the replica set (optional).
      • ssl (boolean): Whether to enable SSL/TLS encryption (optional).
  3. Implement MongoDB connection logic:

    • Utilize a suitable MongoDB driver (e.g., pymongo) to establish a connection using the provided parameters.
    • Handle authentication, replica set configuration, and SSL/TLS settings as needed.

Example Configuration:

{
  "contextProviders": [
    {
      "name": "database",
      "params": {
        "connections": [
          {
            "name": "exampleMongoDB",
            "connection_type": "mongodb",
            "connection": {
              "host": "mongodb://localhost:27017",
              "username": "yourUsername",
              "password": "yourPassword",
              "database": "exampleDB"
            }
          }
        ]
      }
    }
  ]
}

Benefits:

malaki12003 commented 1 month ago

@sestinj @Patrick-Erichsen FYI, I just picked up this task.

abhinit21 commented 1 month ago

Hey @malaki12003 I'd like to help with this issue. I'm new to open source, so any guidance or a pointer to the PR would be appreciated. Thanks!