home / mcp / mongodb mcp server

MongoDB MCP Server

Provides a read-only MCP server to query live MongoDB data via the CData JDBC Driver using natural language requests.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "cdatasoftware-mongodb-mcp-server-by-cdata": {
      "command": "java",
      "args": [
        "-jar",
        "/PATH/TO/CDataMCP-jar-with-dependencies.jar",
        "/PATH/TO/Salesforce.prp"
      ]
    }
  }
}

You can query live MongoDB data through a dedicated MCP server that wraps the CData JDBC Driver for MongoDB. This server exposes a simple MCP interface so you can ask natural-language questions and retrieve up-to-date information from your MongoDB collections without writing SQL. It runs locally in read-only mode, making it safe to integrate with AI clients that need live data.

How to use

You will connect an MCP client to the local server and start asking questions about your MongoDB data. The server exposes a small set of built-in tools that let you discover available tables, inspect columns, and run read-only queries. Typical usage patterns include asking for data overviews, filtering results, and joining insights across collections through SQL-like queries generated by the client. You don’t need to write SQL yourself; simply request the information you need and the client will use the exposed tools to retrieve it.

How to install

Prerequisites and initial steps ensure you have the right environment to run the MCP server locally.

# 1) Ensure you have Java and Maven installed
java -version
mvn -version

# 2) Clone the project and open the directory
git clone https://github.com/cdatasoftware/mongodb-mcp-server-by-cdata.git
cd mongodb-mcp-server-by-cdata

# 3) Build the MCP server jar with dependencies
mvn clean install
# This creates: CDataMCP-jar-with-dependencies.jar

Next, set up the CData JDBC Driver for MongoDB and prepare your connection.

# 4) Download and install the CData JDBC Driver for MongoDB
# URL: https://www.cdata.com/drivers/mongodb/download/jdbc

# 5) License the driver (examples; adjust paths to your setup)
# Windows:
#   java -jar C:\Program\ Files\CData\CData JDBC Driver for MongoDB\cdata.jdbc.mongodb.jar --license
# Mac/Linux:
#   java -jar /Applications/CData\ JDBC\ Driver\ for\ MongoDB/cdata.jdbc.mongodb.jar --license

# 6) Configure a connection string using the driver utility
# This step is performed interactively and may require OAuth authentication in a browser
java -jar cdata.jdbc.mongodb.jar

Additional setup details

Create a .prp file that defines your MCP data source connection. This example shows the required properties you fill in with your own values.

Prefix=mongodb
ServerName=CDataMongoDB
ServerVersion=1.0
DriverPath=PATH\TO\cdata.jdbc.mongodb.jar
DriverClass=cdata.jdbc.mongodb.MongoDBDriver
JdbcUrl=jdbc:mongodb:InitiateOAuth=GETANDREFRESH;
Tables=

Running the server locally

Start the MCP server using the Java runtime and the prepared .prp file. The server runs on stdio, so you launch it from the same machine as your client.

java -jar /PATH/TO/CDataMCP-jar-with-dependencies.jar /PATH/TO/mongodb.prp

Notes about usage with Claude Desktop or similar clients

Configure your client to load the MCP server by pointing to the local stdio server and the mongodb.prp file. After saving the configuration, refresh or restart the client so the MCP server appears in the available server list.

Troubleshooting

If you cannot see the MCP server in your client, ensure you have fully quit and re-launched the client after adding the new server configuration. If data retrieval fails, verify that the connection string is correct and that the MongoDB data source is accessible. If you still have issues, check license status for the CData JDBC Driver and consult the support channels for CData.

Tools & available actions

The server exposes built-in tools to interact with MongoDB data. These tools are designed to work without requiring you to write SQL directly.

Glossary of tools (names and purposes)

  • mongodb_get_tables - Retrieves a list of tables (collections) available in the data source. Output is CSV with headers on the first line.
  • mongodb_get_columns - Retrieves a list of columns (fields) for a given table. Output is CSV with headers on the first line.
  • mongodb_run_query - Executes a SQL SELECT-style query against the data source. Returns matching rows in a structured format.

Available tools

mongodb_get_tables

Retrieves a list of tables (data sources) available for access. The output is provided in CSV format with column headers, enabling you to discover the available data collections.

mongodb_get_columns

Fetches the list of columns for a specified table. The output is CSV with headers for easy parsing and display.

mongodb_run_query

Executes a SQL SELECT-like query against the configured data source to read data samples or filtered results.