Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

atlas-list-db-users

Read-only

Retrieve and display database users for a specific MongoDB Atlas project to manage access permissions and security settings.

Instructions

List MongoDB Atlas database users

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesAtlas project ID to filter DB users

Implementation Reference

  • The main handler function that fetches database users from MongoDB Atlas API for the specified project ID, processes the data, and returns a formatted result.
    protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
        const data = await this.session.apiClient.listDatabaseUsers({
            params: {
                path: {
                    groupId: projectId,
                },
            },
        });
    
        if (!data?.results?.length) {
            return {
                content: [{ type: "text", text: " No database users found" }],
            };
        }
    
        const users = data.results.map((user) => ({
            username: user.username,
            roles:
                user.roles?.map((role) => ({
                    roleName: role.roleName,
                    databaseName: role.databaseName,
                    collectionName: role.collectionName,
                })) ?? [],
            scopes:
                user.scopes?.map((scope) => ({
                    type: scope.type,
                    name: scope.name,
                })) ?? [],
        }));
    
        return {
            content: formatUntrustedData(
                `Found ${data.results.length} database users in project ${projectId}`,
                JSON.stringify(users)
            ),
        };
    }
  • Input schema definition using Zod for validating the projectId argument.
    export const ListDBUsersArgs = {
        projectId: AtlasArgs.projectId().describe("Atlas project ID to filter DB users"),
    };
    
    export class ListDBUsersTool extends AtlasToolBase {
        public name = "atlas-list-db-users";
        protected description = "List MongoDB Atlas database users";
        static operationType: OperationType = "read";
        protected argsShape = {
            ...ListDBUsersArgs,
        };
  • The tool class registration with name, description, operation type, and args shape used by the MCP framework to register and invoke the tool.
    export class ListDBUsersTool extends AtlasToolBase {
        public name = "atlas-list-db-users";
        protected description = "List MongoDB Atlas database users";
        static operationType: OperationType = "read";
  • Re-export of the tool class for aggregation in the atlas tools module.
    export { ListDBUsersTool } from "./read/listDBUsers.js";
  • Central registry where all tool classes, including AtlasTools containing ListDBUsersTool, are collected into AllTools array for use in MCP.
    export const AllTools: ToolClass[] = Object.values({
        ...MongoDbTools,
        ...AtlasTools,
        ...AtlasLocalTools,
    });
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, covering safety aspects. The description adds no behavioral context beyond the basic action, such as pagination, rate limits, or authentication needs. It doesn't contradict annotations but provides minimal additional value.

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's front-loaded and appropriately sized for a simple listing tool, with no wasted information.

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

Completeness3/5

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

Given the tool's simplicity (one parameter, read-only, no output schema), the description is adequate but minimal. It covers the basic action but lacks context about usage scenarios or output format, which could help an agent understand when and how to apply it 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?

Schema description coverage is 100%, with the single parameter 'projectId' fully documented in the schema. The description doesn't add any parameter semantics beyond what's in the schema, such as explaining why projectId is needed or how it affects results, meeting the baseline for high 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 verb ('List') and resource ('MongoDB Atlas database users'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'atlas-list-clusters' or 'atlas-list-projects' beyond specifying the resource type, missing explicit sibling distinction.

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. With sibling tools like 'atlas-list-clusters' and 'atlas-list-projects' available, there's no indication of context, prerequisites, or exclusions for selecting this specific listing tool.

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