website/client/src/en/guide/mcp-server.md
Repomix supports the Model Context Protocol (MCP), allowing AI assistants to directly interact with your codebase. When run as an MCP server, Repomix provides tools that enable AI assistants to package local or remote repositories for analysis without requiring manual file preparation.
[!NOTE]
This is an experimental feature that we'll be actively improving based on user feedback and real-world usage
To run Repomix as an MCP server, use the --mcp flag:
repomix --mcp
This starts Repomix in MCP server mode, making it available for AI assistants that support the Model Context Protocol.
To use Repomix as an MCP server with AI assistants like Claude, you need to configure the MCP settings:
You can install the Repomix MCP server in VS Code using one of these methods:
code --add-mcp '{"name":"repomix","command":"npx","args":["-y","repomix","--mcp"]}'
For VS Code Insiders:
code-insiders --add-mcp '{"name":"repomix","command":"npx","args":["-y","repomix","--mcp"]}'
Edit the cline_mcp_settings.json file:
{
"mcpServers": {
"repomix": {
"command": "npx",
"args": [
"-y",
"repomix",
"--mcp"
]
}
}
}
In Cursor, add a new MCP server from Cursor Settings > MCP > + Add new global MCP server with a configuration similar to Cline.
Edit the claude_desktop_config.json file with similar configuration to Cline's config.
Configure Repomix as an MCP server in Claude Code using the following command:
claude mcp add repomix -- npx -y repomix --mcp
Alternatively, you can use the official Repomix plugins for a more convenient experience. The plugins provide natural language commands and easier setup. See the Claude Code Plugins documentation for details.
Instead of using npx, you can also use Docker to run Repomix as an MCP server:
{
"mcpServers": {
"repomix-docker": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/yamadashy/repomix",
"--mcp"
]
}
}
}
When running as an MCP server, Repomix provides the following tools:
This tool packages a local code directory into a consolidated XML file for AI analysis. It analyzes the codebase structure, extracts relevant code content, and generates a comprehensive report including metrics, file tree, and formatted code content.
Parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
directory | Yes | — | Absolute path to the directory to pack |
compress | No | false | Enable Tree-sitter compression to extract essential code signatures and structure while removing implementation details. Reduces token usage by ~70% while preserving semantic meaning. Generally not needed since grep_repomix_output allows incremental content retrieval. |
includePatterns | No | — | Files to include using fast-glob patterns. Comma-separated (e.g., "**/*.{js,ts}", "src/**,docs/**") |
ignorePatterns | No | — | Additional files to exclude using fast-glob patterns. Comma-separated (e.g., "test/**,*.spec.js"). Supplements .gitignore and built-in exclusions. |
topFilesLength | No | 10 | Number of largest files by size to display in the metrics summary |
style | No | xml | Output format style: xml, markdown, json, or plain |
Example:
{
"directory": "/path/to/your/project",
"compress": false,
"includePatterns": "src/**/*.ts,**/*.md",
"ignorePatterns": "**/*.log,tmp/",
"topFilesLength": 10
}
This tool fetches, clones, and packages a GitHub repository into a consolidated XML file for AI analysis. It automatically clones the remote repository, analyzes its structure, and generates a comprehensive report.
Parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
remote | Yes | — | GitHub repository URL or user/repo format (e.g., "yamadashy/repomix", "https://github.com/user/repo", or "https://github.com/user/repo/tree/branch") |
compress | No | false | Enable Tree-sitter compression to extract essential code signatures and structure while removing implementation details. Reduces token usage by ~70% while preserving semantic meaning. Generally not needed since grep_repomix_output allows incremental content retrieval. |
includePatterns | No | — | Files to include using fast-glob patterns. Comma-separated (e.g., "**/*.{js,ts}", "src/**,docs/**") |
ignorePatterns | No | — | Additional files to exclude using fast-glob patterns. Comma-separated (e.g., "test/**,*.spec.js"). Supplements .gitignore and built-in exclusions. |
topFilesLength | No | 10 | Number of largest files by size to display in the metrics summary |
style | No | xml | Output format style: xml, markdown, json, or plain |
Example:
{
"remote": "yamadashy/repomix",
"compress": false,
"includePatterns": "src/**/*.ts,**/*.md",
"ignorePatterns": "**/*.log,tmp/",
"topFilesLength": 10
}
This tool reads the contents of a Repomix-generated output file. Supports partial reading with line range specification for large files. This tool is designed for environments where direct file system access is limited.
Parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
outputId | Yes | — | ID of the Repomix output file to read |
startLine | No | Beginning of file | Starting line number (1-based, inclusive) |
endLine | No | End of file | Ending line number (1-based, inclusive) |
Features:
Example:
{
"outputId": "8f7d3b1e2a9c6054",
"startLine": 100,
"endLine": 200
}
This tool searches for patterns in a Repomix output file using grep-like functionality with JavaScript RegExp syntax. Returns matching lines with optional context lines around matches.
Parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
outputId | Yes | — | ID of the Repomix output file to search |
pattern | Yes | — | Search pattern (JavaScript RegExp syntax) |
contextLines | No | 0 | Number of context lines before and after each match. Overridden by beforeLines/afterLines if specified. |
beforeLines | No | — | Lines to show before each match (like grep -B). Takes precedence over contextLines. |
afterLines | No | — | Lines to show after each match (like grep -A). Takes precedence over contextLines. |
ignoreCase | No | false | Perform case-insensitive matching |
Features:
Example:
{
"outputId": "8f7d3b1e2a9c6054",
"pattern": "function\\s+\\w+\\(",
"contextLines": 3,
"ignoreCase": false
}
Repomix's MCP server provides two file system tools that allow AI assistants to safely interact with the local file system:
file_system_read_filefile_system_read_directory[FILE] or [DIR])Both tools incorporate robust security measures:
Example:
// Reading a file
const fileContent = await tools.file_system_read_file({
path: '/absolute/path/to/file.txt'
});
// Listing directory contents
const dirContent = await tools.file_system_read_directory({
path: '/absolute/path/to/directory'
});
These tools are particularly useful when AI assistants need to:
Using Repomix as an MCP server offers several advantages:
Once configured, your AI assistant can directly use Repomix's capabilities to analyze codebases, making code analysis workflows more efficient.