Skip to main content
Glama
mongodb-developer

MongoDB Atlas MCP Server

Official

get_atlas_connection_strings

Retrieve connection strings for MongoDB Atlas clusters to establish database connectivity in applications.

Instructions

Retrieves connection strings for a cluster in an existing Atlas project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesThe ID of the Atlas project.
clusterNameYesThe name of the cluster.

Implementation Reference

  • The main handler function that retrieves the cluster details from the MongoDB Atlas API, enhances the connection strings by adding an appName parameter using a helper function, and returns the result in MCP format.
    private async getAtlasConnectionStrings(input: ConnectionStringsInput) {
      try {
        const url = `https://cloud.mongodb.com/api/atlas/v1.0/groups/${input.projectId}/clusters/${input.clusterName}`;
        const result = await this.makeAtlasRequest(url, 'GET');
        
        // Add appName to connection strings if they exist
        if (result.connectionStrings) {
          this.addAppNameToConnectionStrings(result);
        }
        
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: 'text',
            text: error.message
          }],
          isError: true
        };
      }
    }
  • TypeScript interface defining the expected input parameters for the getAtlasConnectionStrings handler.
    interface ConnectionStringsInput {
      projectId: string;
      clusterName: string;
    }
  • src/index.ts:460-477 (registration)
    Tool registration in the MCP listTools handler, defining the tool name, description, and input schema.
    {
      name: 'get_atlas_connection_strings',
      description: 'Retrieves connection strings for a cluster in an existing Atlas project.',
      inputSchema: {
        type: 'object',
        properties: {
          projectId: {
            type: 'string',
            description: 'The ID of the Atlas project.',
          },
          clusterName: {
            type: 'string',
            description: 'The name of the cluster.',
          },
        },
        required: ['projectId', 'clusterName'],
      },
    },
  • src/index.ts:558-560 (registration)
    Dispatch logic in the MCP callTool handler that invokes the getAtlasConnectionStrings method when the tool is called.
    case 'get_atlas_connection_strings':
      result = await this.getAtlasConnectionStrings(input as unknown as ConnectionStringsInput);
      break;
  • Supporting helper method that modifies Atlas cluster response connection strings by appending an appName query parameter for tracking.
    private addAppNameToConnectionStrings(result: any) {
      const appName = "devrel.integration.mcp-atlas";
      
      // Helper function to safely add appName parameter to a connection string
      const addAppNameParam = (connectionString: string): string => {
        if (!connectionString) return connectionString;
        
        // Add appName parameter
        return connectionString + (connectionString.includes('?') ? '&' : '?') + `appName=${appName}`;
      };
      
      // Handle single cluster object
      if (result.connectionStrings) {
        // Add appName to standard connection string
        if (result.connectionStrings.standard) {
          result.connectionStrings.standard = addAppNameParam(result.connectionStrings.standard);
        }
        
        // Add appName to standardSrv connection string
        if (result.connectionStrings.standardSrv) {
          result.connectionStrings.standardSrv = addAppNameParam(result.connectionStrings.standardSrv);
        }
        
        // Add appName to other connection string formats
        if (result.mongoURI) {
          result.mongoURI = addAppNameParam(result.mongoURI);
        }
        
        if (result.mongoURIWithOptions) {
          result.mongoURIWithOptions = addAppNameParam(result.mongoURIWithOptions);
        }
        
        if (result.srvAddress) {
          result.srvAddress = addAppNameParam(result.srvAddress);
        }
      }
      
      // Handle array of clusters (for listAtlasClusters)
      if (result.results && Array.isArray(result.results)) {
        result.results.forEach((cluster: any) => {
          if (cluster.connectionStrings) {
            this.addAppNameToConnectionStrings(cluster);
          }
        });
      }
      
      return result;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data, implying a read-only operation, but lacks details on authentication needs, rate limits, error conditions, or what the output format entails (e.g., types of connection strings). This leaves significant gaps in understanding how the tool behaves in practice.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that retrieves data. It does not explain what connection strings are returned (e.g., MongoDB URI formats, driver-specific strings) or any behavioral aspects like permissions or response structure, leaving the agent with insufficient context to use the tool effectively.

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?

The input schema has 100% description coverage, clearly documenting both parameters ('projectId' and 'clusterName'). The description adds no additional meaning beyond this, such as format examples or constraints, but the schema adequately covers the basics, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Retrieves') and resource ('connection strings for a cluster in an existing Atlas project'), making the purpose understandable. However, it does not explicitly differentiate from sibling tools like 'list_atlas_clusters' or 'setup_atlas_network_access' in terms of specific use cases or data returned, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, such as when to retrieve connection strings instead of listing clusters or setting up network access. It mentions 'existing Atlas project' but does not specify prerequisites or exclusions, leaving usage context vague.

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-developer/mcp-mongodb-atlas'

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