Knowledge & MCP Tools
lm-assist automatically builds a searchable knowledge base from your Claude Code sessions and makes it available through MCP tools and context injection.
How Knowledge Is Built
When Claude Code runs Explore subagents (research tasks), lm-assist captures the results and extracts reusable facts:
Claude Code Session
|
v
Explore subagent returns findings
|
v
lm-assist extracts structured knowledge
|
+----> Vector index (semantic search via LanceDB)
+----> BM25 index (keyword search)
+----> Knowledge store (full content)Each knowledge entry contains:
- Title -- what was explored
- Facts -- specific, reusable findings (code patterns, API details, file locations)
- Source -- which session and project it came from
- Timestamps -- when it was created and last updated
Knowledge Entry Example
K025: Explore user authentication flow
Facts:
1. Auth middleware at gateway-type1/lib/middleware/auth.ts
2. JWT tokens stored in httpOnly cookies
3. OAuth callback at /v1/auth/callback/{provider}
4. Supported providers: Google, GitHub, Microsoft
5. Guest access creates temporary user with 24h expiry
Source: Session abc123 | Project: /home/user/LangMartDesign
Updated: 2026-02-20MCP Tools
lm-assist registers three MCP tools in Claude Code. These are also available in any MCP-compatible IDE (VS Code, Cursor, Windsurf, etc.).
search
Search the knowledge base using natural language, keywords, or file paths.
search(query, scope?, project?, type?, limit?, offset?)| Parameter | Type | Default | Description |
|---|---|---|---|
query |
string | required | Natural language query, keywords, or file paths |
scope |
string | 7d |
Time scope: 24h, 3d, 7d, 30d, all |
project |
string | -- | Filter by project path |
type |
string | all |
Filter: knowledge, all |
limit |
number | 5 | Results per page (max 20) |
offset |
number | 0 | Pagination offset |
Example usage in Claude Code:
When Claude needs to understand a part of your codebase, instead of re-exploring files, it calls:
search("authentication middleware implementation")And gets back relevant knowledge entries from previous sessions.
detail
Get the full content of a knowledge entry by ID.
detail(id, section?, limit?, offset?)| Parameter | Type | Default | Description |
|---|---|---|---|
id |
string | required | Knowledge ID (e.g., K001, K001.2) |
section |
string | -- | Expand specific section: facts, files, content, conversation |
limit |
number | 10 | Items per page |
offset |
number | 0 | For paginated content |
feedback
Provide quality feedback on knowledge entries. This improves future search results.
feedback(id, type, content)| Parameter | Type | Description |
|---|---|---|
id |
string | Knowledge entry ID (e.g., K001.2) |
type |
string | outdated, wrong, irrelevant, needs_update, useful |
content |
string | Specific feedback text |
Example: If a knowledge entry references an old file path:
feedback("K025.3", "outdated", "File moved from lib/auth.ts to middleware/auth.ts")Context Injection Hook
The context injection hook is the most impactful feature. It fires automatically before every Claude Code prompt:
- Prompt received -- the user types a message in Claude Code
- Hook fires -- lm-assist searches the knowledge base for relevant entries
- Results injected -- top matches are added as context to the system prompt
- Claude responds -- with knowledge from previous sessions already loaded
What Gets Injected
The hook injects a compact summary with:
- Knowledge entry IDs and titles
- Key facts relevant to the current prompt
- Suggestions to use
detail(id)for deeper exploration
Typical injection size: 2-5 entries, ~3k tokens.
Viewing Injection Logs
/assist-logsOr from the dashboard: Settings > Context Injection Logs.
Each log entry shows:
- The user prompt that triggered the hook
- Which knowledge entries were searched
- Which entries were injected
- Time taken for the search
Search Architecture
lm-assist uses a hybrid search approach for high-quality results:
| Component | Purpose |
|---|---|
| Vector Search (LanceDB) | Semantic similarity -- finds conceptually related content |
| BM25 Index | Keyword matching -- finds exact terms and phrases |
| RRF Merge | Reciprocal Rank Fusion combines both result sets |
| Content Boost | 2x boost for results containing exact query text |
| Recency Scoring | Time-weighted results (recent sessions rank higher) |
Search Flow
User Query
|
+----> Vector Search (semantic)
| |
+----> BM25 Search (keyword)
| |
v v
RRF Merge (fuse rankings)
|
v
Content-match boost
|
v
Recency weighting
|
v
Top N results returnedKnowledge Quality
Knowledge quality improves over time through:
- Feedback loop -- mark entries as outdated, wrong, or useful
- Deduplication -- overlapping entries are consolidated
- Recency -- newer knowledge ranks higher than stale entries
- Project scoping -- knowledge is tagged with project paths for relevance
Configuration
Knowledge settings are available in the dashboard under Settings:
| Setting | Default | Description |
|---|---|---|
| Context injection | Enabled | Auto-inject knowledge into prompts |
| Max injected entries | 5 | Maximum entries per prompt |
| Search scope | 7 days | Default time window for searches |
| Knowledge types | All | Filter by knowledge type |
Cost Savings
| Metric | Without lm-assist | With lm-assist |
|---|---|---|
| Exploration overhead per session | ~85k tokens | ~3k tokens |
| Time to first useful response | ~3 minutes | < 1 second |
| Redundant file reads | Many | Near zero |
| Token savings | -- | 95%+ reduction |
The knowledge base pays for itself after just a few sessions by eliminating redundant codebase exploration.