Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

connect

Read-only

Establish a new connection to a MongoDB instance and receive a connectionId for use with other MongoDB tools. Each call creates a separate, independent connection.

Instructions

Connect to a MongoDB instance and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time. A connection with the id "preconfigured" already exists for the connection string the server was configured with — there is no need to call this tool to use it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNameNoOptional short label for the connection (stored slugified with a short suffix, e.g. "staging" becomes staging-<suffix>). Shown in connection listings; helpful for telling multiple connections apart.
connectionStringYesMongoDB connection string (in the mongodb:// or mongodb+srv:// format)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds meaningful behavioral context beyond the annotations: each call spawns a new independent connection and multiple can be active simultaneously. It also discloses the existence of a preconfigured connection. This goes beyond the readOnlyHint and openWorldHint annotations, though it does not detail connection cleanup or failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: three sentences that front-load the primary purpose, then add behavioral details and the preconfigured exception. Every sentence contributes important information without unnecessary repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool, the presence of an output schema, and rich annotations, the description is largely complete. It explains the key behavior and the preconfigured shortcut. A minor gap is that it does not mention when to use disconnect or how connection IDs should be managed, but this is not essential for selecting the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description does not add much parameter-specific meaning beyond the schema: connectionString is merely implied as the MongoDB URI, and connectionName is not mentioned in the description at all. The schema already provides adequate descriptions for both parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: connecting to a MongoDB instance and returning a connectionId for use with other MongoDB tools. It distinguishes this from siblings like list-connections and disconnect by focusing on the act of establishing a connection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly notes that a preconfigured connection exists and that there is no need to call this tool in that case, which serves as a when-not-to-use guideline. It also explains that each call creates an independent connection, implying use when a new, separate connection is desired. However, it does not discuss alternatives like atlas-connect-cluster or mention when to prefer those.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mongodb-js/mongodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server