Arra Memory Lab
БесплатноНе проверенEnables trustworthy AI memory operations including authoritative memory creation, hybrid recall with provenance, evidence tracking, and safe dry-run-first forge
Описание
Enables trustworthy AI memory operations including authoritative memory creation, hybrid recall with provenance, evidence tracking, and safe dry-run-first forget and rebuild operations through a stateless MCP endpoint.
README
A standalone, single-user Cloudflare lab for learning the contracts behind trustworthy AI memory: authoritative sources, rebuildable embeddings, evidence-backed observations, inspectable hybrid recall, bounded traces, and preview-before-mutation operations.
The deployment creates one Worker, automatically provisions its D1 database from wrangler.jsonc, and runs the included migrations through the deploy script. Workers AI supplies 768-dimensional @cf/google/embeddinggemma-300m embeddings.
What this demonstrates
- Authority tiers: memories are authoritative; chunks/embeddings and observations are derived.
- Honest recall: every search reports requested mode, effective mode, degradation, and rank provenance.
- Evidence lineage: observations retain source memory IDs, revisions, and hashes.
- Safe mutation: forget and rebuild are dry-run-first; forget confirmation is bound to the exact preview snapshot, and confirmed rebuild work is bounded.
- Data minimization: the newest 100 search traces contain operational metadata, never query or memory content.
- Trace-linked recall: a recall returns a
traceIdwhen trace persistence succeeds; ranked result snapshots retain only memory ID, rank/score provenance, source revision, and source hash. - Explicit supersession:
supersedesMemoryIdresolves once at write time into an immutable ID/revision/hash snapshot. It does not infer a temporal graph. - Small provenance:
project,sourcePath, andcreatedByare structured fields; an Oracle identity remains anoracle-<name>tag.retrospectiveandcheatsheetare first-class memory kinds.
The trace queryHash is a correlation handle, not anonymization—especially for low-entropy queries—so trace access remains protected even though raw query and memory content are omitted.
Release identity
package.json is the single source of truth for the lab's Bangkok CalVer:
YY.M.D-alpha.HMM, where HMM = hour × 100 + minute in Asia/Bangkok.
The build injects only that string into the public client; /api/info, MCP
initialize, the lab_info tool, and the UI footer report the same value.
npm run version:next # preview the next available Bangkok minute
npm run version:bump # update package.json + package-lock.json, no commit/tag
npm run version:check # fail if format or lock metadata drift
The bump command rejects same-minute reuse, clock rollback, unknown flags, and
any CalVer not newer than existing arra-memory-lab-v* tags.
This is intentionally not a production identity or tenancy design. The private web API uses one owner bearer secret. The remote MCP lane uses OAuth 2.1, S256 PKCE, Dynamic Client Registration (DCR), expiring access tokens, and refresh tokens so Claude.ai and other web MCP clients can connect without storing the owner passphrase. Tenants, queues, ANN indexes, and autonomous consolidation remain deferred.
Data flow and privacy boundary
- Creating a memory tries a best-effort embedding after the D1 source write succeeds.
- Semantic/hybrid recall sends the query text to Workers AI.
- A confirmed rebuild sends the selected memory title/content chunks to Workers AI and writes derived vectors to D1.
- Keyword recall and rebuild previews do not call Workers AI.
- D1 stores authoritative text plus derived chunk text/vectors; search traces and result links store only hashes, IDs, ranks, scores, and operational metadata.
Use synthetic or non-sensitive data unless your Cloudflare account policy and threat model explicitly allow this processing. In local development, the Workers AI binding still accesses the remote service and may incur usage.
Deploy
- Click Deploy to Cloudflare above and authorize the repository deployment.
- The Cloudflare deployment form prompts for
LAB_ACCESS_TOKEN. Supply a long random value (for example, one generated withopenssl rand -hex 32); Cloudflare stores it as a secret binding. The same value unlocks the browser API and approves new OAuth clients, but OAuth clients never receive it. - Deploy. The repository's deploy script automatically applies the D1 migrations before building and publishing the Worker.
- Open the Worker URL. Enter the same token once; the browser stores it only in
sessionStorage, so closing that browser session clears it.
If the deployment form or automatic migration step needs manual recovery, use the equivalent CLI fallback:
printf '%s' 'replace-with-a-long-random-token' | npx wrangler secret put LAB_ACCESS_TOKEN
npx wrangler d1 migrations apply DB --remote
For a checked-out release, do not edit placeholder IDs in wrangler.jsonc.
The release helper builds and tests first, resolves exactly one D1 database
named arra-memory-lab and one KV namespace named arra-memory-lab-oauth,
writes their IDs only to a mode-0600 temporary config, applies migrations,
then deploys that same immutable build:
npm run deploy:dry-run
npm run deploy
Private /api/* routes require Authorization: Bearer $LAB_ACCESS_TOKEN. /mcp accepts only access tokens issued by the lab's OAuth provider; the owner secret itself is rejected there. OAuth discovery, DCR, token exchange, and the approval UI live under /.well-known/*, /oauth/*, and /authorize. Only GET /api/info is public application content. If LAB_ACCESS_TOKEN is absent, private API access and OAuth approval fail closed.
The consent response intentionally omits CSP form-action: embedded OAuth
browsers used by real MCP hosts blocked submission even with an exact-origin
allowlist. The form target is a fixed relative /authorize; base-uri 'none'
prevents base-target rewriting, every DCR-derived field is HTML-escaped, and
the POST path re-parses PKCE/scopes/client state before the OAuth provider
validates and completes the redirect. This is a measured compatibility
boundary, not a general CSP recommendation.
Why D1 for one-click deployment?
D1 is used because Cloudflare's deployment flow can provision and bind it automatically, keeping this lab genuinely close to one click. The tradeoff is deliberate provider coupling: this version does not demonstrate a portable database layer or Turso/libSQL deployment. That is acceptable for a focused Cloudflare lab, not a blanket production recommendation.
Local development
Requires Node.js for install/build/deploy, Bun for the test/check scripts, and a Cloudflare account for Workers AI. Wrangler warns because the AI binding remains remote even while the Worker and D1 run locally.
cd labs/arra-memory-lab
npm install
cp .env.example .dev.vars
# Set LAB_ACCESS_TOKEN in .dev.vars
npx wrangler d1 migrations apply DB --local
npm run dev
Quality checks:
npm run typecheck
npm test
npm run build
# or all three:
npm run check
The postbuild hook removes .env* and .dev.vars* files from dist/. This is defense in depth for local artifacts; Wrangler's deploy manifest does not upload those development files.
HTTP examples
export LAB_URL='https://arra-memory-lab.<account>.workers.dev'
export LAB_ACCESS_TOKEN='your-long-random-token'
export AUTH="Authorization: Bearer $LAB_ACCESS_TOKEN"
# Public capability disclosure
curl "$LAB_URL/api/info"
# Create an authoritative memory (indexing is best effort)
curl -X POST "$LAB_URL/api/memories" -H "$AUTH" -H 'Content-Type: application/json' \
-d '{"title":"Prefer explicit authority","content":"Memories are sources; embeddings are projections.","kind":"retrospective","tags":["architecture"],"project":"github.com/soul-brews-studio/claude-ai-mcp-poc","sourcePath":"ψ/memory/retrospectives/example.md","createdBy":"rrr","oracleName":"neo","supersedesMemoryId":"OPTIONAL_EXISTING_MEMORY_ID"}'
# Hybrid recall exposes requested/effective modes and rank provenance
curl -X POST "$LAB_URL/api/search" -H "$AUTH" -H 'Content-Type: application/json' \
-d '{"query":"Which data is authoritative?","mode":"hybrid","project":"github.com/soul-brews-studio/claude-ai-mcp-poc","limit":8}'
# Preview a forget and retain the returned expected* fields
curl -X POST "$LAB_URL/api/memories/MEMORY_ID/forget" -H "$AUTH" -H 'Content-Type: application/json' \
-d '{"confirm":false}'
# Confirm only that exact preview. A changed source/impact returns 409 stale_preview.
curl -X POST "$LAB_URL/api/memories/MEMORY_ID/forget" -H "$AUTH" -H 'Content-Type: application/json' \
-d '{"confirm":true,"expectedRevision":1,"expectedHash":"COPY_FROM_PREVIEW","expectedChunks":0,"expectedObservationCount":0}'
# Preview a bounded rebuild; confirmed work is capped at 10 memories / 256 chunks
curl -X POST "$LAB_URL/api/index/rebuild" -H "$AUTH" -H 'Content-Type: application/json' \
-d '{"confirm":false}'
MCP
The lab exposes stateless Streamable HTTP MCP at /mcp. A token with both
advertised scopes receives these tools:
lab_info, remember, recall, observe, forget, rebuild_index, memory_stats, trace_list, trace_get.
lab_info is always present for a valid token. memory:read controls
recall, memory_stats, trace_list, and trace_get; memory:write controls
remember, observe, forget, and rebuild_index. Scope checks use the
unwrapped access-token scope on every stateless request, including refresh-token
downscoping.
The implementation pins @modelcontextprotocol/[email protected] and uses the
Cloudflare Agents createMcpHandler wrapper. “SDK v2” and “protocol version”
are separate axes: the endpoint serves modern 2026-07-28 requests and keeps
the 2025-era initialize flow as a stateless compatibility lane. Neither lane
creates an Mcp-Session-Id; every request receives a fresh server instance.
See docs/mcp-v2-stateless.md for the proof matrix.
Connect or reload an MCP client
npm run mcp:connect -- codex "$LAB_URL/mcp" arra-memory-lab
# or Claude Code:
npm run mcp:connect -- claude "$LAB_URL/mcp" arra-memory-lab
The helper registers the URL and starts the client's OAuth login. Re-running it refreshes the registration/login path. For Claude.ai, open Settings → Connectors → Add custom connector, enter only https://…/mcp, click Connect, and enter the lab passphrase on the approval page.
Bearer versus OAuth
| Surface | Credential | Why |
|---|---|---|
Browser and curl /api/* |
static LAB_ACCESS_TOKEN bearer |
fastest single-owner lab path |
Claude.ai remote connector /mcp |
OAuth access/refresh tokens | Claude.ai custom connectors support authless or OAuth, not a user-entered static header |
Codex / Claude Code /mcp |
OAuth login via helper | no long-lived owner passphrase in client config |
See docs/provenance-oauth-report.md for the measured decision and sanitized proof.
Failure contracts
- Authoritative memory writes survive embedding failures.
- Hybrid recall degrades only for embedding-provider failures and reports the reason.
- Explicit semantic recall errors if semantic inference is unavailable.
- Database/vector errors are not mislabeled as AI fallback.
- Trace-write failures never alter a successful recall or mask its original error.
- Completed trace, ranked result links, and retention pruning are attempted in one D1 batch; trace persistence remains fail-safe relative to recall.
- Forgetting a memory does not erase historical trace-result or supersession snapshots; pruning a trace cascades to its ranked links.
- Rebuild rechecks source revision/hash before replacing derived chunks.
- Forget confirmation requires the revision, hash, chunk count, and observation count returned by its preview; stale confirmation fails with HTTP
409/stale_preview.
See CONTRACT.md for the current runtime boundary and DESIGN.md for the UI system.
Primary platform references
Установка Arra Memory Lab
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/Soul-Brews-Studio/arra-memory-labFAQ
Arra Memory Lab MCP бесплатный?
Да, Arra Memory Lab MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Arra Memory Lab?
Нет, Arra Memory Lab работает без API-ключей и переменных окружения.
Arra Memory Lab — hosted или self-hosted?
Доступен hosted-вариант: Unyly запускает сервер в облаке, локальная установка не обязательна.
Как установить Arra Memory Lab в Claude Desktop, Claude Code или Cursor?
Открой Arra Memory Lab на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
автор: modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
автор: xuzexin-hzMCP-Agent
A simple, composable framework to build agents using Model Context Protocol by [LastMile AI](https://www.lastmileai.dev)
автор: lastmile-aiSpring AI MCP Client
Provides auto-configuration for MCP client functionality in Spring Boot applications.
mcp.natoma.ai
A Hosted MCP Platform to discover, install, manage and deploy MCP servers by [Natoma Labs](https://www.natoma.ai)
MCPHub
Website to list high quality MCP servers and reviews by real users. Also provide online chatbot for popular LLM models with MCP server support.
MCP Servers Rating and User Reviews
Website to rate MCP servers, write authentic user reviews, and [search engine for agent & mcp](http://www.deepnlp.org/search/agent)
mkinf
An Open Source registry of hosted MCP Servers to accelerate AI agent workflows.
Compare Arra Memory Lab with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории ai
