Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

atlas-list-db-users

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, });

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