Skip to content

ci: add eslint #7

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 4 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions .github/workflows/code_health.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- name: install dependencies
cache: "npm"
- name: Install dependencies
run: |
npm ci
- name: build
Expand All @@ -37,22 +38,36 @@ jobs:
exit 1
fi
prettier:
name: Prettier Check
runs-on: ubuntu-latest
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
with:
config: ${{ vars.PERMISSIONS_CONFIG }}
- name: Checkout Repository
uses: actions/checkout@v2
- name: Run Prettier
id: prettier-run
uses: rutajdash/prettier-cli-action@d42c4325a3b344f3bd4be482bc34de521998d557
- uses: actions/setup-node@v4
with:
config_path: ./.prettierrc.yml
- name: Prettier Output
if: ${{ failure() }}
shell: bash
node-version-file: package.json
cache: "npm"
- name: Install dependencies
run: |
echo "The following files are not formatted:"
echo "${{steps.prettier-run.outputs.prettier_output}}"
npm ci
- run: |
npm run check:format
eslint:
runs-on: ubuntu-latest
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
with:
config: ${{ vars.PERMISSIONS_CONFIG }}
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: "npm"
- name: Install dependencies
run: |
npm ci
- run: |
npm run check:lint
100 changes: 100 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Contributing to MongoDB MCP Server

Thank you for your interest in contributing to the MongoDB MCP Server project! This document provides guidelines and instructions for contributing.

## Project Overview

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.

## Development Setup

### Prerequisites

- Node.js (v23 or later)
- npm

### Getting Started

1. Clone the repository:

```
git clone https://github.com/mongodb-labs/mongodb-mcp-server.git
cd mongodb-mcp-server
```

2. Install dependencies:

```
npm install
```

3. Add the mcp server to your IDE of choice
```json
{
"mcpServers": {
"MongoDB": {
"command": "/path/to/mongodb-mcp-server/dist/index.js"
}
}
}
```

## Code Contribution Workflow

1. Create a new branch for your feature or bugfix:

```
git checkout -b feature/your-feature-name
```

2. Make your changes, following the code style of the project

3. Run the inspector and double check your changes:

```
npm run inspect
```

4. Commit your changes with a descriptive commit message

## Pull Request Guidelines

1. Update documentation if necessary
2. Ensure your PR includes only relevant changes
3. Link any related issues in your PR description
4. Keep PRs focused on a single topic

## Code Standards

- Use TypeScript for all new code
- Follow the existing code style (indentation, naming conventions, etc.)
- Comment your code when necessary, especially for complex logic
- Use meaningful variable and function names

## Reporting Issues

When reporting issues, please include:

- A clear description of the problem
- Steps to reproduce
- Expected vs. actual behavior
- Version information
- Environment details

## Adding New Tools

When adding new tools to the MCP server:

1. Follow the existing pattern in `server.ts`
2. Define clear parameter schemas using Zod
3. Implement thorough error handling
4. Add proper documentation for the tool
5. Include examples of how to use the tool

## License

By contributing to this project, you agree that your contributions will be licensed under the project's license.

## Questions?

If you have any questions or need help, please open an issue or reach out to the maintainers.
6 changes: 3 additions & 3 deletions dist/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class ApiClient {
throw new ApiClientError("Device code expired. Please restart the authentication process.", response);
}
}
catch (error) {
catch {
throw new ApiClientError("Failed to retrieve token. Please check your device code.", response);
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ export class ApiClient {
const expiryWithDelta = new Date(token.expiry.getTime() - expiryDelta);
return expiryWithDelta.getTime() > Date.now();
}
catch (error) {
catch {
return false;
}
}
Expand All @@ -194,7 +194,7 @@ export class ApiClient {
await this.refreshToken(token);
return true;
}
catch (error) {
catch {
return false;
}
}
Expand Down
8 changes: 5 additions & 3 deletions dist/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Server {
await this.apiClient.retrieveToken(this.state.auth.code.device_code);
return !!this.state.auth.token;
}
catch (error) {
catch {
return false;
}
case "issued":
Expand Down Expand Up @@ -217,8 +217,10 @@ export class Server {
name: "MongoDB Atlas",
version: config.version,
});
server.tool("auth", "Authenticate to Atlas", async ({}) => this.authTool());
let projectIdFilter = z.string().describe("Optional Atlas project ID to filter clusters");
server.tool("auth", "Authenticate to Atlas", async () => this.authTool());
let projectIdFilter = z
.string()
.describe("Optional Atlas project ID to filter clusters");
if (config.projectID) {
projectIdFilter = projectIdFilter.optional();
}
Expand Down
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "eslint/config";
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier/flat";

export default defineConfig([
{ files: ["src/**/*.ts"], plugins: { js }, extends: ["js/recommended"] },
{ files: ["src/**/*.ts"], languageOptions: { globals: globals.node } },
tseslint.configs.recommended,
eslintConfigPrettier,
]);
Loading