Skip to content

Commit eb85e72

Browse files
committed
ci: add eslint
1 parent 88b7fea commit eb85e72

File tree

9 files changed

+1743
-102
lines changed

9 files changed

+1743
-102
lines changed

.github/workflows/code_health.yaml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,47 @@ jobs:
3737
exit 1
3838
fi
3939
prettier:
40-
name: Prettier Check
4140
runs-on: ubuntu-latest
4241
steps:
4342
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4443
with:
4544
config: ${{ vars.PERMISSIONS_CONFIG }}
4645
- name: Checkout Repository
4746
uses: actions/checkout@v2
48-
- name: Run Prettier
49-
id: prettier-run
50-
uses: rutajdash/prettier-cli-action@d42c4325a3b344f3bd4be482bc34de521998d557
47+
- uses: actions/setup-node@v4
5148
with:
52-
config_path: ./.prettierrc.yml
53-
- name: Prettier Output
54-
if: ${{ failure() }}
55-
shell: bash
49+
node-version-file: package.json
50+
- name: install dependencies
51+
run: |
52+
npm ci
53+
- run: |
54+
npm run reformat
55+
- name: Check for uncommitted files
5656
run: |
57-
echo "The following files are not formatted:"
58-
echo "${{steps.prettier-run.outputs.prettier_output}}"
57+
export FILES=
58+
FILES=$(git ls-files -o -m --directory --exclude-standard --no-empty-directory)
59+
export LINES=
60+
LINES=$(echo "$FILES" | awk 'NF' | wc -l)
61+
if [ "$LINES" -ne 0 ]; then
62+
echo "Detected files that need to be committed:"
63+
echo "${FILES}"
64+
echo ""
65+
echo "Try running: npm run reformat"
66+
exit 1
67+
fi
68+
eslint:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
72+
with:
73+
config: ${{ vars.PERMISSIONS_CONFIG }}
74+
- name: Checkout Repository
75+
uses: actions/checkout@v4
76+
- uses: actions/setup-node@v4
77+
with:
78+
node-version-file: package.json
79+
- name: install dependencies
80+
run: |
81+
npm ci
82+
- run: |
83+
npm run lint

CONTRIBUTING.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
```
21+
git clone https://github.com/mongodb-labs/mongodb-mcp-server.git
22+
cd mongodb-mcp-server
23+
```
24+
25+
2. Install dependencies:
26+
27+
```
28+
npm install
29+
```
30+
31+
3. Add the mcp server to your IDE of choice
32+
```json
33+
{
34+
"mcpServers": {
35+
"MongoDB": {
36+
"command": "/path/to/mongodb-mcp-server/dist/index.js"
37+
}
38+
}
39+
}
40+
```
41+
42+
## Code Contribution Workflow
43+
44+
1. Create a new branch for your feature or bugfix:
45+
46+
```
47+
git checkout -b feature/your-feature-name
48+
```
49+
50+
2. Make your changes, following the code style of the project
51+
52+
3. Run the inspector and double check your changes:
53+
54+
```
55+
npm run inspect
56+
```
57+
58+
4. Commit your changes with a descriptive commit message
59+
60+
## Pull Request Guidelines
61+
62+
1. Update documentation if necessary
63+
2. Ensure your PR includes only relevant changes
64+
3. Link any related issues in your PR description
65+
4. Keep PRs focused on a single topic
66+
67+
## Code Standards
68+
69+
- Use TypeScript for all new code
70+
- Follow the existing code style (indentation, naming conventions, etc.)
71+
- Comment your code when necessary, especially for complex logic
72+
- Use meaningful variable and function names
73+
74+
## Reporting Issues
75+
76+
When reporting issues, please include:
77+
78+
- A clear description of the problem
79+
- Steps to reproduce
80+
- Expected vs. actual behavior
81+
- Version information
82+
- Environment details
83+
84+
## Adding New Tools
85+
86+
When adding new tools to the MCP server:
87+
88+
1. Follow the existing pattern in `server.ts`
89+
2. Define clear parameter schemas using Zod
90+
3. Implement thorough error handling
91+
4. Add proper documentation for the tool
92+
5. Include examples of how to use the tool
93+
94+
## License
95+
96+
By contributing to this project, you agree that your contributions will be licensed under the project's license.
97+
98+
## Questions?
99+
100+
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: config.version,
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from "eslint/config";
2+
import js from "@eslint/js";
3+
import globals from "globals";
4+
import tseslint from "typescript-eslint";
5+
import eslintConfigPrettier from "eslint-config-prettier/flat";
6+
7+
export default defineConfig([
8+
{ files: ["src/**/*.ts"], plugins: { js }, extends: ["js/recommended"] },
9+
{ files: ["src/**/*.ts"], languageOptions: { globals: globals.node } },
10+
tseslint.configs.recommended,
11+
eslintConfigPrettier
12+
]);

0 commit comments

Comments
 (0)