RepoMix MCP server

Package codebases into AI-friendly single files with intelligent code structure preservation and token optimization.
Back to servers
Provider
Sho Yamada
Release date
Mar 13, 2025
Language
TypeScript
Package
Stats
158.2K downloads
15.5K stars

Repomix is a tool that packages your codebase into a single AI-friendly file for analysis by Large Language Models (LLMs) like ChatGPT, Claude, and others. It optimizes your code for AI consumption while providing useful features like token counting.

Installation

Install Repomix globally for repeated use:

# Using npm
npm install -g repomix

# Using yarn
yarn global add repomix

# Using Homebrew (macOS/Linux)
brew install repomix

Or use it without installation:

npx repomix

Basic Usage

Run Repomix in your project directory:

repomix

This generates a repomix-output.xml file containing your entire repository in an AI-friendly format.

Process a specific directory:

repomix path/to/directory

Include specific files using glob patterns:

repomix --include "src/**/*.ts,**/*.md"

Exclude specific files or directories:

repomix --ignore "**/*.log,tmp/"

Remote Repository Processing

Process a GitHub repository without cloning it:

repomix --remote https://github.com/yamadashy/repomix

# Using GitHub shorthand
repomix --remote yamadashy/repomix

# Specifying branch, tag, or commit
repomix --remote yamadashy/repomix --remote-branch main

Output Formats

Repomix supports multiple output formats:

# XML format (default)
repomix --style xml

# Markdown format
repomix --style markdown

# Plain text format
repomix --style plain

Code Compression

Reduce token count while preserving structure:

repomix --compress

This extracts key code elements like function signatures while removing implementation details.

Configuration

Create a configuration file:

repomix --init

This generates a repomix.config.json file that allows you to customize:

  • Output file path and format
  • Include/exclude patterns
  • Comment and empty line removal
  • Security checks
  • Token counting settings

Create a global configuration:

repomix --init --global

MCP Server Integration

Run Repomix as a Model Context Protocol server:

repomix --mcp

This allows AI assistants to directly interact with your codebase through tools like:

  • pack_codebase: Package a local code directory
  • pack_remote_repository: Fetch and package a GitHub repository
  • read_repomix_output: Read contents of a Repomix output file
  • file_system_read_file: Read a file with security validation
  • file_system_read_directory: List contents of a directory

Docker Usage

Run Repomix in a Docker container:

docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix

Process a remote repository and output to a directory:

docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix

Using the Output

After generating your packed file, send it to an AI assistant with a prompt like:

This file contains all the files in the repository combined into one.
I want to refactor the code, so please review it first.

Additional Options

  • --output <file>: Specify output filename
  • --copy: Copy output to system clipboard
  • --no-security-check: Disable security check
  • --remove-comments: Remove comments from supported file types
  • --remove-empty-lines: Remove empty lines
  • --token-count-encoding <encoding>: Specify token count encoding (e.g., o200k_base for GPT-4o)

For a complete list of options, run:

repomix --help

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later