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
13.3K downloads
286 stars

LLM Context is a tool that reduces friction when providing project files to LLMs. It enables smart file selection and instant context sharing, turning what was once a tedious copy-paste process into a seamless workflow that gets you from "I need to share my project" to productive AI collaboration in seconds.

Installation

You can install LLM Context using the uv package manager:

uv tool install "llm-context>=0.5.0"

Basic Usage

Here's how to get started with LLM Context:

Setup and Daily Workflow

# One-time setup
cd your-project
lc-init

# Daily usage
lc-select
lc-context

The lc-select command intelligently selects relevant project files, while lc-context generates formatted context that you can directly paste into your LLM chat.

MCP Integration

For a more seamless experience, you can integrate LLM Context with MCP (Model Context Protocol). This allows the AI to access additional files directly during conversations.

Setting Up MCP

Add this configuration to your MCP settings:

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

Project Customization

You can customize how LLM Context works with your project by creating specialized rules:

Creating Custom Filters

# Create project-specific filters
cat > .llm-context/rules/flt-repo-base.md << 'EOF'
---
compose:
  filters: [lc/flt-base]
gitignores:
  full-files: ["*.md", "/tests", "/node_modules"]
---
EOF

Customizing Development Rules

# Customize main development rule
cat > .llm-context/rules/prm-code.md << 'EOF'
---
instructions: [lc/ins-developer, lc/sty-python]
compose:
  filters: [flt-repo-base]
  excerpters: [lc/exc-base]
---
Additional project-specific guidelines and context.
EOF

Deployment Patterns

LLM Context supports different ways to share context based on your LLM environment:

  • System Message: lc-context -p (For AI Studio, etc.)
  • Single User Message: lc-context -p -m (For Grok, etc.)
  • Separate Messages: lc-prompt + lc-context -m
  • Project/Files (included): lc-context (For Claude Projects, etc.)
  • Project/Files (searchable): lc-context -m (force into context)

Core Commands

Here are the main commands you'll use with LLM Context:

Command Purpose
lc-init Initialize project configuration
lc-select Select files based on current rule
lc-context Generate and copy context
lc-context -p Generate context with prompt
lc-context -m Send context as separate message
lc-context -nt No tools (for Project/Files inclusion)
lc-context -f Write context to file
lc-set-rule <n> Switch between rules
lc-missing Handle file and context requests (non-MCP)

Rule System

LLM Context uses a structured rule system with five categories:

Rule Categories

  • Prompt Rules (prm-): Generate project contexts
  • Filter Rules (flt-): Control file inclusion
  • Instruction Rules (ins-): Provide guidelines
  • Style Rules (sty-): Enforce coding standards
  • Excerpt Rules (exc-): Configure extractions for context reduction

Example Rule

Here's an example of a rule for debugging authentication issues:

---
description: "Debug API authentication issues"
compose:
  filters: [lc/flt-no-files]
  excerpters: [lc/exc-base]
also-include:
  full-files: ["/src/auth/**", "/tests/auth/**"]
---
Focus on authentication system and related tests.

AI-Assisted Rule Creation

LLM Context provides two approaches to help you create custom rules with AI assistance:

Using the Claude Skill (Recommended for Claude Desktop/Code)

lc-init  # Installs skill to ~/.claude/skills/
# Restart Claude Desktop or Claude Code

# Share any project context (overview is required)
lc-context  # Can use any rule - overview will be included

# Then ask the Skill to help create a rule:
# "Create a rule for refactoring authentication to JWT"

Using Instruction Rules (Works with Any LLM)

# Load the rule creation framework into context
lc-set-rule lc/prm-rule-create
lc-select
lc-context -nt

# Paste into any LLM and describe your task
# "I need to add OAuth integration to the auth system"

Workflow Patterns

Daily Development

lc-set-rule lc/prm-developer
lc-select
lc-context
# AI can review changes, access additional files as needed

Focused Tasks

# Share project context
lc-context

# Then ask Skill (Claude Desktop/Code):
# "Create a rule for [your task]"

# Or work with any LLM using instruction rules:
# lc-set-rule lc/prm-rule-create && lc-context -nt

Key Benefits of MCP Integration

  • Code review: AI examines your changes for completeness/correctness
  • Additional files: AI accesses initially excluded files when needed
  • Change tracking: See what's been modified during conversations
  • Zero friction: No manual file operations during development discussions

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