Kontext - an AI agent memory plugin for KurrentDB#5567
Kontext - an AI agent memory plugin for KurrentDB#5567
Conversation
Embeds Kurrent.Kontext directly in the KurrentDB server process,
exposing an MCP HTTP endpoint at /mcp/kontext for AI agent access.
Plugin components:
- KontextPlugin: SubsystemsPlugin, enabled via KurrentDB:Kontext:Enabled
- KontextClient: IKontextClient using ISystemClient for reads/writes
and SystemClient.Subscriptions for $all subscription
- KontextStreamAccessChecker: post-filters search results against
stream ACLs via IAuthorizationProvider. Unauthorized events are
redacted (data/metadata stripped, AccessDenied flag set)
Configuration is minimal — only Enabled is user-configurable. Data
files are stored under {index}/kontext/. Memory stream is $kontext-memory.
MCP endpoint is /mcp/kontext with HTTP Streamable transport.
Tests: 21 passing (KontextClientTests, KontextPluginTests,
EndToEndTests, McpEndpointTests)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Review Summary by QodoAdd KurrentDB.Plugins.Kontext — embedded agent memory plugin with MCP support
WalkthroughsDescription• Adds KurrentDB.Plugins.Kontext embedded agent memory plugin with MCP HTTP endpoint • Implements IKontextClient using internal ISystemClient for reads/writes/subscriptions • Provides KontextStreamAccessChecker for post-filtering search results against stream ACLs • Includes 21 passing tests covering client operations, MCP endpoint, and end-to-end workflows Diagramflowchart LR
Agent["Agent (Claude Code)"]
MCP["MCP HTTP Endpoint<br/>/mcp/kontext"]
Auth["Auth Middleware"]
Plugin["KontextPlugin"]
Client["KontextClient"]
SystemClient["ISystemClient"]
AccessChecker["KontextStreamAccessChecker"]
SQLite["SQLite Database<br/>FTS5 + Vector"]
Agent -->|"JSON-RPC over POST"| MCP
MCP --> Auth
Auth --> Plugin
Plugin --> Client
Plugin --> AccessChecker
Client --> SystemClient
AccessChecker --> SystemClient
Plugin --> SQLite
File Changes1. src/KurrentDB.Plugins.Kontext/KontextPlugin.cs
|
Code Review by Qodo
1. ToolkitTestEnvironment.Initialize() missing assembly
|
| [Before(Assembly)] | ||
| public static ValueTask BeforeAssembly(AssemblyHookContext context) => | ||
| ToolkitTestEnvironment.Initialize(); | ||
|
|
||
| [After(Assembly)] | ||
| public static ValueTask AfterAssembly(AssemblyHookContext context) => | ||
| ToolkitTestEnvironment.Reset(); |
There was a problem hiding this comment.
1. toolkittestenvironment.initialize() missing assembly 📘 Rule violation ⛯ Reliability
The new test wire-up does not pass context.Assembly to ToolkitTestEnvironment.Initialize/Reset, which breaks the required standardized per-assembly test environment lifecycle. This can cause unreliable test setup/cleanup when multiple test assemblies run under the shared toolkit.
Agent Prompt
## Issue description
`TestEnvironmentWireUp` does not call `ToolkitTestEnvironment.Initialize(context.Assembly)` / `Reset(context.Assembly)` as required.
## Issue Context
The repository test infrastructure relies on assembly-scoped initialization/reset to avoid cross-test-project interference.
## Fix Focus Areas
- src/KurrentDB.Plugins.Kontext.Tests/TestEnvironmentWireUp.cs[10-16]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| <ProjectReference Include="..\KurrentDB.Common\KurrentDB.Common.csproj" /> | ||
| <ProjectReference Include="..\KurrentDB.Core\KurrentDB.Core.csproj" /> | ||
| <ProjectReference Include="..\..\libs\Kurrent.Kontext\src\Kurrent.Kontext\Kurrent.Kontext.csproj" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
2. Ci misses submodules 🐞 Bug ⛯ Reliability
CI uses actions/checkout without enabling submodule checkout, but the solution now includes libs/Kurrent.Kontext as a git submodule and directly ProjectReferences its csproj, causing restore/build failures in CI and for developers without git submodule update --init.
Agent Prompt
### Issue description
The repo now depends on a git submodule (`libs/Kurrent.Kontext`) at build time via `ProjectReference`, but CI workflows check out the repository without fetching submodules. This causes missing project files during restore/build.
### Issue Context
Workflows using `actions/checkout@v4` must set `submodules: recursive` (or at least `true`) for submodules to be present.
### Fix Focus Areas
- .github/workflows/common.yml[21-73]
- .github/workflows/build-reusable.yml[17-97]
- .github/workflows/build-container-reusable.yml[11-97]
### Suggested change
Update each `actions/checkout@v4` step to include:
```yaml
with:
submodules: recursive
```
If you intentionally do not want submodules in some jobs, then remove the `ProjectReference` dependency and consume `Kurrent.Kontext` as a NuGet package or vendored source instead.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Adds the Kontext plugin - an embedded agent memory system for KurrentDB that gives AI agents durable, searchable memory backed by KurrentDB events.
Configuration
Only one setting — everything else is fixed with sensible defaults:
Data stored under
{index}/kontext/. Memory stream is$kontext-memory.Connecting Claude Code
Add
.mcp.jsonto your project root:{ "mcpServers": { "kontext": { "type": "http", "url": "https://localhost:2113/mcp/kontext" } } }How it works
The plugin subscribes to
$alland indexes every event into a local SQLite database using hybrid text (BM25) + vector (embedding) search. Agents connect via MCP over HTTP and can search events, retain synthesized facts, and recall them in future sessions. All ML inference (sentence embeddings + cross-encoder re-ranking) runs on CPU via ONNX Runtime — no LLM calls needed for indexing.