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):
Initialize a project (creates rule folder and basic config):
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:
excerpters:
also-include:
full-files:
---
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
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:
# Paste into your chatClaude 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.
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:
Commands at a glance
| Command | Purpose |
|---|---|
| lc-init | Initialize project config and rule directory |
| lc-select | Smart file selection for the active rule |
| lc-context | Generate context and copy to clipboard |
| lc-context -p | Include prompting instructions in output |
| lc-preview | Validate rule selection and estimate size |
| lc-outlines | Produce excerpted outline of project files |
| lc-missing | MCP endpoint to fetch specific missing files |
lc-set-rule | Switch the active rule | Getting started tips
For detailed examples, rule syntax, and advanced patterns, consult the repository: https://github.com/cyberchitta/llm-context.py |