Part of mathias/infra Track E umbrella. Closes the brain↔Claude loop: every session both consumes + feeds the brain.
Goal
New MCP tool brain_context that Claude Code calls at session start (or on demand) to load relevant prior brain knowledge for the current project.
Scope
Tool signature
{"name":"brain_context","description":"Return top-N relevant brain entries for the current project context. Use at session start or before a complex task to load prior decisions, corrections, and surprises that apply.","inputSchema":{"type":"object","required":["project_root"],"properties":{"project_root":{"type":"string"},"recent_files":{"type":"array","items":{"type":"string"}},"limit":{"type":"integer","description":"default 10"}}}}
Logic
Extract project name from project_root basename (e.g. /home/mathias/dev/AGENTS/hyperguild → hyperguild).
Run BM25 query on the project name to seed candidates.
For top-3 BM25 hits, call graphstore.Subgraph(slug, 2) to expand neighbours.
Optionally weight neighbours by appearance in recent_files paths (e.g. file internal/graphstore/pg.go boosts graph-related entries).
Rerank merged set (BM25 + graph neighbours, deduped), return top-N as [{slug, title, doc_path, excerpt}].
Excerpt = first 200 chars of body after frontmatter.
Files
ingestion/internal/mcp/tools_context.go — new handler
ingestion/internal/mcp/handlers.go — add tool descriptor in tools()
ingestion/internal/mcp/server.go — add dispatch case in handleCall
tools/call brain_context {project_root: "/home/mathias/dev/AGENTS/hyperguild"} returns ≥3 relevant entries on a populated brain
With Track A graph enabled, 2-hop neighbours surface entries BM25 alone misses (test: query for litellm returns litellm-config-drift even when BM25 doesn't rank it top-3)
task check green
Companion: claude-context-bootstrap skill
New skill in mathias/skills repo that documents: at session start, call brain_context with the project root, attach result to the session's working context. Skill author is responsible for shape; this issue ships the tool, not the skill.
Branch policy
If Track E.1 worked on simultaneously, use branch agent/track-e2-brain-context. Merge to main when complete + task check green.
Part of mathias/infra Track E umbrella. Closes the brain↔Claude loop: every session both consumes + feeds the brain.
## Goal
New MCP tool `brain_context` that Claude Code calls at session start (or on demand) to load relevant prior brain knowledge for the current project.
## Scope
### Tool signature
```json
{
"name": "brain_context",
"description": "Return top-N relevant brain entries for the current project context. Use at session start or before a complex task to load prior decisions, corrections, and surprises that apply.",
"inputSchema": {
"type": "object",
"required": ["project_root"],
"properties": {
"project_root": {"type": "string"},
"recent_files": {"type": "array", "items": {"type": "string"}},
"limit": {"type": "integer", "description": "default 10"}
}
}
}
```
### Logic
1. Extract project name from `project_root` basename (e.g. `/home/mathias/dev/AGENTS/hyperguild` → `hyperguild`).
2. Run BM25 query on the project name to seed candidates.
3. For top-3 BM25 hits, call `graphstore.Subgraph(slug, 2)` to expand neighbours.
4. Optionally weight neighbours by appearance in `recent_files` paths (e.g. file `internal/graphstore/pg.go` boosts `graph-related` entries).
5. Rerank merged set (BM25 + graph neighbours, deduped), return top-N as `[{slug, title, doc_path, excerpt}]`.
6. Excerpt = first 200 chars of body after frontmatter.
### Files
- `ingestion/internal/mcp/tools_context.go` — new handler
- `ingestion/internal/mcp/handlers.go` — add tool descriptor in `tools()`
- `ingestion/internal/mcp/server.go` — add dispatch case in `handleCall`
- Tests: `tools_context_test.go` exercising no-graph + with-graph paths
### Acceptance
- `tools/call brain_context {project_root: "/home/mathias/dev/AGENTS/hyperguild"}` returns ≥3 relevant entries on a populated brain
- With Track A graph enabled, 2-hop neighbours surface entries BM25 alone misses (test: query for `litellm` returns `litellm-config-drift` even when BM25 doesn't rank it top-3)
- `task check` green
## Companion: `claude-context-bootstrap` skill
New skill in `mathias/skills` repo that documents: at session start, call `brain_context` with the project root, attach result to the session's working context. Skill author is responsible for shape; this issue ships the tool, not the skill.
## Branch policy
If Track E.1 worked on simultaneously, use branch `agent/track-e2-brain-context`. Merge to main when complete + task check green.
## Related
- infra Track E umbrella
- hyperguild#NN E.1 (parallel: claudewatcher ingestion)
- Track A graph (already shipped, this consumes it)
Closed by merge 2726896 + production deploy via image bad0581. brain_context tool callable, BM25 seed + 2-hop graph expansion working. Test fake satisfies both graphsync.Store and graphReader interfaces; no postgres required for unit tests.
Closed by merge 2726896 + production deploy via image bad0581. brain_context tool callable, BM25 seed + 2-hop graph expansion working. Test fake satisfies both graphsync.Store and graphReader interfaces; no postgres required for unit tests.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of mathias/infra Track E umbrella. Closes the brain↔Claude loop: every session both consumes + feeds the brain.
Goal
New MCP tool
brain_contextthat Claude Code calls at session start (or on demand) to load relevant prior brain knowledge for the current project.Scope
Tool signature
Logic
project_rootbasename (e.g./home/mathias/dev/AGENTS/hyperguild→hyperguild).graphstore.Subgraph(slug, 2)to expand neighbours.recent_filespaths (e.g. fileinternal/graphstore/pg.goboostsgraph-relatedentries).[{slug, title, doc_path, excerpt}].Files
ingestion/internal/mcp/tools_context.go— new handleringestion/internal/mcp/handlers.go— add tool descriptor intools()ingestion/internal/mcp/server.go— add dispatch case inhandleCalltools_context_test.goexercising no-graph + with-graph pathsAcceptance
tools/call brain_context {project_root: "/home/mathias/dev/AGENTS/hyperguild"}returns ≥3 relevant entries on a populated brainlitellmreturnslitellm-config-drifteven when BM25 doesn't rank it top-3)task checkgreenCompanion:
claude-context-bootstrapskillNew skill in
mathias/skillsrepo that documents: at session start, callbrain_contextwith the project root, attach result to the session's working context. Skill author is responsible for shape; this issue ships the tool, not the skill.Branch policy
If Track E.1 worked on simultaneously, use branch
agent/track-e2-brain-context. Merge to main when complete + task check green.Related
Closed by merge
2726896+ production deploy via imagebad0581. brain_context tool callable, BM25 seed + 2-hop graph expansion working. Test fake satisfies both graphsync.Store and graphReader interfaces; no postgres required for unit tests.