Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

atlas-list-projects

Retrieve a list of MongoDB Atlas projects to manage and organize your database resources. Filter by organization ID or view all projects for comprehensive oversight.

Instructions

List MongoDB Atlas projects

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orgIdNoAtlas organization ID to filter projects. If not provided, projects for all orgs are returned.

Implementation Reference

  • Implements the core logic of the 'atlas-list-projects' tool: fetches organizations, retrieves projects (filtered by orgId if provided), formats and returns the list of projects with details like name, id, orgId, orgName, and created date.
    protected async execute({ orgId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> { const orgData = await this.session.apiClient.listOrgs(); if (!orgData?.results?.length) { return { content: [{ type: "text", text: "No organizations found in your MongoDB Atlas account." }], }; } const orgs: Record<string, string> = orgData.results .filter((org) => org.id) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion .reduce((acc, org) => ({ ...acc, [org.id!]: org.name }), {}); const data = orgId ? await this.session.apiClient.getOrgGroups({ params: { path: { orgId, }, }, }) : await this.session.apiClient.listGroups(); if (!data?.results?.length) { return { content: [{ type: "text", text: `No projects found in organization ${orgId}.` }], }; } const serializedProjects = JSON.stringify( data.results.map((project) => ({ name: project.name, id: project.id, orgId: project.orgId, orgName: orgs[project.orgId] ?? "N/A", created: project.created ? new Date(project.created).toLocaleString() : "N/A", })), null, 2 ); return { content: formatUntrustedData(`Found ${data.results.length} projects`, serializedProjects), }; }
  • Defines the input schema for the tool, with an optional 'orgId' parameter for filtering projects by organization.
    protected argsShape = { orgId: AtlasArgs.organizationId() .describe("Atlas organization ID to filter projects. If not provided, projects for all orgs are returned.") .optional(), };
  • Declares the ListProjectsTool class with the tool name 'atlas-list-projects', which is used during registration in the MCP server via generic tool registration in src/server.ts.
    export class ListProjectsTool extends AtlasToolBase { public name = "atlas-list-projects";
  • Re-exports ListProjectsTool for inclusion in the atlas tools module, which is then aggregated into AllTools for server registration.
    export { ListProjectsTool } from "./read/listProjects.js";
  • Aggregates all tools including AtlasTools (which includes ListProjectsTool) into AllTools array, used by the server for instantiating and registering all tools.
    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