Navigation
Comment-stripper-MCP: Batch Process & Deployment-Ready Code - MCP Implementation

Comment-stripper-MCP: Batch Process & Deployment-Ready Code

comment-stripper-mcp: Seamlessly batch-process JS/TS/Vue files/dirs with regex-powered comment stripping, ensuring clean code maintenance and deployment-ready outputs.

✨ Developer Tools
4.4(29 reviews)
43 saves
20 comments

82% of users reported increased productivity after just one week

About Comment-stripper-MCP

What is Comment-stripper-MCP: Batch Process & Deployment-Ready Code?

Comment-stripper-MCP is a specialized server implementing the Model Context Protocol (MCP) to automate comment removal from codebases. It handles files, directories (including nested structures), and raw text inputs across 12+ languages using regex patterns. Built with Node.js/TypeScript and Test-Driven Development, this tool ensures reliable stripping of comments while maintaining code integrity for deployment workflows.

How to use Comment-stripper-MCP: Batch Process & Deployment-Ready Code?

Deployment involves three core steps:

  1. Install dependencies via npm/yarn after cloning the repository
  2. Start the server in dev/prod mode on configured ports
  3. Use MCP-compliant endpoints for comment stripping operations

API requests support file paths, directory paths, or text inputs. Progress tracking and authentication features require specific endpoint parameters and configuration.

Comment-stripper-MCP Features

Key Features of Comment-stripper-MCP: Batch Process & Deployment-Ready Code?

  • Language-specific comment detection for JS/TS/Vue/CSS/HTML/Python/java family languages
  • Recursive directory processing with configurable file type filters
  • Production-ready error handling with standardized response formats
  • Configurable performance parameters (chunk size, worker threads, memory limits)
  • Optional API authentication via environment variables
  • Granular logging (TRACE-ERROR levels) with file output option

Use cases of Comment-stripper-MCP: Batch Process & Deployment-Ready Code?

Typical scenarios include:

  • Pre-deployment code sanitization for production environments
  • Legacy code cleanup before migration projects
  • Continuous Integration pipelines needing comment-free artifact generation
  • Automated documentation generation workflows requiring clean source files
  • Large-scale code audits where comment content needs isolation

Comment-stripper-MCP FAQ

FAQ from Comment-stripper-MCP: Batch Process & Deployment-Ready Code?

Why does the server crash during Claude Desktop connection?

Verify absolute paths in claude_desktop_config.json and ensure Node.js 18+ using NVM. Check process.stdin.resume() improvements in latest builds.

How to optimize performance for 10k+ file projects?

Adjust MAX_WORKERS and CHUNK_SIZE in .env. Enable streaming mode by lowering MEMORY_LIMIT below your project's average file size.

Can I customize comment patterns for new languages?

Yes, extend regex pattern definitions in src/parsers directory following existing language implementations.

What logging levels are available?

TRACE(4), DEBUG(3), INFO(2), WARN(1), ERROR(0) - configure via LOG_LEVEL environment variable.

How to monitor processing progress?

Use the /api/get-progress endpoint with trackerId returned from initial requests when trackProgress is enabled.

Content

comment-stripper-mcp

A flexible MCP server that batch processes code files to remove comments across multiple programming languages. Currently supports JavaScript, TypeScript, Vue, CSS/SCSS/LESS, HTML, Python, Java, C#, C++, Ruby, and PHP files with regex-based pattern matching.

Overview

This server implements the Model Context Protocol (MCP) to provide a service that removes comments from code files. It accepts individual files, directories (including subdirectories), or direct text input, and returns the cleaned code with comments stripped out.

This project is developed using Test-Driven Development (TDD) methodology, ensuring high code quality, better design, and comprehensive test coverage from the start. Each feature is first defined by tests before implementation, following the red-green-refactor cycle.

Features

  • πŸ”„ Process files, directories, or raw text input
  • 🌐 Cross-language support (JS, TS, Vue, CSS/SCSS/LESS, HTML, Python, Java, C#, C++, Ruby, and PHP)
  • πŸ“‚ Recursively handle nested directories
  • ⚑ Regex-based pattern matching for efficient comment removal
  • πŸ”Œ MCP-compliant API for easy integration
  • πŸ› οΈ Built with Node.js and TypeScript
  • πŸ“Š Comprehensive logging system with multiple log levels
  • ⚠️ Robust error handling with standardized error responses
  • βš™οΈ Flexible configuration through environment variables
  • πŸš€ Performance optimization for processing large files
  • πŸ” API authentication for secure access
  • πŸ“ˆ Progress tracking for large directory processing

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

# Clone this repository
git clone https://github.com/yhzion/comment-stripper-mcp.git
cd comment-stripper-mcp

# Install dependencies
npm install
# or
yarn install

Running the Server

# Development mode
npm run dev
# or
yarn dev

# Production mode
npm run build
npm start
# or
yarn build
yarn start

By default, the server runs on port 3000. You can configure this through environment variables.

MCP μ„œλ²„ μ—°κ²° 문제 ν•΄κ²° κ°€μ΄λ“œ

MCP μ„œλ²„κ°€ Claude Desktopκ³Ό μ—°κ²° μ‹œ 예기치 μ•Šκ²Œ μ’…λ£Œλ˜λŠ” λ¬Έμ œκ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€. 이 문제λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•œ κ°€μ΄λ“œμž…λ‹ˆλ‹€.

문제 증상

  • μ„œλ²„κ°€ μ΄ˆκΈ°ν™”λœ ν›„ κ³§λ°”λ‘œ μ’…λ£Œλ¨
  • λ‘œκ·Έμ— "Server transport closed unexpectedly" λ©”μ‹œμ§€κ°€ ν‘œμ‹œλ¨
  • Claude Desktopμ—μ„œ MCP μ„œλ²„μ— μ—°κ²°ν•  수 μ—†λ‹€λŠ” 였λ₯˜ λ©”μ‹œμ§€κ°€ ν‘œμ‹œλ¨

ν•΄κ²° 방법

1. NVM을 μ‚¬μš©ν•œ κΉ¨λ—ν•œ Node.js ν™˜κ²½ μ„€μ •

# NVM μ„€μΉ˜ (이미 μ„€μΉ˜λ˜μ–΄ μžˆλ‹€λ©΄ μƒλž΅)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# μ΅œμ‹  Node.js μ„€μΉ˜
nvm install node

# μ„€μΉ˜ν•œ 버전 ν™œμ„±ν™”
nvm use node

2. Claude Desktop μ„€μ • νŒŒμΌμ— μ ˆλŒ€ 경둜 μ‚¬μš©

Claude Desktop μ„€μ • 파일(claude_desktop_config.json)μ—μ„œ μƒλŒ€ 경둜 λŒ€μ‹  μ ˆλŒ€ 경둜λ₯Ό μ‚¬μš©ν•˜μ„Έμš”:

{
  "mcpServers": {
    "comment-stripper": {
      "command": "/μ ˆλŒ€/경둜/node",
      "args": [
        "/μ ˆλŒ€/경둜/comment-stripper-mcp/build/index.js"
      ]
    }
  }
}

which node λͺ…λ Ήμ–΄λ‘œ Node.js 경둜λ₯Ό 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

3. μ„œλ²„ μ•ˆμ •μ„± κ°œμ„ 

μ„œλ²„ μ½”λ“œμ— λ‹€μŒκ³Ό 같은 μ•ˆμ •μ„± κ°œμ„  사항이 μ μš©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€:

  • ν”„λ‘œμ„ΈμŠ€κ°€ 예기치 μ•Šκ²Œ μ’…λ£Œλ˜μ§€ μ•Šλ„λ‘ process.stdin.resume() μ‚¬μš©
  • 닀쀑 keep-alive λ©”μ»€λ‹ˆμ¦˜ κ΅¬ν˜„
  • 였λ₯˜ 처리 κ°œμ„ 
  • μƒμ„Έν•œ λ‘œκΉ… μΆ”κ°€

μΆ”κ°€ 문제 ν•΄κ²° 팁

  • Claude Desktop의 개발자 λͺ¨λ“œλ₯Ό ν™œμ„±ν™”ν•˜μ—¬ MCP 둜그 νŒŒμΌμ— μ ‘κ·Όν•˜μ„Έμš”.
  • μ„œλ²„ μ‹€ν–‰ μ‹œ λ°œμƒν•˜λŠ” 였λ₯˜ λ©”μ‹œμ§€λ₯Ό ν™•μΈν•˜μ„Έμš”.
  • ν™˜κ²½ λ³€μˆ˜κ°€ μ˜¬λ°”λ₯΄κ²Œ μ„€μ •λ˜μ–΄ μžˆλŠ”μ§€ ν™•μΈν•˜μ„Έμš”.
  • λ°©ν™”λ²½μ΄λ‚˜ λ³΄μ•ˆ μ†Œν”„νŠΈμ›¨μ–΄κ°€ 연결을 μ°¨λ‹¨ν•˜κ³  μžˆμ§€ μ•Šμ€μ§€ ν™•μΈν•˜μ„Έμš”.

Configuration

The server can be configured using environment variables. You can create a .env file in the root directory based on the provided .env.example file:

# Server configuration
PORT=3000                # Port for the server to listen on
HOST=127.0.0.1           # Host for the server to bind to
NODE_ENV=development     # Environment (development, production, test)

# Logging configuration
LOG_LEVEL=2              # 0=ERROR, 1=WARN, 2=INFO, 3=DEBUG, 4=TRACE
LOG_TO_FILE=false        # Whether to log to a file
LOG_DIR=logs             # Directory for log files

# Performance configuration
CHUNK_SIZE=1048576       # 1MB chunk size for processing large files
MAX_WORKERS=4            # Number of concurrent workers for batch processing
MEMORY_LIMIT=536870912   # 512MB memory limit before using streaming

# Authentication
API_KEY=your-secret-key  # API key for authentication

Testing

This project strictly follows Test-Driven Development (TDD) principles:

  1. Write a failing test first (Red phase)
  2. Implement the minimum code to pass the test (Green phase)
  3. Refactor the code while keeping tests passing

The project uses Jest as the testing framework with TypeScript support via ts-jest. Tests are organized into:

  • Unit tests : Testing individual functions and components

  • Integration tests : Testing API endpoints and interactions between components

    Run all tests

    npm test

    or

    yarn test

    Run tests in watch mode

    npm run test:watch

    or

    yarn test:watch

    Run tests with coverage

    npm run test:coverage

    or

    yarn test:coverage

API Documentation

Strip Comments Endpoint

Endpoint : /api/strip-comments

Method : POST

Description : Strips comments from code files or text.

Request Parameters :

  • text (optional): The text to strip comments from.
  • filePath (optional): The path to a file to strip comments from.
  • directoryPath (optional): The path to a directory to process.
  • recursive (optional, default: true): Whether to recursively process subdirectories.
  • fileTypes (optional, default: all supported): Array of file extensions to process.
  • trackProgress (optional, default: false): Whether to track progress for directory processing.

Response :

{
  "success": true,
  "data": {
    "original": "// Original code with comments",
    "stripped": "// Code with comments removed"
  }
}

Get Progress Endpoint

Endpoint : /api/get-progress

Method : POST

Description : Gets the progress of a directory processing operation.

Request Parameters :

  • trackerId: The ID of the progress tracker.

Response :

{
  "success": true,
  "data": {
    "processed": 10,
    "total": 20,
    "percentage": 50,
    "completed": false
  }
}

Authentication Status Endpoint

Endpoint : /api/auth-status

Method : POST

Description : Gets the current authentication status and configuration.

Response :

{
  "success": true,
  "data": {
    "authEnabled": true,
    "authenticated": true,
    "message": "Authenticated successfully"
  }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the ISC License - see the LICENSE file for details.

Related MCP Servers & Clients