
Context Engine
io.github.melonelishPublished by GitHub account melonelishv0.1.0Updated Oct 24, 2026
Compress logs, retrieval chunks, and code context into structured LLM-ready signal.
Overview
Compresses logs, RAG retrieval chunks, and code context into structured, LLM-ready input through a single compress_context tool.
- What you can do
- Context Engine is a task-aware context compression layer exposed over stdio as one MCP tool, compress_context, which takes a mode, a budget, and either raw content or a structured payload. Three modes are supported: logs, which keeps root-cause lines and traceback tails while folding repeated heartbeat, retry, and duplicate noise into counts; rag, which reorders retrieved chunks around a question into high-signal, supporting, and low-signal tiers; and code, which ranks hotspot files using issue terms, test failure output, and path hints. Results come back in a structured envelope with a summary, key facts, discarded noise, and an llm_ready_context block, or a structured error with an error…
- When to use it
- Use it when an agent, RAG pipeline, or coding assistant is being handed context that is too long, too noisy, or poorly ordered, such as long logs with repeated noise, retrieval results dumped in recall order, or a pile of files with no clear fix target. It is aimed at early external trials, integration testing, and developer workflow validation rather than production deployments.
- Requirements
- Runs locally as a Python package (melonelish-context-engine) over stdio, started with the context-engine-mcp command. Requires Python 3.11 to 3.13 and pip, with the optional mcp extra installed for the MCP server. No authentication, environment variables, or headers are declared. Input limits apply: 200000 characters per text segment, 64 structured list items, and 2000000 bytes per input file.
Installation
In SourceWeft
- Open Context Engine in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
Context Engine - 面向 Agent / RAG / AI Coding 的上下文压缩引擎
把噪声日志、检索片段和代码上下文,压缩成大模型更容易使用的高信号输入。
面向 Agent 工作流、RAG 管线、AI Coding 助手的任务感知 Context Compression Layer。
[Python] [Typer CLI] [MCP] [License]
PyPI · GitHub · MCP Registry
为什么需要 Context Engine
很多 Agent / RAG / AI Coding 系统的问题,不是“没有上下文”,而是“上下文太脏、太长、太乱”。
日志里有大量重复 heartbeat 和 retry;RAG 检索结果里混着相关与不相关 chunk;代码修复场景里,模型经常拿到一堆文件,却缺少最小修复线索。
Context Engine 解决的是这个中间层问题:
在把内容交给大模型之前,先按任务类型压缩、排序、去噪,并输出结构化的高信号上下文。
它不是普通摘要工具,而是一个更偏工程化的上下文整理层。
能力边界问题
系统架构
核心理念:先把上下文变成可解释、可预算、可消费的结构,再交给 LLM。
数据流
核心能力
1. logs:根因导向的日志压缩
logs 模式面向长日志、重复日志、异常栈和混合噪声。
2. rag:围绕问题的证据重排
rag 模式接收 question 和 chunks,把检索结果从“按召回顺序堆叠”变成“围绕问题排序”。
3. code:最小修复上下文
code 模式接收 issue、可选 test_output 和 files,用于给 AI Coding 助手准备更聚焦的修复输入。
4. CLI + MCP 双入口
同一套压缩逻辑可通过三种方式使用:
快速开始
前置要求
安装
从 PyPI 安装发布包:
运行示例
CLI 使用
输入格式
logs:纯文本
rag:JSON
code:JSON
MCP 使用
通过 stdio 启动 MCP Server:
当前暴露一个工具:
示例错误返回:
输出契约
CLI 和 MCP 都返回统一结构:
成功结果会包含 schema version、summary、key facts、被丢弃或降权的噪声,以及 llm_ready_context。
安全边界
当前内置限制:
这些限制用于避免外部工作流把任意超大 payload 直接打进工具。
当前已支持
- Python
3.11到3.13 logs/rag/code三种模式- 三种模式的 CLI 使用
- 通过
compress_context暴露 MCP 工具 - 纯文本日志输入
- JSON 格式的 RAG 和 code 输入
- 结构化成功 / 失败 envelope
- 基础 benchmark 和 GitHub Actions CI
暂不支持
- PDF、图片、Office 文件等二进制输入
- embedding-aware reranking
- 仓库级依赖图分析
- 跨未来大版本的长期兼容性承诺
- 生产级鉴权、持久化、监控和审计能力
Benchmark
Benchmark 资料位于:
当前样例集体现的行为:
v0.1.0 的 benchmark 还很小,适合作为回归检查和展示样例,不代表完整生产评测。
开发
CI 会在 push 和 pull request 时运行安装、测试和 benchmark 生成检查。
发布状态
当前版本目标:v0.1.0
已发布渠道:
- PyPI: https://pypi.org/project/melonelish-context-engine/
- MCP Registry: https://registry.modelcontextprotocol.io/v0/servers/io.github.melonelish/context-engine
这个版本适合早期外部试用、集成测试和开发者工作流验证。它已经具备可复用包结构、测试、文档,以及可直接安装的 PyPI / MCP Registry 发布入口,但仍然是范围明确的早期 beta。
Roadmap
- 引入 embedding 或 reranker 驱动的 RAG 排序。
- 加强 code hotspot 识别,加入更可靠的结构化代码信号。
- 扩展 benchmark,加入更多真实脏数据样本。
- 发布更易安装的正式包版本。
- 增加更多 Agent Runtime / MCP 集成示例。
License
本项目采用 MIT License。
Source: README.md at commit 288ad17
Tools
0Version history
1- v0.1.0LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts