上下文钻石 是 AI Skill Hub 本期精选MCP工具之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
上下文钻石 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
上下文钻石 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/RainCherb/context-diamond
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"-----": {
"command": "npx",
"args": ["-y", "context-diamond"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 上下文钻石 执行以下任务... Claude: [自动调用 上下文钻石 MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"_____": {
"command": "npx",
"args": ["-y", "context-diamond"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
Stop pasting the same messy context into every LLM. Turn chats, logs, issues, agent state, and docs into small, auditable context capsules.
Context Diamond v0.7.0 is a deterministic context compression and handoff toolkit for LLM agents. It extracts the things models keep losing in long conversations:
It is built for developers who switch between coding agents, OpenCode, chat UIs, RAG pipelines, issue threads, and local notes. The default engine is offline, zero-dependency, inspectable, and safe to run before any text is sent to an LLM.
ctxd explain shows shard facets, scores, tokens, and reasons.ctxd repo captures branch, git state, and selected files.ctxd diff and ctxd merge support handoff evolution.tiktoken, anthropic, and transformers adapters.coding, support, research, incident).StreamingCompressor for incremental capsule updates.ctxd batch for multiple files.Install from GitHub:
pip install git+https://github.com/RainCherb/context-diamond.git
Compress a long handoff:
context-diamond examples/long_handoff.md --budget 320 --title "Sprint Handoff"
Get JSON with an audit trail:
context-diamond examples/long_handoff.md --format json --loss-report
Benchmark it against dumb head/tail clipping:
context-diamond-bench examples/long_handoff.md --budget 320
Inspect why shards were selected:
ctxd explain examples/long_handoff.md
Build a capsule from a repository:
ctxd repo . --budget 1200
Compare or merge capsules as the handoff evolves:
ctxd diff old_capsule.json new_capsule.json
ctxd merge chat.json repo.json issue.json --budget 900
Batch-process multiple files:
ctxd batch notes/*.md --output-dir capsules/ --budget 400 --template coding
Use a domain-specific template:
context-diamond incident_report.md --template incident --budget 500
Stream capsules incrementally:
from context_diamond import StreamingCompressor
streamer = StreamingCompressor()
streamer.add_message("Goal: build a login form.")
streamer.add_message("Decision: use JWT tokens.")
capsule = streamer.current_capsule
Example benchmark output:
535 source tokens -> 387 rendered capsule tokens
1.38x ratio
constraints:1.00 decisions:1.00 risks:1.00 code:1.00
context-diamond notes.md --tokenizer tiktoken --budget 500
Use a JSON message list:
bash context-diamond conversation.json --messages-json --format json json [ {"role": "user", "content": "Build a local context compressor."}, {"role": "assistant", "content": "Decision: use deterministic extraction first."} ] ```
Auto-compress messages before sending to an LLM:
```python from context_diamond import AutoCompressMiddleware
middleware = AutoCompressMiddleware(threshold_tokens=1200) compressed = middleware.compress_messages(messages, model_name="gpt-4o")
from context_diamond import CompressionConfig, ContextDiamondCompressor
text = """
Goal: reduce token waste in LLM handoffs.
The tool must run locally and avoid API keys by default.
Decision: emit markdown and JSON capsules.
"""
compressor = ContextDiamondCompressor(CompressionConfig(token_budget=220))
capsule = compressor.compress(text)
print(capsule.to_markdown())
Integration helpers:
from context_diamond import compress_documents, compress_messages, compress_tool_payload
See docs/integrations.md.
- Unresolved items that need attention. ```
高质量的MCP工具,实现了审计上下文胶囊
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,上下文钻石 在MCP工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | context-diamond |
| Topics | mcpai-agentscontext-compression |
| GitHub | https://github.com/RainCherb/context-diamond |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-14 · 更新时间:2026-06-14 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端