Skip to main content
Glama

MongoDB MCP Server

Official
by mongodb-js
roles.ts930 B
import type { UserConfig } from "../config.js"; import type { DatabaseUserRole } from "./openapi.js"; const readWriteRole: DatabaseUserRole = { roleName: "readWriteAnyDatabase", databaseName: "admin", }; const readOnlyRole: DatabaseUserRole = { roleName: "readAnyDatabase", databaseName: "admin", }; /** * Get the default role name for the database user based on the Atlas Admin API * https://www.mongodb.com/docs/atlas/mongodb-users-roles-and-privileges/ */ export function getDefaultRoleFromConfig(config: UserConfig): DatabaseUserRole { if (config.readOnly) { return readOnlyRole; } // If any of the write tools are enabled, use readWriteAnyDatabase if ( !config.disabledTools.includes("create") || !config.disabledTools.includes("update") || !config.disabledTools.includes("delete") ) { return readWriteRole; } return readOnlyRole; }

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