LLM Code Context MCP server

Streamlines code context sharing with LLMs by implementing smart file selection, code outlining, and multi-language support for efficient code reviews and documentation generation.
Back to servers
Setup instructions
Provider
cyberchitta
Release date
Dec 06, 2024
Language
Python
Package
Stats
18.3K downloads
246 stars

LLM Context is a tool that streamlines the integration of code and text projects into Large Language Model chat interfaces. It intelligently selects relevant files from your projects and provides both clipboard workflow via command line and direct LLM integration through the Model Context Protocol (MCP).

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-. Consider version controlling your configuration files.

Using with Claude Desktop (MCP)

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 by either:

  1. Asking Claude: "I would like to work with my project" Claude will prompt you for the project root path.

  2. Directly specifying: "I would like to work with my project /path/to/your/project" Claude will automatically load the project context.

Optimal Workflow with Claude

For best 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.

Command Line Usage

Basic Workflow

  1. Navigate to your project's root directory

  2. Initialize repository (only once):

    lc-init
    
  3. Select files:

    lc-sel-files
    
  4. Generate and copy context:

    lc-context
    

    With optional flags:

    lc-context -p  # Include prompt instructions
    lc-context -u  # Include user notes
    lc-context -f output.txt  # Write to file
    
  5. Paste the context into your preferred LLM interface:

    • Claude Projects knowledge section
    • Custom GPT knowledge section
    • Regular chat (use -p flag for instructions)
  6. When the LLM requests additional files:

    • Copy the file list from the LLM
    • Run lc-clip-files
    • Paste the contents back to the LLM

Key Commands

  • lc-init: Initialize project configuration
  • lc-set-rule <n>: Switch between different selection rules
  • 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
  • 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

Advanced Features

Smart File Selection

LLM Context uses .gitignore-like patterns to intelligently select which files to include.

Rule-Based Profiles

  • System rules (prefixed with "lc-") provide default functionality
  • User-defined rules can be created independently or extend existing rules

Code Navigation

  1. Smart Code Outlines: Generate high-level structure of your codebase

    lc-outlines
    
  2. Definition Implementation Extraction: Extract specific code implementations

    lc-clip-implementations
    

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 "CyberChitta" '{"command":"uvx","args":["--from","llm-context","lc-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": {
        "CyberChitta": {
            "command": "uvx",
            "args": [
                "--from",
                "llm-context",
                "lc-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": {
        "CyberChitta": {
            "command": "uvx",
            "args": [
                "--from",
                "llm-context",
                "lc-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