RepoMix MCP server

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

Repomix is a powerful tool that packs your entire codebase into a single, AI-friendly file. This makes it easy to feed your repository to Large Language Models (LLMs) like Claude, ChatGPT, DeepSeek, and others for analysis, refactoring, or documentation generation.

Installation Options

Using the CLI Tool

You can run Repomix instantly without installation:

npx repomix@latest

Or install globally for repeated use:

# Install using npm
npm install -g repomix

# Alternatively using yarn
yarn global add repomix

# Alternatively using bun
bun add -g repomix

# Alternatively using Homebrew (macOS/Linux)
brew install repomix

Using Docker

# Basic usage (current directory)
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix

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

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

Basic Usage

Pack Your Codebase

# Pack entire repository
repomix

# Pack 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/"

Pack Remote Repositories

# Pack from GitHub URL
repomix --remote https://github.com/yamadashy/repomix

# Using GitHub shorthand
repomix --remote yamadashy/repomix

# Specify branch or commit
repomix --remote yamadashy/repomix --remote-branch main
repomix --remote https://github.com/yamadashy/repomix/tree/main

Pack from File List (via stdin)

# Using find command
find src -name "*.ts" -type f | repomix --stdin

# Using git to get tracked files
git ls-files "*.ts" | repomix --stdin

# Using grep to find files with specific content
grep -l "TODO" **/*.ts | repomix --stdin

Advanced Options

# Include git logs in output
repomix --include-logs

# Compress output to reduce token count
repomix --compress

# Initialize configuration file
repomix --init

Output Formats

Repomix supports multiple output formats to suit different needs:

XML Format (default)

repomix

Markdown Format

repomix --style markdown

JSON Format

repomix --style json

Plain Text Format

repomix --style plain

Configuration

Create a configuration file with default settings:

repomix --init

This creates a repomix.config.json file in your project root. You can also use TypeScript or JavaScript configuration:

// repomix.config.ts
import { defineConfig } from 'repomix';

export default defineConfig({
  output: {
    filePath: 'output.xml',
    style: 'xml',
    removeComments: true,
  },
  ignore: {
    customPatterns: ['**/node_modules/**', '**/dist/**'],
  },
});

MCP Server Integration

Repomix can run as a Model Context Protocol (MCP) server to integrate with AI assistants:

repomix --mcp

Configure MCP in VS Code:

code --add-mcp '{"name":"repomix","command":"npx","args":["-y","repomix","--mcp"]}'

Or install using the badge:

Install in VS Code

Agent Skills Generation

Generate Claude Agent Skills for reusable codebase reference:

# Generate Skills from local directory
repomix --skill-generate

# Generate with custom Skills name
repomix --skill-generate my-project-reference

# Generate from remote repository
repomix --remote https://github.com/user/repo --skill-generate

Token Count Optimization

Visualize token usage with:

repomix --token-count-tree

Or set a minimum threshold:

repomix --token-count-tree 1000  # Only show files/directories with 1000+ tokens

Prompt Examples

Once you've generated the packed file, you can use it with AI tools. Example prompts:

This file contains my entire codebase. Please review the overall structure and suggest any improvements or refactoring opportunities, focusing on maintainability and scalability.
Based on the codebase in this file, please generate a detailed README.md that includes an overview of the project, its main features, setup instructions, and usage examples.
Analyze the code in this file and suggest a comprehensive set of unit tests for the main functions and classes. Include edge cases and potential error scenarios.

Command Line Reference

Basic Options

  • -v, --version: Show version information

Input/Output Options

  • --verbose: Enable detailed logging
  • --quiet: Suppress all output except errors
  • --stdout: Write directly to stdout
  • --stdin: Read file paths from stdin
  • --copy: Copy output to clipboard
  • --token-count-tree [threshold]: Show file tree with token counts
  • --top-files-len <number>: Number of largest files to show

Output Options

  • -o, --output <file>: Output file path
  • --style <style>: Output format (xml, markdown, json, plain)
  • --parsable-style: Escape special characters
  • --compress: Extract essential code structure
  • --no-file-summary: Omit file summary section
  • --remove-comments: Strip code comments
  • --remove-empty-lines: Remove blank lines
  • --header-text <text>: Add custom text at beginning
  • --include-logs: Add git commit history
  • --include-diffs: Add git diff section

File Selection Options

  • --include <patterns>: Include only matching files
  • -i, --ignore <patterns>: Additional patterns to exclude
  • --no-gitignore: Don't use .gitignore rules
  • --no-default-patterns: Don't apply built-in ignore patterns

Remote Repository Options

  • --remote <url>: Clone and pack remote repository
  • --remote-branch <name>: Specific branch or commit

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "repomix" '{"command":"npx","args":["-y","repomix","--mcp"]}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "repomix": {
            "command": "npx",
            "args": [
                "-y",
                "repomix",
                "--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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

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