Files
codebase-memory-mcp/tests
Andrew Hundt 12c22e201b feat(config): add context_injection config key to enable/disable _context header
Adds boolean config key context_injection (default true, env CBM_CONTEXT_INJECTION)
that controls whether inject_context_once embeds the _context header in the first
tool response.

WHAT _context contains: node/edge counts, all node labels with counts, edge types
with counts, PageRank stats, and detected ecosystem (Go/Python/Rust/etc.).

WHEN TO DISABLE (context_injection=false):
  - Scripted/programmatic use: extra JSON adds noise to parsed output
  - CI pipelines: token cost is metered, model needs no schema context
  - Model has explicit codebase instructions via system prompt
  - Benchmarking: removes schema-query overhead from latency measurements

WHEN TO KEEP ENABLED (default):
  - Interactive AI sessions benefit from automatic situational awareness
  - Saves 2-3 round-trips otherwise needed for get_architecture/get_graph_schema

Usage:
  codebase-memory-mcp config set context_injection false   # per-install
  CBM_CONTEXT_INJECTION=false codebase-memory-mcp          # per-session

Implementation:
  - Config check placed BEFORE setting context_injected flag so toggling
    mid-session works (re-enable without server restart)
  - session_project is still always included regardless of this setting
  - cbm_config_get_bool reads CBM_CONTEXT_INJECTION env var automatically
    via cbm_config_get_effective (the standard env-override path)

TDD: config_context_injection_disabled, config_context_injection_enabled_by_default
Tests: 2274 passed, 0 failed
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-04-06 04:26:20 -04:00
..