npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@slathar-dev/mcp-sensitive-read

v0.9.8

Published

MCP server for secure file reading within project boundaries

Readme

MCP Sensitive Read Server

A secure Model Context Protocol (MCP) server that integrates Gitleaks secret scanning into file reading operations. This ensures that any hardcoded credentials, API keys, tokens, or other secrets are automatically detected and redacted before file content is returned to LLM systems.

Features

  • Automatic Secret Detection: Uses Gitleaks to scan files for over 100 types of secrets
  • Smart Redaction: Replaces secret values with "REDACTED" while preserving keys and file structure
  • Line Integrity: Maintains original line numbers for accurate file slicing
  • Cross-Platform: Automatically downloads and manages Gitleaks binaries for Linux, macOS, and Windows
  • Performance Optimized: Includes caching system to avoid repeated scans of unchanged files
  • Comprehensive Error Handling: Graceful fallbacks when scanning fails
  • MCP Compatible: Drop-in replacement for standard read_file tools

Installation

npm install
npm run build

Usage

As an MCP Server

npm start

The server will initialize Gitleaks and listen for MCP tool calls.

Testing

Run the comprehensive test suite:

npm test                    # Full test suite
npm run test:unit          # Unit tests only
npm run test:integration   # Integration tests only

How It Works

  1. File Read Request: When a read_file tool call is received, the server reads the entire file content
  2. Secret Scanning: The content is scanned using Gitleaks to detect secrets
  3. Smart Redaction: Any detected secrets are replaced with "REDACTED" while preserving structure
  4. Line Slicing: If specific line ranges are requested, slicing is applied AFTER redaction
  5. Response: The redacted (and optionally sliced) content is returned

Supported Secret Types

Gitleaks detects over 100 types of secrets including:

  • API Keys (Generic, AWS, Google, etc.)
  • Authentication Tokens (GitHub, GitLab, etc.)
  • Private Keys (RSA, SSH, etc.)
  • Database Credentials
  • Cloud Service Keys
  • Payment Processing Keys (Stripe, PayPal, etc.)
  • And many more...

Configuration

The Gitleaks manager can be configured with:

const gitleaksManager = new GitLeaksManager({
  maxFileSize: 50 * 1024 * 1024, // 50MB max file size
  enableCache: true,              // Enable result caching
  cacheTimeout: 10 * 60 * 1000,  // 10 minutes cache timeout
  binaryPath: '/custom/path'      // Custom Gitleaks binary path
});

Security Behavior

  • Fail-Safe: If Gitleaks scanning fails, the original content is returned with a warning (configurable)
  • Complete Redaction: Multi-line secrets (like private keys) are completely replaced
  • Structure Preservation: Keys and structure are maintained for readability
  • Project Scoped: Only files within the project root can be accessed

Architecture

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   MCP Client    │───▶│  Server (Node)   │───▶│ Gitleaks Binary │
│   (Claude)      │    │                  │    │                 │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                │
                                ▼
                       ┌─────────────────┐
                       │  File Content   │
                       │   (Redacted)    │
                       └─────────────────┘

Test Coverage

The implementation includes comprehensive tests:

  • Unit Tests: GitLeaks manager functionality (100% pass rate)
  • Secret Detection: Various secret types and formats
  • Redaction Logic: Proper replacement while preserving structure
  • Line Slicing: Accurate slicing after redaction
  • Caching: Performance optimization verification
  • Error Handling: Graceful failure scenarios
  • Cross-Platform: Binary download and execution

Implementation Status

COMPLETED - All core functionality implemented and tested:

  1. ✅ Project structure and MCP server examination
  2. ✅ Gitleaks binary download and management system
  3. ✅ Cross-platform binary detection and fetching
  4. ✅ read_file tool integration with Gitleaks scanning
  5. ✅ Gitleaks command execution and JSON parsing
  6. ✅ Secret redaction logic preserving keys and line numbers
  7. ✅ Line slicing after redaction
  8. ✅ Caching system for performance optimization
  9. ✅ Error handling and fallbacks
  10. ✅ Comprehensive test suite (8/8 unit tests passing)
  11. ✅ Cross-platform functionality verification

Performance

  • First Scan: ~20-50ms per file (depending on size)
  • Cached Scans: <1ms (cache hit)
  • Memory Usage: Minimal overhead with automatic cleanup
  • Binary Size: ~7MB (Gitleaks binary)

License

MIT