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
195.6K downloads
16.3K stars

Repomix is a powerful tool that packages your codebase into AI-friendly formats, making it easier to analyze your code with large language models like ChatGPT, Claude, or other AI assistants.

Installation

You can use Repomix without installation using npx:

npx repomix

For global installation:

# Using npm
npm install -g repomix

# Using yarn
yarn global add repomix

# Using Homebrew (macOS/Linux)
brew install repomix

Basic Usage

Run in your project directory:

repomix

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

To process a specific directory:

repomix path/to/directory

To include specific files using glob patterns:

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

To exclude specific files:

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

Processing Remote Repositories

Analyze any GitHub repository without cloning it:

# Full URL
repomix --remote https://github.com/yamadashy/repomix

# GitHub shorthand
repomix --remote yamadashy/repomix

# Specific branch
repomix --remote yamadashy/repomix --remote-branch main

# Specific commit
repomix --remote yamadashy/repomix --remote-branch 935b695

# Branch URL
repomix --remote https://github.com/yamadashy/repomix/tree/main

# Commit URL
repomix --remote https://github.com/yamadashy/repomix/commit/836abcd7335137228ad77feb28655d85712680f1

Code Compression

To reduce token count while preserving code structure:

repomix --compress

This extracts essential function and class signatures while removing implementation details.

Output Formats

Repomix supports multiple output formats:

# XML format (default)
repomix --style xml

# Markdown format
repomix --style markdown

# Plain text format
repomix --style plain

Docker Usage

Run Repomix in an isolated container:

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

# Specific directory
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix path/to/directory

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

Configuration

Create a configuration file:

repomix --init

This generates a repomix.config.json file with customizable options:

{
  "input": {
    "maxFileSize": 50000000
  },
  "output": {
    "filePath": "repomix-output.xml",
    "style": "xml",
    "compress": false,
    "removeComments": false,
    "removeEmptyLines": false
  },
  "include": ["**/*"],
  "ignore": {
    "useGitignore": true,
    "useDefaultPatterns": true,
    "customPatterns": [
      "additional-folder",
      "**/*.log"
    ]
  },
  "security": {
    "enableSecurityCheck": true
  }
}

Advanced Options

Some useful command-line options:

# Output to stdout instead of file
repomix --stdout

# Copy output to clipboard
repomix --copy

# Remove comments from code
repomix --remove-comments

# Remove empty lines
repomix --remove-empty-lines

# Show line numbers
repomix --output-show-line-numbers

# Disable security check
repomix --no-security-check

# Use custom configuration file
repomix --config path/to/config.json

MCP Server Integration

Run Repomix as a Model Context Protocol (MCP) server to allow AI assistants to directly interact with your codebase:

repomix --mcp

This enables tools that let AI assistants package repositories for analysis without manual file preparation.

Using with AI Assistants

Once you've generated a packed file, upload it to your 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.

Example prompts for specific tasks:

  • Code Review: "Please review the overall structure and suggest improvements."
  • Documentation: "Generate a detailed README.md based on this codebase."
  • Test Generation: "Suggest unit tests for the main functions and classes."

Using with GitHub Actions

Automate repository packing with GitHub Actions:

- name: Pack repository with Repomix
  uses: yamadashy/repomix/.github/actions/repomix@main
  with:
    output: repomix-output.xml
    style: xml
    compress: true

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