/ Directory / Playground / llm-context.py
● Community cyberchitta ⚡ Instant

llm-context.py

by cyberchitta · cyberchitta/llm-context.py

Share just the right slice of your codebase with any LLM — rule-driven file selection, outlines, and on-demand fetches, not 'paste it all'.

llm-context.py is a rule-based code-sharing tool that exposes its output via MCP or clipboard. Instead of uploading your whole repo, you define composable rules (filter, instruction, style, excerpt) per task and ship a focused context. The MCP flavor lets the LLM ask for more files on demand.

Why use it

Key features

Live Demo

What it looks like in practice

llm-context-py.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "llm-context-py": {
      "command": "uvx",
      "args": [
        "llm-context.py"
      ],
      "_inferred": true
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "llm-context-py": {
      "command": "uvx",
      "args": [
        "llm-context.py"
      ],
      "_inferred": true
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "llm-context-py": {
      "command": "uvx",
      "args": [
        "llm-context.py"
      ],
      "_inferred": true
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "llm-context-py": {
      "command": "uvx",
      "args": [
        "llm-context.py"
      ],
      "_inferred": true
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "llm-context-py",
      "command": "uvx",
      "args": [
        "llm-context.py"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "llm-context-py": {
      "command": {
        "path": "uvx",
        "args": [
          "llm-context.py"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add llm-context-py -- uvx llm-context.py

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use llm-context.py

Ship a focused code-review context to your LLM

👤 Developers tired of pasting 3000 lines ⏱ ~15 min intermediate

When to use: You're about to ask 'review my auth module' and don't want the whole repo in context.

Prerequisites
  • llm-context.py installed — uv tool install 'llm-context>=0.6.0'
  • Initialized in your repolc-init in your repo root
Flow
  1. Create a filter rule for auth
    Create an lc filter rule 'flt-auth' that includes src/auth/** and src/middleware/auth*.ts.✓ Copied
    → Rule file created under .lc/
  2. Preview what the rule selects
    Run lc_preview on flt-auth — show me which files will be sent and total token count.✓ Copied
    → File list + token count
  3. Share context with the LLM via MCP
    Using the flt-auth rule, review the module for security issues. If you need to see a specific file not included, ask via lc_missing.✓ Copied
    → Review with targeted file requests

Outcome: A code review that fits in context and can still explore — no manual paste.

Pitfalls
  • Rule too narrow → LLM can't understand callers of your module — Include interface / types of neighboring modules, use outlines for the rest
  • Rule too broad → token budget blown — Start broad, watch lc_preview, tighten until under your client's limits
Combine with: filesystem

Give an LLM a structural map of a huge codebase

👤 Engineers onboarding to unfamiliar monorepos ⏱ ~20 min intermediate

When to use: 100k+ LOC repo; you need orientation, not all the code.

Flow
  1. Generate outline
    lc_outlines for the whole repo — classes, top-level functions, exports per file. Skip bodies.✓ Copied
    → Skeletal outline with a few thousand lines
  2. Ask orientation questions
    Given the outline, where's the entry point, where's routing defined, and which files hold the data-layer abstractions?✓ Copied
    → Architectural answers
  3. Drill in on one area
    Show me the full contents of the three files that define routing via lc_missing.✓ Copied
    → Specific files expand into context

Outcome: A guided tour without ever pasting the whole repo.

Attach project style rules to every prompt

👤 Teams with specific conventions ⏱ ~10 min beginner

When to use: You want Claude to always know 'we use pytest, not unittest' without repeating.

Flow
  1. Write a style rule
    Create sty-python rule: 'pytest only, type hints required, black formatting'.✓ Copied
    → Rule saved
  2. Apply automatically
    Use prm-default which composes flt-current + sty-python + ins-standards for every context.✓ Copied
    → Rule auto-attached

Outcome: Per-task conventions enforced without manual boilerplate.

Combine with: drift

Combinations

Pair with other MCPs for X10 leverage

llm-context-py + drift

drift records conventions; llm-context pushes only relevant files + style rules per task

Load drift conventions for this repo, then use lc with rule flt-auth + sty-ts to review the auth module.✓ Copied
llm-context-py + filesystem

After reviewing, filesystem applies edits

Based on the llm-context review, use filesystem to apply the suggested edits to src/auth/.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
lc_outlines rule?: str Orient on large codebases free (local)
lc_preview rule: str Before shipping context, verify scope free
lc_missing path: str LLM calls this mid-conversation to request a file free

Cost & Limits

What this costs to run

API quota
None
Tokens per call
Depends entirely on your rule scope — that's the point
Monetary
Free, open source
Tip
Always run lc_preview before lc_outlines/shipping context — one second of preview saves thousands of tokens.

Security

Permissions, secrets, blast radius

Credential storage: None
Data egress: Only to whichever LLM client/provider you pipe context into

Troubleshooting

Common errors and fixes

No rules found

Run lc-init in repo root to create .lc/ scaffolding.

Verify: ls .lc/
lc_preview token count surprisingly high

Your filter is too loose or includes generated files. Narrow globs and add ignore patterns.

Verify: lc_preview again
MCP tool not available

Use uvx --from llm-context lc-mcp in your MCP server config.

Verify: claude mcp list

Alternatives

llm-context.py vs others

AlternativeWhen to use it insteadTradeoff
repomix / ai-digestYou want a single-file dump, not MCP toolsNo interactive lc_missing; static snapshot
filesystem MCPYou want raw file accessNo rule-based selection or outlines
driftYou want persistent convention memory, not per-task file bundlingDifferent problem entirely

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills