/ Каталог / Песочница / llm-context.py
● Сообщество cyberchitta ⚡ Сразу

llm-context.py

автор 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.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

llm-context-py.replay ▶ готово
0/0

Установка

Выберите клиент

~/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
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

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

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

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

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

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

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

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

Continue использует массив объектов серверов, а не map.

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

Добавьте в context_servers. Zed перезагружается автоматически.

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

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: llm-context.py

Ship a focused code-review context to your LLM

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

Когда использовать: You're about to ask 'review my auth module' and don't want the whole repo in context.

Предварительные требования
  • llm-context.py installed — uv tool install 'llm-context>=0.6.0'
  • Initialized in your repolc-init in your repo root
Поток
  1. Create a filter rule for auth
    Create an lc filter rule 'flt-auth' that includes src/auth/** and src/middleware/auth*.ts.✓ Скопировано
    → 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.✓ Скопировано
    → 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.✓ Скопировано
    → Review with targeted file requests

Итог: A code review that fits in context and can still explore — no manual paste.

Подводные камни
  • 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
Сочетать с: filesystem

Give an LLM a structural map of a huge codebase

👤 Engineers onboarding to unfamiliar monorepos ⏱ ~20 min intermediate

Когда использовать: 100k+ LOC repo; you need orientation, not all the code.

Поток
  1. Generate outline
    lc_outlines for the whole repo — classes, top-level functions, exports per file. Skip bodies.✓ Скопировано
    → 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?✓ Скопировано
    → Architectural answers
  3. Drill in on one area
    Show me the full contents of the three files that define routing via lc_missing.✓ Скопировано
    → Specific files expand into context

Итог: A guided tour without ever pasting the whole repo.

Attach project style rules to every prompt

👤 Teams with specific conventions ⏱ ~10 min beginner

Когда использовать: You want Claude to always know 'we use pytest, not unittest' without repeating.

Поток
  1. Write a style rule
    Create sty-python rule: 'pytest only, type hints required, black formatting'.✓ Скопировано
    → Rule saved
  2. Apply automatically
    Use prm-default which composes flt-current + sty-python + ins-standards for every context.✓ Скопировано
    → Rule auto-attached

Итог: Per-task conventions enforced without manual boilerplate.

Сочетать с: drift

Комбинации

Сочетайте с другими MCP — эффект x10

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.✓ Скопировано
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/.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
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

Стоимость и лимиты

Во что обходится

Квота API
None
Токенов на вызов
Depends entirely on your rule scope — that's the point
Деньги
Free, open source
Совет
Always run lc_preview before lc_outlines/shipping context — one second of preview saves thousands of tokens.

Безопасность

Права, секреты, радиус поражения

Хранение учётных данных: None
Исходящий трафик: Only to whichever LLM client/provider you pipe context into

Устранение неполадок

Частые ошибки и исправления

No rules found

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

Проверить: ls .lc/
lc_preview token count surprisingly high

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

Проверить: lc_preview again
MCP tool not available

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

Проверить: claude mcp list

Альтернативы

llm-context.py в сравнении

АльтернативаКогда использоватьКомпромисс
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

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills