
context-mode
by mksglu·★ 14,865·综合分 62
一个 MCP server,通过沙箱化工具输出,为 AI 代理优化上下文窗口,减少 98%。
概述
Context Mode 是一个 MCP server,旨在解决 AI 编码代理的上下文窗口优化问题。它提供四个关键解决方案:通过沙箱化工具将原始数据保持在上下文窗口之外(减少 98%),通过在 SQLite 中跟踪所有操作并在需要时仅检索相关信息来实现会话连续性,鼓励 LLM 编写脚本而非直接处理大量数据的'思考代码'方法,以及不强制执行散文风格响应的灵活输出样式。该项目支持 15 个平台,已被微软、谷歌、Meta 和亚马逊等主要科技公司采用。
试试问 AI
装完之后,这里有 6 个你可以让 AI 做的事:
什么时候选它
当处理大型代码库或长时间编码会话时,上下文溢出成为瓶颈,特别是使用支持的平台如Claude Code或Gemini CLI时,应选择Context Mode。
什么时候不要选它
如果你需要在上下文中保留完整的原始工具输出,或者使用的是需要手动实现所有路由逻辑的不支持平台,应避免使用。
此 server 暴露的工具
从 README 抽取出 11 个工具ctx_batch_executeExecutes multiple code snippets in a batch
ctx_executeExecutes code in the specified language and returns results
ctx_execute_fileExecutes a code file and returns the results
ctx_indexIndexes content for later retrieval
ctx_searchSearches indexed content using BM25
ctx_fetch_and_indexFetches content from a source and indexes it
ctx_statsShows context savings and usage statistics
ctx_doctorRuns diagnostic checks on the system
ctx_upgradeUpgrades context-mode to the latest version
ctx_purgeDeletes all indexed content from the knowledge base
ctx_insightOpens personal analytics dashboard
可对比工具
安装
安装
Claude Code
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-modeGemini CLI
npm install -g context-mode添加到 ~/.gemini/settings.json:
{
"mcpServers": {
"context-mode": {
"command": "context-mode"
}
},
"hooks": {
"BeforeTool": [{
"matcher": "run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli beforetool" }]
}],
"AfterTool": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli aftertool" }]
}],
"PreCompress": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli precompress" }]
}],
"SessionStart": [{
"matcher": "",
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli sessionstart" }]
}]
}
}手动 MCP(适用于 Claude Desktop)
{
"mcpServers": {
"context-mode": {
"command": "npx",
"args": ["-y", "context-mode"]
}
}
}FAQ
- Context Mode 如何减少上下文使用?
- Context Mode 通过沙箱化工具输出减少 98% 的上下文使用。它将原始数据存储在 SQLite 中而非放入上下文窗口,只对其进行索引,使模型能够在需要时检索相关信息。
- Context Mode 是否与我喜欢的 AI 编码平台兼容?
- 是的,Context Mode 支持 15 个平台,包括 Claude Code、Gemini CLI、VS Code Copilot、Cursor 等。它为每个平台提供具体的安装说明。
context-mode 对比
最后更新于 · 由 README + GitHub 公开数据自动生成。