MCP ExplorerExplorer

Code Review Tool

@ClemNTTSon 25 days ago
1 MIT
FreeCommunity
AI Systems
#docker#docker-compose#eslint#flake8#github-actions#mcp#mcp-server#pipeline#python
This project is a code linting tool for Python and JavaScript, powered by a FastAPI backend. It allows you to send code via a REST API and receive a lint report in JSON format, using Flake8 for Python and ESLint for JavaScript. This project is designed to be integrated with a custom GPT.

Overview

What is Code Review Tool

Code-review-tool is a code linting tool designed for Python and JavaScript. It utilizes a FastAPI backend to allow users to send code via a REST API and receive lint reports in JSON format, leveraging Flake8 for Python and ESLint for JavaScript.

Use cases

Use cases for the code-review-tool include automated code reviews in CI/CD pipelines, integration into development environments to provide real-time feedback on code quality, and enhancing code quality during collaborative coding sessions.

How to use

To use the code-review-tool, first clone the repository and install the necessary Python and Node.js dependencies. Then, run the API server using Uvicorn. You can send code to the ‘/functions/run_linter’ endpoint via a POST request with the required JSON body containing the programming language and the code to be analyzed.

Key features

Key features of the code-review-tool include support for both Python and JavaScript linting, integration with a custom GPT for advanced capabilities, and the ability to receive detailed lint reports in JSON format.

Where to use

The code-review-tool is suitable for software development environments where code quality and adherence to coding standards are critical. It can be used in both individual projects and larger team collaborations.

Content

Code Review Tool

This project is a code linting tool for Python and JavaScript, powered by a FastAPI backend. It allows you to send code via a REST API and receive a lint report in JSON format, using Flake8 for Python and ESLint for JavaScript.

This project is designed to be integrated with a custom GPT, providing it with access to advanced code linting capabilities through the API.

Prerequisites

  • Python 3.10+
  • Node.js (for ESLint)
  • pip (to install Python dependencies)
  • npm (to install Node dependencies)

Installation

  1. Clone the repository
# Clone the project
git clone https://github.com/ClemNTTS/code-review-tool
cd code-review-tool
  1. Install Python dependencies
cd backend
python -m venv ../env
source ../env/Scripts/activate
pip install -r requirements.txt
  1. Install Node dependencies (for ESLint)
npm install

Configuration

  • The .flake8 file configures Flake8 for Python.
  • The .eslintrc.json file configures ESLint for JavaScript.

Run the API server

uvicorn app.main:app --reload

The server will be available at http://127.0.0.1:8000

API Usage

Endpoint: /functions/run_linter

  • Method: POST
  • Body (JSON):
    • language: “python” or “javascript”
    • code: the source code to analyze

Example with curl (Python)

curl -X POST "http://127.0.0.1:8000/functions/run_linter" \
  -H "Content-Type: application/json" \
  -d '{"language": "python", "code": "def add(a, b):\n    return a+b\n"}'

Example with curl (JavaScript)

curl -X POST "http://127.0.0.1:8000/functions/run_linter" \
  -H "Content-Type: application/json" \
  -d '{"language": "javascript", "code": "var unused; function add(a,b){return a+b;}"}'

Endpoint: /politique-de-confidentialite

  • Method: GET
  • Description: Returns the privacy policy as HTML.
  • Response: text/html containing the privacy policy.

Example with curl

curl http://127.0.0.1:8000/politique-de-confidentialite

Monitoring & Logging

  • Logs: All API requests and linting results are logged to backend/logs/app.log with automatic rotation.
  • Prometheus metrics: The /metrics endpoint exposes Prometheus-compatible metrics, including the number of lint requests per language. Example: curl http://localhost:8000/metrics.
  • Sentry: Error reporting is integrated with Sentry. Set your SENTRY_DSN and SENTRY_ENV in the .env file to enable error tracking. Errors are automatically sent to your Sentry dashboard.

Environment Variables

  • Use a .env file at the project root (see .env.example).
  • Main variables:
    • SENTRY_DSN: Sentry Data Source Name (for error reporting)
    • SENTRY_ENV: Sentry environment (e.g. development, production)

Docker & Docker Compose

  • Build and run the backend with Docker Compose:
docker compose up --build
  • The .env file is automatically loaded for environment variables.
  • The backend is available on port 8000.

Continuous Integration

  • GitHub Actions workflow is set up in .github/workflows/ci.yml.
  • On each push or pull request to main, the workflow:
    • Installs Python and Node dependencies
    • Runs all integration tests
    • Builds the Docker image to ensure Dockerfile validity

Tests

  • Integration tests are in backend/tests/test_api.py.
  • Run all tests locally with:
pytest

License

Read LICENSE file.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers