Labsco
smat-dev logo

Jinni

β˜… 269

from smat-dev

A tool to provide Large Language Models with project context by intelligently filtering and concatenating relevant files.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup
Jinni Banner

Jinni: Bring Your Project Into Context

Jinni: Bring Your Project Into Context MCP server

Jinni is a tool to efficiently provide Large Language Models the context of your projects. It gives a consolidated view of relevant project files, overcoming the limitations and inefficiencies of reading files one by one. Each file's content is preceded by a simple header indicating its path:

```path=src/app.py
print("hello")

The philosophy behind this tool is that LLM context windows are large, models are smart, and directly seeing your project best equips the model to help with anything you throw at it.

There is an MCP (Model Context Protocol) server for integration with AI tools and a command-line utility (CLI) for manual use that copies project context to the clipboard ready to paste wherever you need it.

These tools are opinionated about what counts as relevant project context to best work out of the box in most use cases, automatically excluding:

* Binary files
* Dotfiles and hidden directories
* Common naming conventions for logs, build directories, tempfiles, etc

Inclusions/exclusions are customizable with complete granularity if required using .contextfiles – this works like .gitignore except defining inclusions. .gitignore files themselves are also respected automatically, but any rules in .contextfiles take priority.

The MCP server can provide as much or as little of the project as desired. By default the scope is the whole project, but the model can ask for specific modules / matching patterns / etc.

MCP Quickstart

MCP server config file for Cursor / Roo / Claude Desktop / client of choice:

{
    "mcpServers": {
        "jinni": {
            "command": "uvx",
            "args": ["jinni-server"]
        }
    }
}

You can optionally constrain the server to only read within a tree for security in case your LLM goes rogue: add "--root", "/absolute/path/" to the args list.

Install uv if it is not on your system: https://docs.astral.sh/uv/getting-started/installation/

Reload your IDE and you can now ask the agent to read in context.

If you want to restrict this to particular modules / paths just ask - e.g. "Read context for tests".

In action with Cursor:

Usage Example

Note For Cursor Users

Cursor can silently drop context that is larger than the allowed maximum, so if you have a sizable project and the agent acts like the tool call never happened, try reducing what you are bringing in ("read context for xyz")

Components

  1. jinni MCP Server:

    • Integrates with MCP clients like Cursor, Cline, Roo, Claude Desktop, etc.
    • Exposes a read_context tool that returns a concatenated string of relevant file contents from a specified project directory.
  2. jinni CLI:

    • A command-line tool for manually generating the project context dump.
    • Useful for feeding context to LLMs via copy-paste or file input. Or pipe the output wherever you need it.

Features

  • Efficient Context Gathering: Reads and concatenates relevant project files in one operation.
  • Intelligent Filtering (Gitignore-Style Inclusion):
    • Uses a system based on .gitignore syntax (pathspec library's gitwildmatch).
    • Automatically loads .gitignore files from the project root downward. These exclusions can be overridden by rules in .contextfiles.
    • Supports hierarchical configuration using .contextfiles placed within your project directories. Rules are applied dynamically based on the file/directory being processed.
    • Matching Behavior: Patterns match against the path relative to the target directory being processed. Output paths remain relative to the original project root.
    • Rule Root Behavior: Each target has its own rule root:
      • Targets within the project root (or CWD) use the project root/CWD as their rule root
      • External targets use themselves as their rule root, ensuring self-contained rule sets
    • Overrides: Supports --overrides (CLI) or rules (MCP) to use a specific set of rules exclusively. When overrides are active, both built-in default rules and any .contextfiles are ignored. Path matching for overrides is still relative to the target directory.
    • Explicit Target Inclusion: Files explicitly provided as targets are always included (bypassing rule checks, but not binary/size checks).
  • Customizable Configuration (.contextfiles / Overrides):
    • Define precisely which files/directories to include or exclude using .gitignore-style patterns applied to the relative path.
    • Patterns starting with ! negate the match (an exclusion pattern). (See Configuration section below).
  • Large Context Handling: Aborts with a DetailedContextSizeError if the total size of included files exceeds a configurable limit (default: 100MB). The error message includes a list of the 10 largest files contributing to the size, helping you identify candidates for exclusion. See the Troubleshooting section for guidance on managing context size.
  • Metadata Headers: Output includes a path header for each included file (e.g., ````path=src/app.py). This can be disabled with list_only`.
  • Encoding Handling: Attempts multiple common text encodings (UTF-8, Latin-1, etc.).
  • List Only Mode: Option to only list the relative paths of files that would be included, without their content.

Platform-specific notes

Windows + WSL

Jinni v0.1.7+ auto-converts WSL paths.

Provide either of these as project_root (CLI --root or MCP argument):

/home/user/project
vscode-remote://wsl+Ubuntu-22.04/home/user/project

No wrappers, mounts, or extra flags requiredβ€”Jinni resolves the UNC path (\\wsl$\...) on Windows automatically.

UNC Path Format: Jinni always uses \\wsl$\<distro>\... for maximum compatibility with all Windows versions supporting WSL. Distro Name Handling: Spaces and most special characters are allowed in the distro name. Only truly illegal UNC characters are replaced with _. Caching: WSL path lookups and conversions are cached for performance. If you install WSL while Jinni is running, restart Jinni to pick up the new wslpath. Opt-out: Set the environment variable JINNI_NO_WSL_TRANSLATE=1 to disable all WSL path translation logic.

Only wsl+<distro> URIs and absolute POSIX paths (starting with /) are translated; for SSH or container remotes, run Jinni inside that environment.

Runtime OSWhat you pass inWhat _translate_wsl_path() returns
Windowsvscode-remote://wsl%2BUbuntu/home/a/b\\wsl$\\Ubuntu\home\a\b
Windows/home/a/b\\wsl$\\Ubuntu\home\a\b (via wslpath)
Linux/WSLvscode-remote://wsl+Ubuntu/home/a/b/home/a/b
Linux/WSL/home/a/b/home/a/b (unchanged)

Examples

  • Dump context of my_project/ to the console:

    jinni ./my_project/ # Process a single directory
    jinni ./src ./docs/README.md # Process multiple targets
    jinni # Process current directory (.)
  • List files that would be included in my_project/ without content:

    jinni -l ./my_project/
    jinni --list-only ./src ./docs/README.md
  • Dump context of my_project/ to a file named context_dump.txt:

    jinni -o context_dump.txt ./my_project/
  • Use override rules from custom.rules instead of .contextfiles:

    jinni --overrides custom.rules ./my_project/
  • Show debug information:

    jinni --debug-explain ./src
  • Dump context (output is automatically copied to clipboard by default):

    jinni ./my_project/
  • Dump context but do not copy to clipboard:

    jinni --no-copy ./my_project/

Development

  • Design Details: DESIGN.md

  • Running Server Locally: During development (after installing with uv pip install -e . or similar), you can run the server module directly:

    python -m jinni.server [OPTIONS]

    Example MCP client configuration for local development:

    {
      "mcpServers": {
        "jinni": {
          // Adjust python path if needed, or ensure the correct environment is active
          "command": "python -m jinni.server"
          // Optionally constrain the server to only read within a tree (recommended for security):
          // "command": "python -m jinni.server --root /absolute/path/to/repo"
        }
      }
    }