-
Notifications
You must be signed in to change notification settings - Fork 157
chore: Add a new generic copilot-instructions.md to make copilot more useful on reviews #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Project Overview | ||
|
|
||
| This project is a server implementing the MCP (Model Context Protocol) that allows users to interact with their MongoDB clusters | ||
| and MongoDB Atlas accounts. It is built using TypeScript, Node.js and the official Anthropic | ||
| @modelcontextprotocol/sdk SDK. | ||
|
|
||
| ## Folder Structure | ||
|
|
||
| - `/src`: Contains the source code of the MCP Server. | ||
| - `/src/tools`: Contains the implementation of MCP tools. | ||
| - `/src/tools/atlas/`: Contains the implementation of MCP tools that are specific to MongoDB Atlas. | ||
| - `/src/tools/mongodb/`: Contains the implementation of MCP tools that are specific to MongoDB clusters. | ||
| - `/src/resources`: Contains the implementation of MCP Resources. | ||
| - `/tests`: Contains the test code for the MCP Server. | ||
| - `/tests/accuracy`: Contains the test code for the accuracy tests, that use different models to ensure that tools have reliable descriptions. | ||
| - `/tests/integration`: Contains tests that start the MCP Server and interact with it to ensure that functionality is correct. | ||
| - `/tests/unit`: Contains simple unit tests to cover specific functionality of the MCP Server. | ||
|
|
||
| ## Libraries and Frameworks | ||
|
|
||
| - Zod for message and schema validation. | ||
| - Express for the HTTP Transport implementation. | ||
| - mongosh NodeDriverServiceProvider for connecting to MongoDB. | ||
| - vitest for testing. | ||
| - @modelcontextprotocol/sdk for the protocol implementation. | ||
|
|
||
| ## 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 object 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. | ||
|
|
||
| ### Guidelines for All Tools | ||
|
|
||
| - The name of the tool should describe an action: `create-collection`, `insert-many`. | ||
| - 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 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. | ||
| - `connects`: Connects to a MongoDB cluster. | ||
| - If a new tool is added, or the tool description is modified, the accuracy tests MUST be updated too. | ||
|
|
||
| ### Guidelines for MongoDB Tools | ||
|
|
||
| - 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 `src/common/config.ts` in the `confirmationRequiredTools` list in the defaultUserConfig. | ||
kmruiz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Guidelines for Atlas Tools | ||
|
|
||
| - The tool category MUST be `atlas`. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.