cerebro
Cérebro 2.0
用于 OpenCode 的上下文优化服务器。通过 LLMLingua-2 压缩 LLM 提示词,注入任务协议,并提供 2nd Brain 知识图谱。
架构
┌─────────────────────────────────────────────────┐
│ OpenCode │
│ ┌──────────────┐ ┌──────────────────────────┐ │
│ │ Plugin │ │ MCP Client │ │
│ │ (hooks) │ │ (tools) │ │
│ └──────┬───────┘ └────────────┬─────────────┘ │
│ │ │ │
└─────────┼───────────────────────┼────────────────┘
│ │
┌─────▼─────┐ ┌──────▼──────┐
│ Compressor │ │ MCP Server │
│ LLMLingua-2│ │ + HTTP API │
└─────┬─────┘ └──────┬──────┘
│ │
┌─────▼───────────────────────▼──────┐
│ @cerebro/core │
│ compressor · task-injector · brain │
└────────────────────────────────────┘包
Package | 说明 |
| 压缩引擎、任务注入器、大脑引擎、指标 |
| MCP stdio 服务器 + HTTP API(供仪表盘使用) |
| OpenCode 插件(消息压缩 + 任务注入) |
| 基于 Vite + React + Tailwind 的仪表盘 UI |
Related MCP server: ContextStream MCP Server
快速开始
# Install dependencies
pnpm install
# Approve native builds (onnxruntime-node)
pnpm approve-builds
# Run tests
pnpm test
# Build all packages
pnpm -r build
# Start MCP server (stdio for OpenCode)
node packages/mcp-server/dist/index.js
# Start dashboard dev server
pnpm --filter @cerebro/dashboard dev配置
环境变量(在 opencode.json 的 environment 中设置):
变量 | 默认值 | 说明 |
|
| 压缩率(0.05–1.0,值越小压缩越多) |
|
| 2nd Brain 知识库的路径 |
|
| 仪表板的 HTTP API 端口 |
|
| 是否启用任务协议注入 |
|
| 以逗号分隔的受保护块模式 |
OpenCode 集成
在项目根目录的 opencode.json 中添加以下内容:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"cerebro": {
"type": "local",
"command": ["node", "caminho/para/cerebro/packages/mcp-server/dist/index.js"],
"environment": {
"COMPRESSION_RATE": "0.4",
"BRAIN_PATH": ".context-brain",
"DASHBOARD_PORT": "4321",
"ENABLE_TASK_INJECTION": "true"
},
"enabled": true
}
}
}MCP 工具
compress_prompt
使用 LLMLingua-2 ONNX 压缩文本。
{ "text": "Your long prompt...", "rate": 0.4 }brain_resolve
查询 2nd Brain 中某个 screen 及其 wiki 链接依赖项。
{ "screen": "dashboard-vendas", "depth": 1 }brain_index
在知识图谱中索引或更新某个 screen。
{
"id": "dashboard-vendas",
"content": "---\ntitle: Dashboard Vendas\n---\n\n# Dashboard Vendas\n\nMetrics for the sales dashboard."
}brain_screens
列出所有已索引的 screen。无参数。
cerebro_metrics
获取压缩指标和 token 节省情况。无参数。
cerebro_config
获取或设置运行时配置。
{ "key": "compressionRate", "value": 0.3 }仪表板
仪表板运行在 4321 端口,提供以下功能:
指标:压缩统计、token 节省、最近事件
第二大脑:浏览已索引的 screen 及其 wiki 链接
配置:查看和编辑运行时配置
pnpm --filter @cerebro/dashboard dev
# Open http://localhost:4321插件钩子
OpenCode 插件提供三个钩子:
Hook | 说明 |
| 在发送给 LLM 之前压缩旧消息 |
| 在系统提示词中注入任务协议 + 自检 |
| 记录工具执行情况,供仪表板展示 |
开发
# Type check all packages
pnpm -r typecheck
# Run tests
pnpm test
# Watch mode
npx vitest
# Build dashboard
pnpm --filter @cerebro/dashboard buildpackages/core/src/ task-injector.test.ts (18) · metrics.test.ts (5)
packages/mcp-server/src/ errors.test.ts (9) · rate-limiter.test.ts (7) · e2e.test.ts (10)
packages/plugin/src/ plugin.test.ts (8)使用 pnpm test 或 npxnpx vitest run 运行。
许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.6123MIT
- AlicenseCqualityAmaintenanceProvides AI assistants with persistent memory and code intelligence across all tools and conversations. Features semantic search, knowledge graphs, decision tracking, and impact analysis with 60+ tools for universal context preservation.3640539MIT
- AlicenseAqualityAmaintenanceProvides persistent memory and a codebase knowledge graph for AI coding assistants, enabling shared context across multiple tools like Claude, Cursor, and ChatGPT, with significant token reduction.532MIT
- AlicenseNot gradedqualityCmaintenanceEnables storing, searching, and compressing contextual memories for LLM interactions, with tools for memory management and context injection.9MIT
Related MCP Connectors
The project brain for AI coding agents — memory, decisions, sprints, knowledge base via MCP.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Universal memory for AI agents and tools. Save, organize and search context anywhere.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Wendell-A/cerebro2.0-lowvram'
If you have feedback or need assistance with the MCP directory API, please join our Discord server