Skip to main content
Glama
knowledge-graph-mcp

knowledge-graph-mcp

README.md
# Mnemos

![Mnemos wordmark](docs/assets/mnemos-readme.svg)

Mnemos is a YAML-extensible knowledge graph with a CLI, native Pi and OpenCode 2
adapters, and a stdio MCP server. Hosts share one
Node daemon per canonical database path. No embeddings or external DB server.

**0.2.0 is unreleased and not published to npm yet.** Use a local directory or
built tarball today. See [release status and checklist](docs/release.md).

## Install

Requires **Node 22.19.0+**. Automated release checks target Linux x64.
LadybugDB 0.22.3 also provides native binaries for Linux arm64, macOS x64/arm64,
and Windows x64; this release does not claim full host support on those targets.
Keep optional dependencies enabled: they supply platform-specific native binaries.
Do not use `--omit=optional`. No browser installation is required for consumers.

After publication (these registry commands are not available yet):

```bash
npm install @laurindustries/mnemos@0.2.0
# Or install the three command bins globally:
npm install -g @laurindustries/mnemos@0.2.0
```

From an obtained source directory:

```bash
cd /path/to/mnemos
npm ci
npm pack
# Install the resulting archive in a separate consumer project:
npm install /path/to/mnemos/laurindustries-mnemos-0.2.0.tgz
```

Local adapters can load the directory after `npm ci`. Runtime TypeScript uses
shipped `jiti`, not development-only `tsx`. **`npm run build` is typechecking**;
it does not produce compiled JS. Package exports and bins are runtime bootstraps.
Pi is an optional peer, absent from standalone production installations.

## Pi

```bash
pi install /absolute/path/to/mnemos
# After publication only:
pi install npm:@laurindustries/mnemos@0.2.0
```

Choose one source, not both. `--local` installs into a trusted project's settings.
The manifest loads only `src/index.ts`. Do not also load an archived compatibility
loader: see [relocation and single-loader migration](docs/relocation.md).
The `knowledge_graph` tool shares the schema. `/kg schema` shows it without
starting the graph service. If the explorer is enabled, `/kg` opens it and
`/kg url` prints its URL.

## OpenCode 2 native plugin

In OpenCode 2 configuration, use the native `plugins` array:

```json
{ "plugins": ["/absolute/path/to/mnemos"] }
```

After publication, replace the local path with the pinned registry specifier:

```json
{ "plugins": ["@laurindustries/mnemos@0.2.0"] }
```

The package root exports the native OpenCode 2 plugin, type-checked against
`@opencode/plugin` 2.4.3 without shipping the SDK. OpenCode 1 is not supported.
Bun dispatches the database daemon to Node on PATH; set `PI_KNOWLEDGE_GRAPH_NODE`
if needed. See [release checks](docs/release.md) for tested host behaviors.
Do not declare a second auto-discovered wrapper.

## MCP stdio

Generic client configuration (client formats differ):

```json
{
  "mcpServers": {
    "knowledge-graph": {
      "command": "node",
      "args": ["/absolute/path/to/mnemos/scripts/mcp.mjs"],
      "env": { "PI_KNOWLEDGE_GRAPH_DB": "/absolute/path/to/graph.lbug" }
    }
  }
}
```

For a consumer installation, replace the script path with
`/absolute/path/to/project/node_modules/@laurindustries/mnemos/scripts/mcp.mjs`.
A global installation also provides `knowledge-graph-mcp` on PATH.
Stdout is protocol-only; diagnostics go to stderr. There is no HTTP MCP transport,
raw Cypher, remote access or expanded authentication surface.

## CLI quickstart

Use installed bins on PATH (or `npx --no-install knowledge-graph` in a consumer
project). In the checkout, use `node scripts/cli.mjs` instead.

```bash
knowledge-graph --help
knowledge-graph schema --human
knowledge-graph --db ./demo.lbug upsert-entity project:demo --entity-type Project --name Demo
knowledge-graph --db ./demo.lbug get project:demo
knowledge-graph --db ./demo.lbug search --query demo
knowledge-graph-refresh --help
```

`--db FILE` and `--ontology FILE` select storage and a complete YAML ontology
before modules load. `schema` and CLI help do not start storage. Custom scalar
writes use `--attributes JSON`; exact search uses `--filters JSON`.
See [CLI and tool reference](docs/cli.md) and [ontology](docs/ontology.md).

## Configuration and data safety

- Default DB: `~/.pi/agent/knowledge-graph/graph.lbug`, independent of Pi presence.
- `PI_CODING_AGENT_DIR` changes the compatibility root for **all** hosts.
- `PI_KNOWLEDGE_GRAPH_DB` and `PI_KNOWLEDGE_GRAPH_ONTOLOGY` select explicit files.
  Relative paths resolve against process/session cwd; use absolute shared paths.
- `PI_KNOWLEDGE_GRAPH_PORT`: loopback port (default 7450; 0 means ephemeral).
- `PI_KNOWLEDGE_GRAPH_EXPLORER=1`: opt in to the unauthenticated read-only explorer.
- `PI_KNOWLEDGE_GRAPH_NODE`: Node executable for daemon dispatch.

Use identical ontology, port, and explorer settings for clients of the same database. Mismatched
live owners are refused, never killed automatically. Existing DBs are not moved
or merged. Additive initialization/migrations can occur on opening storage.
Graph writes persist across host reloads, session forks and shutdowns. Deletes
are permanent; cancellation cannot roll back a committed mutation. Never blindly
retry a mutation after a lost response. Never store secrets.

The explorer is **off by default**. When enabled, `http://127.0.0.1:7450/` is
**read-only but unauthenticated**: other local users can read it. Do not expose
it publicly. The tool API always requires a private bearer token. Closing a client
does not stop the owner or change its settings. Back up only after
coordinated owner shutdown; keep the ontology manifest, exclude credential/service
artifacts. See [operations, security, backup and coexistence](docs/operations.md).

## Reference

- [Ontology and compatibility/migrations](docs/ontology.md)
- [CLI and shared tool actions](docs/cli.md)
- [Operations and explorer limitations](docs/operations.md)
- [Refresh: preview, ownership, pruning and scheduling](docs/refresh.md)
- [Development and tests](docs/development.md) · [Brand assets](docs/branding.md)
- [Release checklist and known blockers](docs/release.md)
- [Changelog](CHANGELOG.md) · [MIT license](LICENSE)