Skip to content

Commit a1f101f

Browse files
authored
ci: add eslint (#7)
1 parent 88b7fea commit a1f101f

File tree

9 files changed

+1739
-104
lines changed

9 files changed

+1739
-104
lines changed

.github/workflows/code_health.yaml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
- uses: actions/setup-node@v4
1818
with:
1919
node-version-file: package.json
20-
- name: install dependencies
20+
cache: "npm"
21+
- name: Install dependencies
2122
run: |
2223
npm ci
2324
- name: build
@@ -37,22 +38,36 @@ jobs:
3738
exit 1
3839
fi
3940
prettier:
40-
name: Prettier Check
4141
runs-on: ubuntu-latest
4242
steps:
4343
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4444
with:
4545
config: ${{ vars.PERMISSIONS_CONFIG }}
4646
- name: Checkout Repository
4747
uses: actions/checkout@v2
48-
- name: Run Prettier
49-
id: prettier-run
50-
uses: rutajdash/prettier-cli-action@d42c4325a3b344f3bd4be482bc34de521998d557
48+
- uses: actions/setup-node@v4
5149
with:
52-
config_path: ./.prettierrc.yml
53-
- name: Prettier Output
54-
if: ${{ failure() }}
55-
shell: bash
50+
node-version-file: package.json
51+
cache: "npm"
52+
- name: Install dependencies
5653
run: |
57-
echo "The following files are not formatted:"
58-
echo "${{steps.prettier-run.outputs.prettier_output}}"
54+
npm ci
55+
- run: |
56+
npm run check:format
57+
eslint:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
61+
with:
62+
config: ${{ vars.PERMISSIONS_CONFIG }}
63+
- name: Checkout Repository
64+
uses: actions/checkout@v4
65+
- uses: actions/setup-node@v4
66+
with:
67+
node-version-file: package.json
68+
cache: "npm"
69+
- name: Install dependencies
70+
run: |
71+
npm ci
72+
- run: |
73+
npm run check: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: 5 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":
@@ -217,8 +217,10 @@ export class Server {
217217
name: "MongoDB Atlas",
218218
version: config.version,
219219
});
220-
server.tool("auth", "Authenticate to Atlas", async ({}) => this.authTool());
221-
let projectIdFilter = z.string().describe("Optional Atlas project ID to filter clusters");
220+
server.tool("auth", "Authenticate to Atlas", async () => this.authTool());
221+
let projectIdFilter = z
222+
.string()
223+
.describe("Optional Atlas project ID to filter clusters");
222224
if (config.projectID) {
223225
projectIdFilter = projectIdFilter.optional();
224226
}

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)