Skip to content

Installing Code2Prompt

Guide Overview

Welcome to the Code2Prompt installation guide. This document provides step-by-step instructions for installing it on various platforms, including Windows, macOS, and Linux.

TL;DR

Terminal window
# Cargo
$ cargo install code2prompt
# Homebrew
$ brew install code2prompt

Make sure Rust and cargo are installed on your system.

Terminal window
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

This is the official way to install the latest stable version of Rust and Cargo. Make sure to refresh your PATH variable after installing Rust. Restart your terminal or run the instructions proposed by the installer.

Terminal window
source $HOME/.cargo/env

You can check that everything is installed correctly by running:

Terminal window
cargo --version
git --version
Terminal window
# Cargo
$ cargo install code2prompt
# Homebrew
$ brew install code2prompt

🧪 Install the latest (unpublished) version from GitHub

Section titled “🧪 Install the latest (unpublished) version from GitHub”

If you want the latest features or fixes before they’re released on crates.io:

Terminal window
cargo install --git https://github.com/mufeedvh/code2prompt

Ideal for developers that want to build from source or contribute to the project.

  1. 🛠️ Install Prerequisites :

  2. 📥 Clone the repository :

    Terminal window
    git clone https://github.com/mufeedvh/code2prompt.git
    cd code2prompt
  3. 📦 Install the binary :

    To build and install from source:

    Terminal window
    cargo install --path crates/code2prompt

    To build the binary without installing it:

    Terminal window
    cargo build --release

    The binary will be available in the target/release directory.

  4. 🚀 Run it :

    Terminal window
    code2prompt --help

Best for users that want to use the latest version without building from source.

Download the latest binary for your OS from Releases.

⚠️ Binary releases may lag behind the latest GitHub version. For cutting-edge features, consider building from source.

Specifically for Arch Linux users, code2prompt is available in the AUR.

code2prompt is available in the AUR. Install it via any AUR helpers.

Terminal window
paru/yay -S code2prompt

If you’re using Nix, you can install it using either nix-env or nix profile.

Terminal window
# without flakes:
nix-env -iA nixpkgs.code2prompt
# with flakes:
nix profile install nixpkgs#code2prompt

You can download the python bindings from Pypi

Terminal window
pip install code2prompt_rs
  1. 🛠️ Install Prerequisites :

  2. 📥 Clone the repository :

    Terminal window
    git clone https://github.com/mufeedvh/code2prompt.git
    cd code2prompt/crates/code2prompt-python
  3. 📦 Install the dependencies :

    The rye command will create a virtual environment and install all the dependencies.

    Terminal window
    rye sync
  4. ⚙️ Build the package :

    You will develop the package in the virtual environment located in .venv folder at the root of the project.

    Terminal window
    rye run maturin develop -r

The code2prompt MCP server will soon be available in MCP registries.

The code2prompt MCP server is still a prototype and will be integrated to the main repository soon.

To run the MCP server, locally to use it with Cline, Goose or Aider:

  1. 🛠️ Install Prerequisites :

  2. 📥 Clone the repository :

    Terminal window
    git clone https://github.com/odancona/code2prompt-mcp.git
    cd code2prompt-mcp
  3. 📦 Install the dependencies :

    The rye command will create a virtual environment and install all the dependencies in the .venv folder.

    Terminal window
    rye sync
  4. 🚀 Run the server :

    The MCP server is now installed. You can run it using:

    Terminal window
    . .venv/bin/activate
    python -m src/code2prompt_mcp/main.py
  5. 🔌 Integrate with Agents :

    For instance, you can integrate it with Cline, using a similar configuration:

    {
    "mcpServers": {
    "code2prompt": {
    "command": "bash",
    "args": [
    "-c",
    "cd /home/olivier/projet/code2prompt-mcp && rye run python /home/olivier/projet/code2prompt-mcp/src/code2prompt_mcp/main.py"
    ],
    "env": {}
    }
    }
    }