Sherlock's second brain
This MCP server implements a second brain system, managing unvalidated investigation cases as JSON and validated knowledge as markdown files and skills. It provides tools for creating, updating, promoting cases, managing knowledge files, and performing semantic search.
README
sherlock-second-brain
Named after the famous detective of Baker Street who inspired this project: the same way, we run rigorous investigations (symptoms, clues, hypotheses, evidence, conclusion) to debug, analyze code, and remember what we learn across multiple projects.
MCP server + skill for Sherlock's second brain: validated knowledge lives in MD fiches and skills; everything not yet validated lives in cases (JSON investigation files for debugging and troubleshooting). Standalone notes worth remembering without an investigation live in memories (MD + YAML frontmatter). A resolved case is promoted into a fiche or a skill through the MCP; a memory can also be promoted into a fiche.
source of truth (files) derived index (rebuildable)
──────────────────────────────────── ────────────────────────────
<data_dir>/
cases/<case-id>/case.json ──→ vector/ (chromadb, gitignored)
cases/<case-id>/evidence/*.log hybrid search: vector (Chroma)
memories/<id>.md + lexical (RRF)
fiches/*.md
skills/<slug>/SKILL.md
Stack
- Python 3.12+,
uv - FastMCP (stdio)
- ChromaDB + fastembed (vector index, multilingual MiniLM-L12 model)
- jsonschema (case validation)
- jinja2 (rendering of promoted fiches / skills)
- PyYAML (memory frontmatter)
- Hexagonal architecture:
domain/(pure pydantic) ·application/(use cases + ports) ·adapters/(filesystem, chroma, lexical, hybrid RRF, MCP DTO, templates)
Installation (in a project)
uv init
uv add sherlock-second-brain
Or from the repo:
cd sherlock-second-brain
uv sync
Two ways to run it
Your data (cases, fiches, skills, vector index) always lives on the machine where the server process runs. The server is local-first (stdio), so you choose where that machine is:
A. Self-hosted (data stays on your machine)
Install the package and run the stdio server locally — no third party ever touches
your data. Configure SHERLOCK_BRAIN_DATA_DIR to choose where the files live
(default ~/sherlock-second-brain-data).
B. Managed on Glama (opt-in)
Deploy your own instance on Glama's hosting from the Glama listing:
Glama builds the image, wraps the stdio transport into Streamable HTTP, and mounts
a persistent volume at /data. Set SHERLOCK_BRAIN_DATA_DIR=/data so your
knowledge survives redeploys. This is a paid managed option — the code itself is
free and open source (MIT).
Configuration
| Variable | Role | Default |
|---|---|---|
SHERLOCK_BRAIN_DATA_DIR |
Root data directory (cases + memories + kb + vector) | ~/sherlock-second-brain-data |
Wire the MCP server into opencode
Add to ~/.config/opencode/opencode.json:
{
"mcp": {
"sherlock-second-brain": {
"type": "local",
"command": ["/opt/sherlock-second-brain/.venv/bin/python", "-m", "sherlock_second_brain.server"],
"enabled": true,
"environment": {
"SHERLOCK_BRAIN_DATA_DIR": "/opt/infra/kb"
}
}
}
}
Install the agent globally
The agent is versioned in this repo (agent/sherlock-second-brain.md). To make it
available to all opencode agents:
ln -s /opt/sherlock-second-brain/agent/sherlock-second-brain.md ~/.config/opencode/agent/sherlock-second-brain.md
On another machine, clone the repo then create the same symlink pointing to the checkout. Restart opencode after installation.
MCP tools
Cases
| Tool | Role |
|---|---|
case_create |
Create an investigation (unvalidated topic) |
case_get / case_list |
Read / list (status, tag filters) |
case_search |
Semantic search (cases + KB) |
case_update |
Add findings / steps / hypotheses / conclusion / hypothesis result |
case_add_evidence |
Attach evidence (log, output, note) |
case_set_status |
open / in_progress / resolved / abandoned |
case_delete |
Delete a case and its evidence |
case_promote |
Promote a resolved case → fiche or skill |
Memories
| Tool | Role |
|---|---|
memory_add |
Add a standalone note to remember (no case) |
memory_get / memory_list |
Read / list memories (tag filter) |
memory_search |
Semantic search restricted to memories (hydrated) |
memory_update |
Update summary / content / tags / references / source |
memory_delete |
Delete a memory |
memory_promote |
Promote a memory → validated fiche |
KB
| Tool | Role |
|---|---|
fiche_list / fiche_read / fiche_write / fiche_delete |
CRUD validated fiches |
skill_list / skill_read / skill_write / skill_delete |
CRUD validated skills |
index_rebuild |
Rebuild the vector index from source files |
Hybrid search
case_search (and memory_search) combines two engines via Reciprocal Rank
Fusion (adapters/hybrid.py) over four sources: fiches, cases,
skills and memories.
- Vector (
adapters/chroma.py): multilingual embeddings (MiniLM-L12, ~0.22GB, French included), persistent collection invector/, rebuildable viaindex_rebuild. - Lexical (
adapters/lexical.py): token overlap, zero dependency — a doc relevant for an exact term but missed by the vector engine still surfaces.
RRF fusion: score(d) = 1/(k + vector_rank) + 1/(k + lexical_rank), k = 60. The first index_rebuild downloads the model.
Memories
A memory is a low-friction capture ("remember that the NAS runs Fedora 44"), with
no case workflow. It is stored as memories/<id>.md with YAML frontmatter
(metadata) and a free-form markdown body. Memories are indexed on every mutation
(create included) so they are immediately searchable. A memory is not
validated; promote it with memory_promote once it becomes validated knowledge.
Case schema
Defined in
src/sherlock_second_brain/schema/case.schema.json
— source of truth, shipped inside the package. Every case written through the MCP
is validated against this schema (works from PyPI installs too).
Tests
uv run ruff check src/ tests/ # lint
uv run ty check # type checking
uv run pytest tests/ -v # tests
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。