pi-dense-mem

extension

Pi extension that exposes dense-mem MCP tools as native Pi tools. Replaces pi-mcp-adapter proxy for dense-mem only.

by — · v0.1.1 · published 3w ago

$ pi install npm:pi-dense-mem
downloads/mo
345
stars
—
last push
—
open issues
—

Signals

license: MITtestspi manifest: missinginstall size: —deps: 0peer deps: 0

Download trend

No downloads in the last 12 weeks.

README

pi-dense-mem

Pi extension that exposes dense-mem production MCP tools as native Pi tools. Replaces the pi-mcp-adapter proxy for dense-mem with a direct JSON-RPC client and eliminates the per-call discovery/formatting round-trip.

Status

v0.1.0 — production tool set (7 tools), 89 tests passing, strict TypeScript with exactOptionalPropertyTypes and noUncheckedIndexedAccess.

Install

pi install npm:pi-dense-mem@0.1.1

(Published as pi-dense-mem on npm; can also be installed as a regular npm package: npm install pi-dense-mem.)

Configure

Set PI_DENSE_MEM_URL (default http://127.0.0.1:8080/mcp) and any other env vars you need.

Tools

Pi nameServer methodRead/Write
dense_mem_recall_memoryrecall_memoryR
dense_mem_rememberrememberW
dense_mem_get_submission_statusget_submission_statusR
dense_mem_retract_evidenceretract_evidenceW
dense_mem_correct_relationshipcorrect_relationshipW
dense_mem_trace_memorytrace_memoryR
dense_mem_export_memory_packexport_memory_packR

Tool registration is dynamic: tools/list runs on session_start and only the tools the server actually exposes are registered. The server catalog is the source of truth.

Architecture

┌─────────────────────┐
│ Pi extension        │
│ (this package)      │
├─────────────────────┤
│ extension.ts        │  ← factory + lifecycle, calls buildExtension
│ config/schema.ts    │  ← TypeBox-validated env > file > defaults
│ log/logger.ts       │  ← JSON to stderr, no deps
│ jsonrpc/client.ts   │  ← JSON-RPC 2.0 over fetch, stdlib only
│ client/             │  ← high-level, retry, error translation
│ ready/wait.ts       │  ← exponential backoff, abortable
│ tools/production.ts │  ← 7 production tools, TypeBox schemas
│ tools/create-tool.ts│  ← shared wrapper: validation + serialization
│ errors.ts           │  ← DenseMemError taxonomy
│ retry.ts            │  ← exponential backoff with jitter
└─────────────────────┘
        │
        │ HTTP POST /mcp (JSON-RPC 2.0)
        ▼
┌─────────────────────┐
│ dense-mem server    │
│ (Docker, port 8080) │
└─────────────────────┘

Zero runtime dependencies beyond @sinclair/typebox (which is a pure type-level library; the runtime cost is zero). All HTTP, retry, JSON-RPC, and logging are implemented on top of Node 20+ stdlib.

Development

npm install
npm test           # 89 tests, no network required
npm run typecheck  # tsc --noEmit, strict
npm run build      # tsc -p tsconfig.build.json → dist/

Tests use vitest. No real dense-mem server is needed — the JSON-RPC client takes a fetch implementation that you can mock.

TDD

Every module was written test-first:

test/errors.test.ts       → src/errors.ts
test/retry.test.ts        → src/retry.ts
test/jsonrpc.test.ts      → src/jsonrpc/client.ts
test/client.test.ts       → src/client/dense-mem-client.ts
test/config.test.ts       → src/config/schema.ts
test/logger.test.ts       → src/log/logger.ts
test/ready.test.ts        → src/ready/wait.ts
test/tools.test.ts        → src/tools/create-tool.ts
test/production-tools.test.ts → src/tools/production.ts
test/extension.test.ts    → src/extension.ts

License

MIT. See LICENSE.