LL

LLM Context MCP Server for Code Sharing

Share code with LLMs using an MCP server via Model Context Protocol or clipboard, with rule-based task switching and smart code outlining.

Overview

LLM Context MCP Server provides a lightweight, rule-driven way to share relevant code and project files with large language models (LLMs). It runs as an MCP (Model Context Protocol) server or can copy formatted project context to the clipboard, letting you give an LLM focused snippets instead of dumping an entire repository. The tool reduces friction when debugging, refactoring, or delegating sub-tasks to agents by combining rule-based file selection, smart excerpting, and on-demand file fetch via MCP.

Designed for developers who want reproducible, task-specific context in chats or agents, LLM Context prevents token bloat, surfaces the most relevant files and tests, and enables LLMs (or agent sub-processes) to request additional artifacts during a session.

Features

  • Rule-based context selection: define composable rules to describe what files and excerpts matter for a task.
  • MCP server support: expose lc_* tools to chat-based LLMs (e.g., Claude Desktop) so models can fetch files on demand.
  • Clipboard and CLI workflows: copy formatted context to clipboard for manual chats, or use commands in agents and shells.
  • Smart outlining and excerpting: generate concise code outlines and content excerpts that respect token limits.
  • Validation and previews: simulate rule output and size before using it in a conversation.
  • Extensible rule library: prompt, filter, instruction, style, and excerpt rules to mix-and-match behavior.

Installation / Configuration

Install via UV Tools (recommended):

uv tool install "llm-context>=0.6.0"

Initialize a project (creates rule folder and basic config):

cd /path/to/your/project
lc-init

Add LLM Context as an MCP server in Claude Desktop (example path):

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

After editing the config, restart Claude Desktop (or your MCP-capable client) so it can call the server.

Available Tools / Resources

Primary CLI and MCP-facing tools:

  • lc-init — initialize project configuration and rule directory
  • lc-select — interactively or automatically choose files for the active rule
  • lc-context — generate formatted context and copy to clipboard (or stdout)
  • lc-preview — simulate rule selection and show size/coverage
  • lc-outlines / lc_outlines — produce code structure excerpts for a rule
  • lc-missing / lc_missing — MCP endpoint to fetch specific files or implementations on demand
  • lc-set-rule — switch the active rule used for selection

See the project on GitHub for source, examples, and rule templates: https://github.com/cyberchitta/llm-context.py

Core Concepts (brief)

Rules are YAML+Markdown files which describe the task scope and how to compose other rules. A rule can include filters (which files to include/exclude), excerpters (how to excerpt content), and human-facing instructions.

Example rule fragment:

---
description: "Debug API authentication"
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.

Rule categories:

  • prm- (prompt rules) — produce project context
  • flt- (filter rules) — file inclusion/exclusion
  • ins- (instruction rules) — task instructions
  • sty- (style rules) — coding standards to show
  • exc- (excerpt rules) — control how files are excerpted

Rules are composable so you can build complex selection logic from small, reusable parts.

Use Cases

  1. Human clipboard workflow (chat):

    • One-time: run lc-init in the repo.
    • Daily: run lc-select to pick a rule or choose files, then lc-context to copy a condensed, annotated context to the clipboard. Paste into any chat UI.

    Example:

    lc-select
    lc-context
    # Paste into your chat
    
  2. Claude Desktop (MCP integration):

    • Configure llm-context as an MCP server (see config snippet above).
    • Paste a short project overview into Claude and let the assistant call lc_outlines, lc_preview, or lc_missing to fetch details as needed. The model can request specific files instead of you pasting everything.
  3. Agent / automation (CLI):

    • An agent exploring the repo can call lc-outlines to understand structure, create or receive a tmp-prm-* rule for a subtask, preview it with lc-preview, and then generate focused context with lc-context to pass to a sub-agent.

    Example:

    lc-outlines
    lc-preview tmp-prm-oauth-task
    lc-context tmp-prm-oauth-task
    

Commands at a glance

Getting started tips

  • Start with a small number of rules (e.g., developer overview, bug debug, refactor) and iterate.
  • Use preview to avoid hitting token limits before pasting into a chat.
  • Leverage MCP integration for interactive model-driven exploration — let the model request specific files with lc_missing instead of preemptively including everything.

For detailed examples, rule syntax, and advanced patterns, consult the repository: https://github.com/cyberchitta/llm-context.py

CommandPurpose
lc-initInitialize project config and rule directory
lc-selectSmart file selection for the active rule
lc-contextGenerate context and copy to clipboard
lc-context -pInclude prompting instructions in output
lc-previewValidate rule selection and estimate size
lc-outlinesProduce excerpted outline of project files
lc-missingMCP endpoint to fetch specific missing files
lc-set-rule Switch the active rule