MCP Catalogs
首页context-mode screenshot

context-mode

by mksglu·14,865·综合分 62

一个 MCP server,通过沙箱化工具输出,为 AI 代理优化上下文窗口,减少 98%。

ai-llmdeveloper-toolsproductivity
1,055
Forks
12
活跃 Issue
本月
最近提交
2 天前
收录于

概述

Context Mode 是一个 MCP server,旨在解决 AI 编码代理的上下文窗口优化问题。它提供四个关键解决方案:通过沙箱化工具将原始数据保持在上下文窗口之外(减少 98%),通过在 SQLite 中跟踪所有操作并在需要时仅检索相关信息来实现会话连续性,鼓励 LLM 编写脚本而非直接处理大量数据的'思考代码'方法,以及不强制执行散文风格响应的灵活输出样式。该项目支持 15 个平台,已被微软、谷歌、Meta 和亚马逊等主要科技公司采用。

试试问 AI

装完之后,这里有 6 个你可以让 AI 做的事:

:处理大文件或多个文档时优化上下文使用
:跨 AI 编码会话保持会话连续性而不丢失编辑
:通过执行代码而非读取文件内容来减少令牌消耗
:通过最小化上下文溢出提高 AI 代理性能
:Context Mode 如何减少上下文使用?
:Context Mode 是否与我喜欢的 AI 编码平台兼容?

什么时候选它

当处理大型代码库或长时间编码会话时,上下文溢出成为瓶颈,特别是使用支持的平台如Claude Code或Gemini CLI时,应选择Context Mode。

什么时候不要选它

如果你需要在上下文中保留完整的原始工具输出,或者使用的是需要手动实现所有路由逻辑的不支持平台,应避免使用。

此 server 暴露的工具

从 README 抽取出 11 个工具
  • ctx_batch_execute

    Executes multiple code snippets in a batch

  • ctx_execute

    Executes code in the specified language and returns results

  • ctx_execute_file

    Executes a code file and returns the results

  • ctx_index

    Indexes content for later retrieval

  • ctx_search

    Searches indexed content using BM25

  • ctx_fetch_and_index

    Fetches content from a source and indexes it

  • ctx_stats

    Shows context savings and usage statistics

  • ctx_doctor

    Runs diagnostic checks on the system

  • ctx_upgrade

    Upgrades context-mode to the latest version

  • ctx_purge

    Deletes all indexed content from the knowledge base

  • ctx_insight

    Opens personal analytics dashboard

可对比工具

claude-desktopmcp-server-kitcontext-optimizer

安装

安装

Claude Code

/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode

Gemini 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 对比

GitHub →

最后更新于 · 由 README + GitHub 公开数据自动生成。