loading…
Search for a command to run...
loading…
Enables multi-agent cognitive processing for complex tasks using a pipeline of Analyst, Creator, and Critic agents, running locally via MiniMax API.
Enables multi-agent cognitive processing for complex tasks using a pipeline of Analyst, Creator, and Critic agents, running locally via MiniMax API.
A lightweight AI framework that runs locally on your machine using MiniMax API. Three specialized agents — Analyst, Creator, and Critic — collaborate through a structured cognitive pipeline to solve complex problems.
User Task
│
▼
┌──────────┐ Analyst breaks it down
│ Analyst ├─────────────────────────┐
└──────────┘ │
│ │
▼ │
┌──────────┐ Creator drafts ┌──────────┐
│ Creator │◄──────────────────┤ Analyst │
└──────────┘ │ Context │
│ └──────────┘
│ │
▼ │
┌──────────┐ Critic evaluates ┌──────────┐
│ Critic │◄────────────────────┤ Creator │
└──────────┘ │ Draft │
│ └──────────┘
│ │
▼ │
┌──────────┐ Creator improves ┌──────────┐
│ Creator │◄────────────────────┤ Critic │
└──────────┘ │ Feedback │
│ └──────────┘
│
▼
┌──────────┐ Critic final ┌──────────┐
│ Critic │◄──────eval─────────│ Improved │
└──────────┘ │ Solution │
│ └──────────┘
▼
Final Solution + Evaluation
~/.mcp/ for reviewmcp setup, mcp process, mcp sessions# Install from PyPI
pip install mcp-brain
# Or install with pipx (recommended on Ubuntu)
pipx install mcp-brain
# Or install from source
git clone https://github.com/MC80s/mcp.git
cd mcp
pip install -e .
# 1. Configure your MiniMax API key
mcp setup
# 2. Process your first task
mcp process "Design a logo for a tech startup called Quantum Leap"
# 3. View previous sessions
mcp sessions
# 4. Check config status
mcp status
| Step | Agent | Role |
|---|---|---|
| 1 | Analyst | Breaks down the problem into components |
| 2 | Creator | Generates an initial creative solution |
| 3 | Critic | Evaluates the draft, identifies flaws |
| 4 | Creator | Improves the solution based on critique |
| 5 | Critic | Final evaluation and rating |
MiniMax API is pay-per-use. Each task runs 5 agent calls.
| Complexity | Est. Cost |
|---|---|
| Simple task | ~$0.02–0.05 |
| Medium task | ~$0.05–0.15 |
| Complex task | ~$0.15–0.30 |
No subscription fees. You control your usage.
mcp-brain/
├── src/mcpbrain/
│ ├── minimax_client.py # MiniMax API client
│ ├── agents.py # Creator/Critic/Analyst agents
│ ├── memory.py # Working memory
│ ├── mcp_core.py # Orchestration engine
│ ├── http_server.py # OpenAI-compatible HTTP server
│ ├── server.py # MCP stdio server
│ ├── tools.py # Local tool registry
│ └── cli.py # CLI commands
├── scripts/
├── tests/
├── setup.py
├── pyproject.toml
├── install.sh
└── README.md
mcp setup Interactively configure API key
mcp process "task" Run a task through the cognitive pipeline
mcp sessions List recent sessions
mcp session <id> View full session details
mcp status Check configuration
The HTTP server exposes POST /v1/chat/completions in OpenAI format, making mcp-brain usable as a drop-in LLM provider for any OpenAI-compatible client.
Mode 1: Passthrough (tools present) — When the request includes tools or functions, the cognitive pipeline is bypassed. The full messages array is forwarded directly to MiniMax with the tool definitions. The LLM decides whether to call a tool or respond with text. This is the mode used by Hermes agent integration.
Mode 2: Cognitive Pipeline (no tools) — When no tools are present, the full adaptive pipeline runs. Tasks are classified as SIMPLE (1 step), MODERATE (2 steps), or COMPLEX (5 steps) and routed accordingly.
# Auto-start on boot (systemd user service)
systemctl --user enable mcp-brain-http
systemctl --user start mcp-brain-http
# Or run manually
mcp-brain-http --port 8080
# ~/.config/systemd/user/mcp-brain-http.service
[Unit]
Description=MCP Brain HTTP Server (OpenAI-compatible)
After=network.target
[Service]
ExecStart=/home/YOUR_USERNAME/.local/share/pipx/venvs/mcp-brain/bin/mcp-brain-http --host 127.0.0.1 --port 8080
Restart=always
RestartSec=10
[Install]
WantedBy=default.target
curl http://127.0.0.1:8080/health # {"status":"ok"}
curl http://127.0.0.1:8080/v1/models # {"object":"list","data":[{"id":"mcp-brain",...}]}
curl -X POST http://127.0.0.1:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"mcp-brain","messages":[{"role":"user","content":"What is 2+2?"}],"stream":false}'
mcp-brain integrates with Hermes in two ways:
Connect mcp-brain as a native MCP tool server. Hermes can delegate complex reasoning tasks to the multi-agent pipeline by calling the process_task tool.
# ~/.hermes/config.yaml
mcp_servers:
mcp-brain:
command: "/home/YOUR_USERNAME/.local/bin/mcp-brain-server"
Route all LLM conversations through the cognitive pipeline. Every message goes through the adaptive multi-agent architecture automatically.
# ~/.hermes/config.yaml
custom_providers:
- name: "mcp-brain"
base_url: "http://127.0.0.1:8080/v1"
api_key: "local" # any value — the server ignores it
provider: "openai" # OpenAI-compatible endpoint
Why Option B: With Option A, you manually invoke mcp-brain tools. With Option B, every conversation automatically benefits from the cognitive pipeline — no explicit invocation needed.
Config file: ~/.mcp/config.json
{
"api_key": "...",
"model": "MiniMax-M2.7",
"max_tokens": 2000,
"temperature": 0.7
}
Run setup: mcp setup
Important: MiniMax API base URL is https://api.minimax.io/v1 (NOT .chat — that returns 401 on everything).
Working model names: MiniMax-M2.7, MiniMax-M2, MiniMax-M2.5.
_read_code_files: fair per-file budget — pre-calculates equal allocation across all
discovered files instead of sequential-first-wins. Prevents large files from
starving subsequent files in the context window._classify_task: code_pattern_confidence now factored into return confidence via
max(); strong pattern-only matches return MODERATE instead of UNKNOWN.find_code_patterns: Jaccard threshold raised from score > 0 to score >= 0.15
(matches threshold already used in _classify_task).record_pattern: deduplication window expanded from patterns[-50:] to patterns[-200:]
to match retention limit._STOPWORDS: removed "file","files","code","mcp","brain" — too generic for a
code-analysis fingerprinting system.TOOL_REGISTRY.list() returned flat {name, description, parameters} dicts but MiniMax API expects {type:'function', function:{...}}. Added _normalize_to_api_format() to wrap schemas. This fixed "invalid tool type (2013)" errors and enabled tool execution._stream_passthrough had no try/except while _stream_pipeline did. Uncaught exceptions now yield SSE error chunk instead of crashing the FastAPI route.mkdir() in __init__, json.dump() TypeError in save(), and PermissionError/OSError in load() are now all caught._read_code_files: fair per-file budget — pre-calculates equal allocation across all
discovered files instead of sequential-first-wins. Prevents large files from
starving subsequent files in the context window._classify_task: code_pattern_confidence now factored into return confidence via
max(); strong pattern-only matches return MODERATE instead of UNKNOWN.find_code_patterns: Jaccard threshold raised from score > 0 to score >= 0.15
(matches threshold already used in _classify_task).record_pattern: deduplication window expanded from patterns[-50:] to patterns[-200:]
to match retention limit._STOPWORDS: removed "file","files","code","mcp","brain" — too generic for a
code-analysis fingerprinting system.~/.mcp/learned/code_patterns.json (last 200). Classifies as refactor/fix/feature/audit/optimize. Extracts file paths, code snippets, and pattern summaries._auto_record_pattern() fires at every pipeline completion (SIMPLE/MODERATE/COMPLEX). Also fires in report_outcome() for explicit feedback._classify_task() looks up similar code patterns by Jaccard fingerprint and injects [CODE PATTERN: prior fix on file.py — snippet: ...] into the Analyst prompt.CodeChangePattern namedtuple with deduplication by (pattern_summary, task_keywords)._classify_task() method: pre-classifies task using heuristics + learned history before Analyst runs. Combines similarity score, recency decay (30-day half-life), and outcome bonus into a weighted complexity prediction. High-confidence (>=0.85) SIMPLE seeds complexity_detected early and injects "answer directly" hint into the prompt.~/.mcp/learned/: routing is informed by past session outcomes instead of just storing themagents.py: remove unused log, app_log imports; add try-except around json.dumps(tool_result) to prevent crashes from non-serializable tool results; fix misleading else: break comment on async-for; remove dead process_stream method (never called anywhere)tools.py: _read_file uses itertools.islice for O(1) memory instead of loading full file then slicing; _skill_view adds is_file() check and 500KB size cap; _web_search checks curl returncode before claiming success; _write_file removes redundant hardcoded /home/mc411 path checkagents.py: remove unused log, app_log imports; add try-except around json.dumps(tool_result); fix misleading else: break comment; remove dead process_stream methodtools.py: _read_file O(1) memory via islice; _skill_view size cap + is_file() check; _web_search returncode check; _write_file redundant path removalMiniMaxAPIError, MiniMaxRateLimitError imports_build_token_chunk() now takes resolved model name instead of hardcoded "mcp-brain"get_api_key() startup-cached helper — eliminates per-request disk I/O on /health and /readygetattr(request.state, 'correlation_id', None) or new_correlation_id() instead of always overwriting_extract_user_message() to handle OpenAI list content blocks ([{"type": "text", "text": "..."}])_stream_passthrough — now uses proper choices[0].error nested object_stream_pipeline — samedone_result variable (assigned on every done event but never consumed)/health and /ready endpoints simplified to use cached get_api_key()_BARE_CODE_FILE_PATTERN regex — matches mcp_core.py style bare filenames in addition to slash-prefixed paths_read_code_files() now resolves bare filenames relative to package source directory when cwd doesn't matchexploration_note renamed to analyst_exploration_note — only Analyst agent receives the mandatory exploration directive; Creator and Critic no longer get redundant injection_llm_tool_dispatch (~40 lines) — dead code with latent import requests in unreachable try block_parse_local_tool (~55 lines) — phrasal tool patterns (run 'command', read "file"), never called_parse_tool_invocation (~25 lines) — slash-command parser, never called_run_step (~6 lines) — legacy blocking helper, deadsession_id entropy doubled: str(uuid.uuid4())[:8] → [:16] (2¹²⁸ vs 2³²)_write_file in tools.py: inconsistent path check (str(p).startswith("/tmp/") vs is_relative_to())report_outcome in mcp_core.py: saved stale result dict instead of updated — feedback fields were lost on re-save_find_result_on_disk: returned first matching file instead of latest by mtime_save_session_log: used self.session_id for filename instead of result["session_id"]read_file before generating analysis — eliminates hallucination for code reference tasksanalyst_exploration_note injected when _extract_file_paths() finds file referencescall_0_0 to call_{round:02d}_{index:04d} (MiniMax compatible){"function": {"name": ..., "arguments": json.dumps(...)}} structuremax_tokens bumped to 12000, Creator to 4000report_outcome race condition fixed: atomic RMW with self.__class__._results_lock~/.local/share/pipx/venvs/mcp-brain/lib/python3.12/site-packages/mcpbrain/ was not updated after code changespipx install ~/mcp-work --force after every edit to update the venvSessionIndex — fingerprints tasks by keywords, finds similar past sessions (Jaccard similarity >= 0.2)LearnedMemory — stores outcome patterns (success/partial/failed) with ratingsreport_outcome(session_id, outcome, rating, notes) — record feedback for a session~/.mcp/learned/patterns.json — outcome records~/.mcp/learned/session_index.json — session metadata with fingerprints~/.mcp/learned/heuristics.json — extracted heuristics from successful solutionsmcp feedback <session_id> <outcome> [rating] CLI command for recording outcomesmcp learned CLI command to view learned patternsv0.7.2 through v0.7.5 were minor fixes: version string cleanup, MiniMax reasoning tag leakage, unified _filter_think_tags() helper for streaming and non-streaming paths, file corruption修复.
httpx.AsyncClient replaces requests — true async streaming, connection pooling (100 max connections)structlog for structured logging with correlation IDsgenerate_stream() and generate_stream_from_messages() with retry/backoff/ready (readiness probe) and /metrics (Prometheus-compatible) endpointsget_shared_client() singleton — reused across HTTP requests_make_think_filter()) applied to pipeline modeaclose()<think> and <tool_call> reasoning blocks from token stream_process_token) handles the stripping during streamingre.sub() stripping added for non-streaming responses_strip_reasoning_tags() now runs on full response before returning<think>...</think>) were leaking into passthrough responses — stripped with re.sub()<tool_call>think> and <thinking> tag variants handledmax_tokens hardcoded to 2000 in passthrough mode — now reads from request body (default 4096)tools are present in the request, the cognitive pipeline is bypassed and messages are forwarded directly to MiniMax API~/.mcp/logs/~/.mcp/config.json (keep this file private)Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mcp-brain": {
"command": "npx",
"args": []
}
}
}from github.com/MC80s/mcp