Neuro-Cognitive Engine
A multi-tenant memory and reasoning substrate for AI agents that provides tenant-isolated, append-only, and auditable memory with vertical business engines for procurement, sales, project management, and more, exposed via MCP and REST.
README
NCE — Neuro-Cognitive Engine
A multi-tenant memory and reasoning substrate for AI agents, with a suite of business engines built on top of it.
Agents that run a business need to remember things, and they need the memory to be correct: scoped to the right tenant, attributable to a source, and impossible to quietly corrupt. NCE is the layer that provides that, plus the vertical engines that use it — procurement, sales, project, economy, inventory and others.
Built in Python on Postgres, MongoDB, Redis and MinIO. Exposed over MCP (JSON-RPC 2.0) and REST.
What is actually here
Python in nce/ |
103,762 lines |
| Test files | 391 |
| Registered MCP tools | 115 |
| Database migrations | 48 |
| Vertical engines with code on main | 11 |
| Documentation pages | 114 — read them here |
| Architecture decision records | 8 |
| CI jobs per pull request | 5 |
Numbers are counted from the tree, not estimated. The tool count is asserted by a test (tests/test_tool_registry.py), so it cannot drift from reality without failing the build.
The parts worth looking at
Tenant isolation is enforced by the database, not by convention. Every tenant-scoped table carries ENABLE + FORCE ROW LEVEL SECURITY with a policy on namespace_id. Application code additionally filters explicitly, because a superuser connection bypasses FORCE RLS and a test that forgets this proves nothing. tests/test_rls_catalog.py fails the build if any tenant table is added without being registered.
Write authority is deny-by-default. Engines do not write each other's data. nce/config_data/node-ownership.json maps (node_type, transition) → owning engine, and assert_owner refuses anything unregistered at the write site. Ownership can be per-transition, not just per-node: a purchase order line's ORDERED status belongs to Procurement, DELIVERED to Warehouse, INSTALLED to Field Tech, and the same guard expresses all three.
The audit log is append-only at the database level. event_log has a WORM trigger; UPDATE and DELETE are revoked, not merely avoided.
Autonomy is bounded. World-writing tools default to human-confirm-only, carry an idempotency key, and record to the audit log. Value and volume ceilings, an allowlist and a kill switch sit in front of them. Replaying an action is a no-op rather than a second write.
Money and cost never leave the building. An allow-list field projector (project(node, surface)) controls what reaches an external surface. Margin and cost are not on any allow-list.
Generated text is grounded. Prose is assembled from facts already in the graph, with each claim linked to the node it came from, rather than produced free-hand and checked afterwards.
Data can come from two systems at once. A per-namespace resolver decides whether a given function reads from Dynamics 365, from NCE, or both, and logs divergence when the two disagree — so a migration can be measured before it is committed to.
Vertical engines
Eleven engines have code on main. Each owns its own tables, its own node types, and a documented boundary with the others.
procurement · product · agreements · vendors · sales · system_design · project · economy · inventory · dynamics365 · diagnostics
The engine suite is planned at 17. It is being built incrementally and is not finished; see Status below.
How it is built
The engine suite is not written by hand in one pass. It is built as a sequence of small units — 229 planned, each one concern, each on its own branch and commit — and every unit passes an independent adversarial review before it is accepted.
The review is done by a different model instance than the one that wrote the code, with the specific instruction to try to break it and to default to rejecting when uncertain. That has repeatedly mattered:
- A stock-movement change shipped with a graph projection written inside the authoritative transaction. It deadlocked on any two-way traffic between the same two locations, at 100% of attempts. Lint passed, types passed, the test suite was green. The review found it and the fix was to order both the row writes and the projection by a canonical key.
- An event-bus change would have marked events as successfully published while silently dropping them, because a handler logged and returned instead of raising. The review rejected it twice before anything shipped.
- A test asserting a decimal-precision rule was found to pass identically whether or not the rule was applied, because its only fixture rounded the same way under both paths.
The recurring lesson is that a green test suite says less than it appears to. The properties that fail are usually the ones a docstring argues for most confidently and no test actually discriminates.
Running it
cp .env.example .env # fill in the values
make local-up # Postgres, MongoDB, Redis, MinIO via docker compose
make lint typecheck # ruff + mypy
pytest -m "not integration" # unit tests, no database required
pytest -m integration # requires the stack above
Integration tests skip rather than fail when no database is reachable. A green exit code with skipped tests is not a passing run — check the counts.
Documentation
The full documentation is published at sindrehaugen.github.io/neuro-cognitive-engine — architecture, the eight architecture decision records, per-engine admin and user guides, the shared-core reference, and the MCP tool cookbook.
Worth starting with:
- Architecture — the four-database stack and how the layers sit
- Shared core — entity resolution, ownership, autonomy governance, redaction
- Multi-tenancy — how
FORCE ROW LEVEL SECURITYis applied - MCP tool cookbook — the tool surface, with gating flags
- ADRs — decisions and their trade-offs
Layout
nce/ engine core: memory, graph, RLS, autonomy, signing, replay
nce/vertical_modules/ the business engines
nce/migrations/ idempotent SQL, re-applied on boot under an advisory lock
tests/ 391 files; integration tests marked and CI-wired
docs/ source for the published documentation
go/ launcher and hardware detection
trimcp-infra/ Terraform for AWS and GCP
deploy/ compose stacks and container images
Status
Under active development. Eleven of seventeen engines have code on main; the twelfth is in progress. The core substrate — tenant isolation, ownership, autonomy governance, audit log, signing, replay — is complete and in use by the engines above it.
This repository is published to show the architecture and the engineering approach. It is not a packaged product and there is no support commitment.
Licence
Proprietary. All rights reserved. Published for review; not licensed for reuse.
Sindre Løvlie Haugen · github.com/sindrehaugen
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。