# Using the memory connector ## Registering it for agents `plugin_memory` is an **MCP connector**, not a standalone MCP server. Installed through `plugin_manage` (or **Settings → Plugins**), it announces `kind:"mcp"`, `mcp:true`, `menus:false`, and `scorpiox-bot-api` records it in `/mcp_plugins.json`: ```json { "mcpServers": { "memory": { "command": "/root/.scorpiox/plugins/plugin_memory", "args": ["--mcp"] } } } ``` `clang` never sees that file. `scorpiox-bot-api` ships one stdio router, `sx-connector-mcp`, registered as a **single** MCP server; it reads `mcp_plugins.json` and exposes four compact meta-tools — `connector_list`, `connector_search`, `connector_tools`, `connector_call`. That is why a node can carry hundreds of connectors without touching `MAX_SERVERS 16` or bloating the prompt: only the router's four tools are ever in context, and the nine memory tools are fetched on demand. ## Talking to it by hand ```sh # discovery (no password) ./plugin_memory --meta # the nine tool schemas ./plugin_memory --schema | python3 -m json.tool # a real JSON-RPC session: one request per line, one response per line printf '%s\n' \ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \ '{"jsonrpc":"2.0","method":"notifications/initialized"}' \ '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \ '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"create_entities","arguments":{"entities":[{"name":"Earl Grey","entityType":"tea","observations":["black tea","bergamot"]}]}}}' \ '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"read_graph","arguments":{}}}' \ | ./plugin_memory --mcp ``` Through the router, which is how an agent reaches it: ```sh sx-connector-mcp --list sx-connector-mcp --tools memory sx-connector-mcp --call memory create_entities \ '{"entities":[{"name":"Earl Grey","entityType":"tea","observations":["black tea"]}]}' sx-connector-mcp --call memory read_graph '{}' ``` ## Prompt recipes that work The tool names, schemas and error sentences match the upstream reference memory server, so existing prompts transfer unchanged. Two that earn their keep: **Orient first, read second.** On a graph you did not build, do not open the whole thing. Ask for the cheap overview, then open only what matters: > Read the graph with `observationLimit: 0` to see every entity name, type and > observation **count**. Then `open_nodes` on the two or three names you > actually need, without the limit, to read their full observations. **Facts, not prose.** An observation is one atomic claim an agent can match on exactly (`delete_observations` matches exact text). "deploy runs on .100 via tmux" is a fact; "notes about deploying" is not. ## Session memory pattern A common shape for a long-running assistant: 1. At the start of a session: `read_graph` with `observationLimit: 0` — one cheap call that tells the agent what it already knows. 2. When the user states something worth keeping: `create_entities` for the thing, then `create_relations` to hang it on something already in the graph. The relation is the memory; two unlinked entities are two facts nobody can find. 3. Before correcting: `delete_observations` on the exact stale text, then `add_observations` with the new one. Never delete and recreate the entity — that silently drops its relations. ## Where the data lives, and how to move it | Situation | Do this | |---|---| | Default | `~/.scorpiox/connectors/plugin_memory/memory.jsonl` | | BotCloud container (rootfs does not survive stop → start) | `/workspace/.scorpiox/connectors/plugin_memory/memory.jsonl` — used automatically when `/workspace` exists | | Windows node | `%LOCALAPPDATA%\scorpiox\connectors\plugin_memory\memory.jsonl` | | Put it somewhere else | `MEMORY_FILE_PATH=/srv/memory/graph.jsonl` (absolute, or relative to the connector dir; `..` is refused) | The file is plain JSONL — one `{"type":"entity",...}` or `{"type":"relation",...}` per line. Back it up by copying it, edit it in any editor, `git` it, or move it between nodes. Lines the loader cannot parse are preserved byte for byte and reported as `unreadable_lines` in `?action=stats`, so a hand-edit that breaks one line cannot lose the graph. `?action=export` downloads the file as-is; `GET /plugin_memory?action=export` with the node password is the whole backup path. ## Limits | Knob | Default | Effect | |---|---|---| | `MEMORY_MAX_ENTITIES` | 20000 | creating past this is refused with an instruction to delete | | `MEMORY_MAX_RELATIONS` | 40000 | same | | `MEMORY_MAX_OBS` | 2000 per entity | extra observations in a call are dropped, the call still succeeds | | `MEMORY_MAX_BAD` | 5000 | how many unparseable lines are carried forward verbatim | | `MEMORY_LOCK_STALE_MS` | 10000 | a `.lock` older than this is treated as abandoned and broken | | `MEMORY_LOCK_TIMEOUT_MS` | 2000 | how long a second writer waits for the lock before proceeding best-effort | ## Troubleshooting | Symptom | Cause | |---|---| | `--meta` fine, tools missing in the agent | the router has not re-read `mcp_plugins.json` — reinstall through `plugin_manage`, or restart the session so `scorpiox-mcp` respawns | | `{"error":{"code":-32601}}` | method not supported by design (`prompts/*`, `tools/*` typos). Only `initialize`, `ping`, `notifications/*`, `tools/list`, `tools/call`, `resources/list`, `resources/read` answer | | A tool "failed" but there is no JSON-RPC error | intentional: tool failures are results with `isError:true` and the reason in `content[0].text`, so the agent can read and correct | | `create_entities` created nothing | the name already exists (check `skipped`) — use `add_observations`, which is the tool for that | | `Entity with name X not found` on `create_relations` | both ends must exist first; create the entities, then link | | Two processes writing at once | the second takes a `.lock` and waits; if it times out, a stale `.lock` older than `MEMORY_LOCK_STALE_MS` is broken automatically |