agentleFS
mongodb-jsmongodb-js/mongodb-mcp-server/.github/copilot-instructions.md

mongodb-mcp-server

Copilot instructions1.1k starsChanged 19 months agoApache-2.0View on GitHub

This project is a monorepo implementing the MCP (Model Context Protocol) server that lets users interact with their MongoDB clusters and MongoDB Atlas accounts. It is built using TypeScript, Node.js, pnpm workspaces, and the official @modelcontextprotocol v2 SDK packages (client, server, core, node). The server ships as the v3 API: a set of scoped @mongodb-js/mcp-* packages. The mongodb-mcp-server package is the binary CLI distribution (npx mongodb-mcp-server / MCPB) — library embedding uses the scoped packages. This project uses pnpm workspaces…

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 1 mentionFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 2 mentionsMay 2026: 0 mentionsJun 2026: 5 mentionsJul 2026: 1 mentionAug 2026: 1 mentionSep 2026: 5 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the mongodb-js/mongodb-mcp-server repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about mongodb-js/mongodb-mcp-server

The biggest 5 of 29 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 29

Talked about on GitHub (29 times).

On GitHub · 29

24 more on GitHub

The file

We split this copilot-instructions.md into the rules it gives an agent

10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Test packages: packages/integration-tests (start the server and interact with it), packages/accuracy-tests (accuracy tests that use …

    line 25
  2. Very specific:

    Always follow the eslint and prettier rule formats specified in eslint.config.js and .prettierrc.json.

    line 39
  3. Distinctive:

    Use classes for stateful components and functions for stateless pure logic.

    line 40
  4. Distinctive:

    Use dependency injection to provide dependencies between components.

    line 41
  5. Distinctive:

    Avoid using global variables as much as possible.

    line 42
  6. Very specific:

    All tools MUST provide a Zod schema (argsShape) that clearly specifies the API of the tool.

    line 60
  7. Distinctive:

    If a new tool is added, or the tool description is modified, the accuracy tests MUST be updated too.

    line 69
  8. Distinctive:

    Ensure there are proper timeout mechanisms to avoid long-running queries that can affect the server.

    line 77
  9. Very specific:

    If a tool requires elicitation, it must be added to the confirmationRequiredTools list in packages/cli/src/config/userConfig.ts (the …

    line 79
  10. Very specific:

    If a response field comes from the Atlas API, format it with formatUntrustedData before returning it to the client.

    line 86

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Project Overview

This project is a monorepo implementing the MCP (Model Context Protocol) server that lets users interact with their MongoDB clusters and MongoDB Atlas accounts. It is built using TypeScript, Node.js, pnpm workspaces, and the official @modelcontextprotocol v2 SDK packages (client, server, core, node).

The server ships as the v3 API: a set of scoped @mongodb-js/mcp-* packages. The mongodb-mcp-server package is the binary CLI distribution (npx mongodb-mcp-server / MCPB) — library embedding uses the scoped packages.

Folder Structure

This project uses pnpm workspaces (pnpm-workspace.yaml). The source of the server lives in packages/*:

  • packages/mongodb-mcp-server: The shipped CLI binary entrypoint and its scripts.
  • packages/cli: CLI wiring — runMcpCli, CliServer, Session, parseUserConfig, UserConfigSchema, applyConfigOverrides, create*FromConfig factories, Resources.
  • packages/core: Shared infrastructure — ToolBase/ToolClass, StdioRunner, InMemoryTransport, SessionStore, Keychain, Elicitation, NoopLogger, NoopTelemetry, McpServer re-export.
  • packages/http-runners: HTTP transport — StreamableHttpRunner, MCPHttpServer, MonitoringServer.
  • packages/tools-mongodb: MongoDB tools (MongoDBTools, MongoDBToolBase), connection management (MCPConnectionStore, MCPConnectionManager, ConnectionRegistry), ErrorCodes, MongoDBError.
  • packages/tools-atlas: Atlas Admin API tools (AtlasTools).
  • packages/tools-atlas-local: Atlas Local tools (AtlasLocalTools).
  • packages/tools-assistant: Assistant / knowledge tools (AssistantTools).
  • packages/atlas-api-client: Atlas API client (ApiClient, ClientCredentialsAuthProvider).
  • packages/atlas-telemetry: Telemetry pipeline (AtlasTelemetry).
  • packages/logging: Loggers (ConsoleLogger, DiskLogger, McpLogger).
  • packages/metrics: Metrics (PrometheusMetrics, createDefaultMetrics).
  • packages/types: Shared types (UserConfig, TransportRequestContext, ToolCategory, OperationType, ServerMetadata, McpSession, …).
  • packages/ui: MCP UI resources (UIRegistry).
  • Test packages: packages/integration-tests (start the server and interact with it), packages/accuracy-tests (accuracy tests that use different models to ensure tools have reliable descriptions), packages/eval-tests, packages/browser-tests, packages/test-utils.
  • packages/scripts: repo maintenance scripts (API report generation, tool argument/UI generation, release notes).

Libraries and Frameworks

  • Zod for message and schema validation.
  • Express for the HTTP Transport implementation.
  • mongosh NodeDriverServiceProvider for connecting to MongoDB.
  • vitest for testing (run per-package).
  • @modelcontextprotocol/server, @modelcontextprotocol/client, @modelcontextprotocol/core, and @modelcontextprotocol/node for the protocol implementation (v2 SDK).

Coding Standards

  • For declarations, use types. For usage, rely on type inference unless it is not clear enough.
  • Always follow the eslint and prettier rule formats specified in eslint.config.js and .prettierrc.json.
  • Use classes for stateful components and functions for stateless pure logic.
  • Use dependency injection to provide dependencies between components.
  • Avoid using global variables as much as possible.
  • New functionality MUST be under test.
    • Tools MUST HAVE integration tests.
    • Tools MUST HAVE unit tests.
    • Tools MAY HAVE accuracy tests.

Architectural Guidelines and Best Practices

Every agent connected to the MCP Server has a Session (per-session context, from @mongodb-js/mcp-cli; typed as McpSession) attached to it. The Session is the main entrypoint for dependencies to other components — any component that MUST be used by either a tool or a resource MUST be provided through the Session.

Note: MongoDB connection state lives at the app level, not in the Session — it lives in the ConnectionRegistry (from @mongodb-js/mcp-tools-mongodb, e.g. via MCPConnectionStore.view()), shared across sessions, and is addressed by the connectionId tool argument.

Guidelines for All Tools

Tools extend ToolBase from @mongodb-js/mcp-core and must conform to ToolClass (static toolName, category, operationType; description; zod argsShape; execute(); resolveTelemetryMetadata()).

  • The name of the tool should describe an action: create-collection, insert-many. It must be unique across the server.
  • The description MUST be a simple and accurate prompt that defines what the tool does in an unambiguous way.
  • All tools MUST provide a Zod schema (argsShape) that clearly specifies the API of the tool.
  • The Operation type MUST be clear:
    • metadata: Reads metadata for an entity (for example, a cluster). Example: CollectionSchema.
    • read: Reads information from a cluster or Atlas.
    • create: Creates resources, like a collection or a cluster.
    • delete: Deletes resources or documents, like collections, documents or clusters.
    • update: Modifies resources or documents, like collections, documents or clusters.
    • connect: Connects to a MongoDB cluster.
  • The tool category MUST be one of mongodb | atlas | atlas-local | assistant | custom (see per-category guidelines below).
  • If a new tool is added, or the tool description is modified, the accuracy tests MUST be updated too.

Guidelines for MongoDB Tools (packages/tools-mongodb)

  • The tool category MUST be mongodb.
  • They MUST call this.ensureConnected() before attempting to query MongoDB.
  • They MUST return content sanitized using formatUntrustedData.
  • Documents should be serialized with EJSON.stringify.
  • Ensure there are proper timeout mechanisms to avoid long-running queries that can affect the server.
  • Tools that require elicitation MUST implement getConfirmationMessage and provide an easy-to-understand message for a human running the operation.
    • If a tool requires elicitation, it must be added to the confirmationRequiredTools list in packages/cli/src/config/userConfig.ts (the defaultUserConfig).

Guidelines for Atlas Tools (packages/tools-atlas)

  • The tool category MUST be atlas.
  • They interact with the Atlas Admin API through ApiClient (from @mongodb-js/mcp-atlas-api-client), provided via the Session (session.apiClient).
  • Atlas tools that make slow paginated API calls should consider timeouts / limits appropriate for the server.
  • If a response field comes from the Atlas API, format it with formatUntrustedData before returning it to the client.

Guidelines for Assistant Tools (packages/tools-assistant)

  • The tool category MUST be assistant.

Custom Tools

  • A custom tool in a consumer embedding uses category custom (see MCP_SERVER_LIBRARY.md and the v1→v3 migration skill for the embedding API).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.