MCP ExplorerExplorer

LLM Context

@cyberchittaon 12 days ago
227 Apache 2.0
FreeCommunity
Dev Tools
#LLM#Context Injection#Development#ChatGPT#Productivity
Provides a repo-packing MCP tool with configurable profiles that specify file inclusion/exclusion patterns and optional prompts.

Overview

What is LLM Context

LLM Context is a tool designed to help developers efficiently integrate relevant content from code and text projects into Large Language Model chat interfaces. It utilizes .gitignore patterns for file selection and offers both a CLI clipboard workflow and integration with the Model Context Protocol (MCP) for real-time project context access.

Use cases

LLM Context is beneficial for projects involving code repositories and collections of text/markdown/html documents. It supports both standard chat interfaces and environments with persistent context, enabling dynamic interactions with AI systems and optimized responses based on project-specific understanding.

How to use

To get started, navigate to your project directory and initialize with ‘lc-init’. Use ‘lc-sel-files’ to select files, generate context with ‘lc-context’, and then paste this context into your LLM interface. For efficient assistance, manage any additional file requests using ‘lc-clip-files’.

Key features

Key features include smart file selection leveraging .gitignore patterns, rule-based profiles for flexible usage, automatic code outlines for better navigation, and the ability to extract specific code implementations upon request. These enhance the overall interaction between developers and LLMs.

Where to use

LLM Context can be integrated into various environments like IDEs, CLI applications, and LLM chat interfaces that support context retention, such as Claude Pro and Custom GPTs, facilitating a seamless developer experience across different platforms.

Content

LLM Context

License
PyPI version
Downloads

LLM Context is a tool that helps developers quickly inject relevant content from code/text projects into Large Language Model chat interfaces. It leverages .gitignore patterns for smart file selection and provides both a streamlined clipboard workflow using the command line and direct LLM integration through the Model Context Protocol (MCP).

Note: This project was developed in collaboration with several Claude Sonnets - 3.5, 3.6 and 3.7 (and more recently Grok-3 as well), using LLM Context itself to share code during development. All code in the repository is human-curated (by me 😇, @restlessronin).

Why LLM Context?

For an in-depth exploration of the reasoning behind LLM Context and its approach to AI-assisted development, check out our article: LLM Context: Harnessing Vanilla AI Chats for Development

To see LLM Context in action with real-world examples and workflows, read: Full Context Magic - When AI Finally Understands Your Entire Project

Current Usage Patterns

  • Direct LLM Integration: Native integration with Claude Desktop via MCP protocol
  • Chat Interface Support: Works with any LLM chat interface via CLI/clipboard
    • Optimized for interfaces with persistent context like Claude Projects and Custom GPTs
    • Works equally well with standard chat interfaces
  • Project Types: Suitable for code repositories and collections of text/markdown/html documents
  • Project Size: Optimized for projects that fit within an LLM’s context window. Large project support is in development

Installation

Install LLM Context using uv:

uv tool install "llm-context>=0.3.0"

To upgrade to the latest version:

uv tool upgrade llm-context

Warning: LLM Context is under active development. Updates may overwrite configuration files prefixed with lc-. We recommend all configuration files be version controlled for this reason.

Quickstart

MCP with Claude Desktop

Add to ‘claude_desktop_config.json’:

{
  "mcpServers": {
    "CyberChitta": {
      "command": "uvx",
      "args": ["--from", "llm-context", "lc-mcp"]
    }
  }
}

Once configured, you can start working with your project in two simple ways:

  1. Say: “I would like to work with my project”
    Claude will ask you for the project root path.

  2. Or directly specify: “I would like to work with my project /path/to/your/project”
    Claude will automatically load the project context.

Preferred Workflow: Combining Project UI with MCP

For optimal results, combine initial context through Claude’s Project Knowledge UI with dynamic code access via MCP. This provides both comprehensive understanding and access to latest changes. See Full Context Magic for details and examples.

CLI Quick Start and Typical Workflow

  1. Navigate to your project’s root directory
  2. Initialize repository: lc-init (only needed once)
  3. Select files: lc-sel-files
  4. (Optional) Review selected files in .llm-context/curr_ctx.yaml
  5. Generate context: lc-context (with optional flags: -p for prompt, -u for user notes)
  6. Use with your preferred interface:
  • Project Knowledge (Claude Pro): Paste into knowledge section
  • GPT Knowledge (Custom GPTs): Paste into knowledge section
  • Regular chats: Use lc-context -p to include instructions
  1. When the LLM requests additional files:
    • Copy the file list from the LLM
    • Run lc-clip-files
    • Paste the contents back to the LLM

Core Commands

  • lc-init: Initialize project configuration
  • lc-set-rule <n>: Switch rules (system rules are prefixed with “lc-”)
  • lc-sel-files: Select files for inclusion
  • lc-sel-outlines: Select files for outline generation
  • lc-context [-p] [-u] [-f FILE]: Generate and copy context
    • -p: Include prompt instructions
    • -u: Include user notes
    • -f FILE: Write to output file
  • lc-prompt: Generate project instructions for LLMs
  • lc-clip-files: Process LLM file requests
  • lc-changed: List files modified since last context generation
  • lc-outlines: Generate outlines for code files
  • lc-clip-implementations: Extract code implementations requested by LLMs (doesn’t support C/C++)

Features & Advanced Usage

LLM Context provides advanced features for customizing how project content is captured and presented:

  • Smart file selection using .gitignore patterns
  • Multiple rule-based profiles for different use cases
    • System rules (prefixed with “lc-”) provide default functionality
    • User-defined rules can be created independently or extend existing rules
  • Code Navigation Features:
    1. Smart Code Outlines: Allows LLMs to view the high-level structure of your codebase with automatically generated outlines highlighting important definitions
    2. Definition Implementation Extraction: Paste full implementations of specific definitions that are requested by LLMs after they review the code outlines, using the lc-clip-implementations command
  • Customizable templates and prompts

See our User Guide for detailed documentation of these features.

Similar Tools

Check out our comprehensive list of alternatives - the sheer number of tools tackling this problem demonstrates its importance to the developer community.

Acknowledgments

LLM Context evolves from a lineage of AI-assisted development tools:

  • This project succeeds LLM Code Highlighter, a TypeScript library I developed for IDE integration.
  • The concept originated from my work on RubberDuck and continued with later contributions to Continue.
  • LLM Code Highlighter was heavily inspired by Aider Chat. I worked with GPT-4 to translate several Aider Chat Python modules into TypeScript, maintaining functionality while restructuring the code.
  • This project uses tree-sitter tag query files from Aider Chat.
  • LLM Context exemplifies the power of AI-assisted development, transitioning from Python to TypeScript and back to Python with the help of GPT-4 and Claude-3.5-Sonnet.

I am grateful for the open-source community’s innovations and the AI assistance that have shaped this project’s evolution.

I am grateful for the help of Claude-3.5-Sonnet in the development of this project.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Tools

lc-project-context
IMPORTANT: First check if project context is already available in the conversation before making any new requests. Use lc-get-files for retrieving specific files, and only use this tool when a broad repository overview is needed. Generates a structured repository overview including: 1) Directory tree with file status (✓ full, ○ outline, ✗ excluded) 2) Complete contents of key files 3) Smart outlines highlighting important definitions in supported languages. The output is customizable via profiles that control file inclusion rules and presentation format. The assistant tracks previously retrieved project context in the conversation and checks this history before making new requests.
lc-get-files
IMPORTANT: Check previously retrieved file contents before making new requests. Retrieves (read-only) complete contents of specified files from the project. For this project, this is the preferred method for all file content analysis and text searches - simply retrieve the relevant files and examine their contents. The assistant cannot modify files with this tool - it only reads their contents.
lc-list-modified-files
IMPORTANT: First get the generation timestamp from the project context. Returns a list of paths to files that have been modified since a given timestamp. This is typically used to track which files have changed during the conversation. After getting the list, use lc-get-files to examine the contents of any modified files of interest.
lc-code-outlines
Returns smart outlines highlighting important definitions in all supported code files. This provides a high-level overview of code structure without retrieving full file contents. Outlines show key definitions (classes, functions, methods) in the codebase. Use lc-get-implementations to retrieve the full implementation of any definition shown in these outlines.
lc-get-implementations
Retrieves complete code implementations of definitions identified in code outlines. Provide a list of file paths and definition names to get their full implementations. This tool works with all supported languages except C and C++.

Comments