Skip to content

Commit fc8b987

Browse files
committed
ci: add eslint
1 parent 19821c2 commit fc8b987

File tree

9 files changed

+2751
-94
lines changed

9 files changed

+2751
-94
lines changed

.github/workflows/code_health.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,20 @@ jobs:
5555
shell: bash
5656
run: |
5757
echo "The following files are not formatted:"
58-
echo "${{steps.prettier-run.outputs.prettier_output}}"
58+
echo "${{steps.prettier-run.outputs.prettier_output}}"
59+
eslint:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
63+
with:
64+
config: ${{ vars.PERMISSIONS_CONFIG }}
65+
- name: Checkout Repository
66+
uses: actions/checkout@v4
67+
- uses: actions/setup-node@v4
68+
with:
69+
node-version-file: package.json
70+
- name: install dependencies
71+
run: |
72+
npm ci
73+
- run: |
74+
npm run lint

CONTRIBUTING.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Contributing to MongoDB MCP Server
2+
3+
Thank you for your interest in contributing to the MongoDB MCP Server project! This document provides guidelines and instructions for contributing.
4+
5+
## Project Overview
6+
7+
This project implements a Model Context Protocol (MCP) server for MongoDB and MongoDB Atlas, enabling AI assistants to interact with MongoDB Atlas resources through natural language.
8+
9+
## Development Setup
10+
11+
### Prerequisites
12+
13+
- Node.js (v23 or later)
14+
- npm
15+
16+
### Getting Started
17+
18+
1. Clone the repository:
19+
```
20+
git clone https://github.com/mongodb-labs/mongodb-mcp-server.git
21+
cd mongodb-mcp-server
22+
```
23+
24+
2. Install dependencies:
25+
```
26+
npm install
27+
```
28+
29+
3. Add the mcp server to your IDE of choice
30+
```json
31+
{
32+
"mcpServers": {
33+
"MongoDB": {
34+
"command": "/path/to/mongodb-mcp-server/dist/index.js"
35+
}
36+
}
37+
}
38+
```
39+
40+
## Code Contribution Workflow
41+
42+
1. Create a new branch for your feature or bugfix:
43+
```
44+
git checkout -b feature/your-feature-name
45+
```
46+
47+
2. Make your changes, following the code style of the project
48+
49+
3. Run the inspector and double check your changes:
50+
```
51+
npm run inspect
52+
```
53+
54+
4. Commit your changes with a descriptive commit message
55+
56+
## Pull Request Guidelines
57+
58+
1. Update documentation if necessary
59+
2. Ensure your PR includes only relevant changes
60+
3. Link any related issues in your PR description
61+
4. Keep PRs focused on a single topic
62+
63+
## Code Standards
64+
65+
- Use TypeScript for all new code
66+
- Follow the existing code style (indentation, naming conventions, etc.)
67+
- Comment your code when necessary, especially for complex logic
68+
- Use meaningful variable and function names
69+
70+
## Reporting Issues
71+
72+
When reporting issues, please include:
73+
74+
- A clear description of the problem
75+
- Steps to reproduce
76+
- Expected vs. actual behavior
77+
- Version information
78+
- Environment details
79+
80+
## Adding New Tools
81+
82+
When adding new tools to the MCP server:
83+
84+
1. Follow the existing pattern in `server.ts`
85+
2. Define clear parameter schemas using Zod
86+
3. Implement thorough error handling
87+
4. Add proper documentation for the tool
88+
5. Include examples of how to use the tool
89+
90+
## License
91+
92+
By contributing to this project, you agree that your contributions will be licensed under the project's license.
93+
94+
## Questions?
95+
96+
If you have any questions or need help, please open an issue or reach out to the maintainers.

dist/client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class ApiClient {
112112
throw new ApiClientError("Device code expired. Please restart the authentication process.", response);
113113
}
114114
}
115-
catch (error) {
115+
catch {
116116
throw new ApiClientError("Failed to retrieve token. Please check your device code.", response);
117117
}
118118
}
@@ -182,7 +182,7 @@ export class ApiClient {
182182
const expiryWithDelta = new Date(token.expiry.getTime() - expiryDelta);
183183
return expiryWithDelta.getTime() > Date.now();
184184
}
185-
catch (error) {
185+
catch {
186186
return false;
187187
}
188188
}
@@ -194,7 +194,7 @@ export class ApiClient {
194194
await this.refreshToken(token);
195195
return true;
196196
}
197-
catch (error) {
197+
catch {
198198
return false;
199199
}
200200
}

dist/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class Server {
4343
await this.apiClient.retrieveToken(this.state.auth.code.device_code);
4444
return !!this.state.auth.token;
4545
}
46-
catch (error) {
46+
catch {
4747
return false;
4848
}
4949
case "issued":
@@ -178,7 +178,7 @@ export class Server {
178178
const header = `Project Name | Project ID | Created At
179179
----------------|----------------|----------------`;
180180
const rows = projects
181-
.map((project) => {
181+
.map(project => {
182182
const createdAt = project.created ? new Date(project.created.$date).toLocaleString() : "N/A";
183183
return `${project.name} | ${project.id} | ${createdAt}`;
184184
})
@@ -217,7 +217,7 @@ export class Server {
217217
name: "MongoDB Atlas",
218218
version: process.env.VERSION || "1.0.0",
219219
});
220-
server.tool("auth", "Authenticate to Atlas", async ({}) => this.authTool());
220+
server.tool("auth", "Authenticate to Atlas", async () => this.authTool());
221221
let projectIdFilter = z.string().describe("Optional Atlas project ID to filter clusters");
222222
if (config.projectID) {
223223
projectIdFilter = projectIdFilter.optional();

eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from "eslint/config";
2+
import js from "@eslint/js";
3+
import globals from "globals";
4+
import tseslint from "typescript-eslint";
5+
6+
export default defineConfig([
7+
{ files: ["src/**/*.ts"], plugins: { js }, extends: ["js/recommended"] },
8+
{ files: ["src/**/*.ts"], languageOptions: { globals: globals.node } },
9+
tseslint.configs.recommended,
10+
]);

0 commit comments

Comments
 (0)