cerebro
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cerebrocompress the current prompt to a 50% rate and store it in the brain"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Cérebro 2.0
Context optimization server for OpenCode. Compresses LLM prompts via LLMLingua-2, injects task protocols, and provides a 2nd Brain knowledge graph.
Architecture
┌─────────────────────────────────────────────────┐
│ OpenCode │
│ ┌──────────────┐ ┌──────────────────────────┐ │
│ │ Plugin │ │ MCP Client │ │
│ │ (hooks) │ │ (tools) │ │
│ └──────┬───────┘ └────────────┬─────────────┘ │
│ │ │ │
└─────────┼───────────────────────┼────────────────┘
│ │
┌─────▼─────┐ ┌──────▼──────┐
│ Compressor │ │ MCP Server │
│ LLMLingua-2│ │ + HTTP API │
└─────┬─────┘ └──────┬──────┘
│ │
┌─────▼───────────────────────▼──────┐
│ @cerebro/core │
│ compressor · task-injector · brain │
└────────────────────────────────────┘Packages
Package | Description |
| Compression engine, task injector, brain engine, metrics |
| MCP stdio server + HTTP API for dashboard |
| OpenCode plugin (message compression + task injection) |
| Vite + React + Tailwind dashboard UI |
Related MCP server: context-mcp
Quick Start
# 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 devConfiguration
Environment variables (set in opencode.json under environment):
Variable | Default | Description |
|
| Compression rate (0.05–1.0, lower = more compression) |
|
| Path to 2nd Brain knowledge base |
|
| HTTP API port for dashboard |
|
| Enable task protocol injection |
|
| Comma-separated protected block patterns |
OpenCode Integration
Add to opencode.json in your project root:
{
"$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 Tools
compress_prompt
Compress text using LLMLingua-2 ONNX.
{ "text": "Your long prompt...", "rate": 0.4 }brain_resolve
Query the 2nd Brain for a screen and its wiki-linked dependencies.
{ "screen": "dashboard-vendas", "depth": 1 }brain_index
Index or update a screen in the knowledge graph.
{
"id": "dashboard-vendas",
"content": "---\ntitle: Dashboard Vendas\n---\n\n# Dashboard Vendas\n\nMetrics for the sales dashboard."
}brain_screens
List all indexed screens. No parameters.
cerebro_metrics
Get compression metrics and token savings. No parameters.
cerebro_config
Get or set runtime configuration.
{ "key": "compressionRate", "value": 0.3 }Dashboard
The dashboard runs on port 4321 and provides:
Métricas: Compression stats, token savings, recent events
2º Cérebro: Browse indexed screens and their wiki-links
Config: View and edit runtime configuration
pnpm --filter @cerebro/dashboard dev
# Open http://localhost:4321Plugin Hooks
The OpenCode plugin provides three hooks:
Hook | Description |
| Compresses old messages before sending to LLM |
| Injects task protocol + self-check into system prompt |
| Logs tool execution for dashboard visibility |
Development
# Type check all packages
pnpm -r typecheck
# Run tests
pnpm test
# Watch mode
npx vitest
# Build dashboard
pnpm --filter @cerebro/dashboard buildTesting
66 tests across 6 suites:
packages/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)Run with: pnpm test or npx vitest run
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Intelligent context infrastructure for AI teams: knowledge graph, sessions, tasks, documents.
Codebase graphs, caller impact analysis, and recorded project context for AI coding agents.
Shared memory for coding agents. Stop re-explaining your codebase every session.
- OneLoreOAuthai.onelore
Shared project context for AI agents and teams: docs, tasks, and messages that stay current.
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.616 npm3MIT
- AlicenseAqualityBmaintenanceProvides 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.513 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables storing, searching, and compressing contextual memories for LLM interactions, with tools for memory management and context injection.9MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI coding agents to retrieve and manage code context with hybrid search, project memory, and observability via MCP tools.29MIT