# Connect MCP and harness hooks

Source: https://usecns.dev/engram-topic-connect-mcp-and-harness-hooks/

[Start here](https://usecns.dev/manual-engram/)
[CLI commands](https://usecns.dev/commands-engram/)
[Configuration & integration](https://usecns.dev/engram-topics/)

Use CLI commands for controlled administration and the six local MCP tools for in-session memory work. Register `engram mcp` as a stdio JSON-RPC server in the harness's MCP configuration. `engram tools` prints its catalog; not every CLI maintenance verb has an MCP equivalent.

* [engram\_recall](https://usecns.dev/engram-mcp-recall/)
* [engram\_record](https://usecns.dev/engram-mcp-record/)
* [engram\_distill](https://usecns.dev/engram-mcp-distill/)
* [engram\_complete](https://usecns.dev/engram-mcp-complete/)
* [engram\_outcome](https://usecns.dev/engram-mcp-outcome/)
* [engram\_status](https://usecns.dev/engram-mcp-status/)

The parser accepts `hook HARNESS EVENT` for `claude`, `claude-code` (Claude alias), `codex`, `gemini`, and `pi`. Claude variants emit hook JSON; the others emit text. Wire session start to keyspace injection, pre-tool-use to cue/guard checks, post-tool-use to structured gate feedback, and pre-compact/session-end/turn-complete to consolidation. Session-end also expires overrides and sweeps remaining reaches. Hooks that read stdin need a complete JSON payload and EOF, not an indefinitely open pipe.

CLI fallback plus `block --output` can integrate harnesses without native MCP/hooks, but wrapper integration is the harness owner's responsibility. Check the catalog rather than copying historical `wrap`, `jit`, `block --seat`, or `tools --format` examples; those interfaces are not implemented here. There is no `grok` hook harness.

Most internal hook/block errors fail open with diagnostics; invalid harness/OTE configuration can return 1 and pre-tool-use can return 2. Exit 0 does not prove learning happened. `CNS_VITALS_PATH`, when configured, receives content-bearing operational diagnostics whose destination must be authorized. If capability enforcement is enabled through `ENGRAM_RIG_SECRET`, protect that secret and the matching `ENGRAM_SEAT_TOKEN`; a seat token is separate from independent oracle attestation.