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
Provider
cyberchitta
Release date
Dec 06, 2024
Language
Python
Package
Stats
19.0K downloads
208 stars

LLM Context is a tool that enables developers to inject relevant content from code and text projects into Large Language Model chat interfaces. It supports direct LLM integration via the Model Context Protocol (MCP) and offers a clipboard workflow for any chat interface, leveraging smart file selection based on .gitignore patterns.

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

Using MCP with Claude Desktop

To set up MCP integration with Claude Desktop, add the following to your '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. Saying to Claude: "I would like to work with my project" (Claude will ask for the project path)
  2. Directly specifying: "I would like to work with my project /path/to/your/project"

Recommended Workflow

For best results, combine Claude's Project Knowledge UI with MCP for dynamic code access. This provides both comprehensive understanding and access to the latest changes.

CLI Usage

Basic Workflow

  1. Navigate to your project's root directory

  2. Initialize the repository (only needed once):

    lc-init
    
  3. Select files for inclusion:

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

    lc-context
    

    Optional flags:

    • -p to include prompt instructions
    • -u to include user notes
    • -f FILE to write to output file
  5. Paste the context into your LLM interface:

    • Claude Pro: Paste into Project Knowledge section
    • Custom GPTs: Paste into knowledge section
    • Regular chats: Use lc-context -p to include 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

Core Commands

File Selection and Context Generation

  • lc-init: Initialize project configuration
  • lc-set-rule <n>: Switch between rules (system rules are prefixed with "lc-")
  • lc-sel-files: Select files for inclusion
  • 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

Code Navigation Features

  • lc-sel-outlines: Select files for outline generation
  • lc-outlines: Generate outlines for code files
  • lc-clip-implementations: Extract code implementations requested by LLMs (C/C++ not supported)

Advanced Features

LLM Context provides several advanced features:

  • Smart file selection using .gitignore patterns
  • Rule-based profiles for different use cases:
    • System rules (prefixed with "lc-") provide default functionality
    • User-defined rules can be created or extend existing rules
  • Code navigation features:
    • Smart code outlines showing high-level structure of your codebase
    • Definition implementation extraction for reviewing specific code sections
  • Customizable templates and prompts

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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