CPersona

v2.5.3
io.github.Cloto-dev/cpersona Checked 2 hours ago Published 4 months ago

Persistent AI memory in one SQLite file: 3-layer hybrid search, confidence scoring, 29 tools.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

pause_persistence

Pause write operations on this MCP server for an opt-in TTL window. While paused, every write tool — store, archive_episode, update_memory, delete_memory, delete_episode, delete_agent_data, lock_memory, unlock_memory, update_profile, import_memories, merge_memories, calibrate_threshold, set_recall_precision — returns a no-op response carrying `persisted: false`, `dry_run: true` and a `reason` (with the TTL remaining) instead of writing to the database. `persisted: false` is the authoritative signal: branch on it, not on an id. Where the success shape has an `id`, it reads `"no-persist"` (s…

ParameterTypeDescription
ttl_secondsintegerTTL until automatic resume. Min 1, max 86400 (clamped). Default 1800.

resume_persistence

Re-enable persistence immediately, clearing any active no-persist TTL. Returns was_active=true if persistence was paused before this call. **The flag is PROCESS-WIDE (response `scope`: "process"): on a streamable-HTTP deployment this re-enables writes for every connected session sharing the process, not just the caller's.**

persistence_status

Report whether persistence is currently paused and the TTL remaining (in seconds). The reported state is PROCESS-WIDE (response `scope`: "process"): on a streamable-HTTP deployment it reflects the one flag shared by every connected session, so `paused: true` may have been set by a different session.

get_operating_context

Read the server-served operating context (v2.5.1): the operator-owned doctrine distributed to every connected client. Without arguments returns the preview tier — context_revision, instructions_summary, project_id registry (+ enforce mode), @auto defaults, and doctrine section names. Pass section to fetch one section's full body. Read-only: the context is edited by the operator on the filesystem (~/.cpersona/operating-context.toml), never via MCP.

ParameterTypeDescription
sectionstringDoctrine section name to fetch in full (from doctrine_sections). Empty = preview tier.

store

Store a message in agent memory for future recall. Every response carries result — the one field to branch on: 'stored' (a new row was written; {ok:true, result:'stored', id:<row-id>, embedded:<bool>}, embedded true iff a local blob was persisted or the remote index push succeeded — false under EMBEDDING_MODE=none; the response also carries truncated:true when content exceeded the length cap and was shortened), 'skipped' (nothing written and nothing wrong: {ok:true, result:'skipped', reason:...}; the msg_id / content dedup branches echo the pre-existing row's id, the OR IGNORE fallback rea…

ParameterTypeDescription
agent_id *stringAgent identifier
message *objectClotoMessage to store. Legacy source shapes are normalized server-side where unambiguous (e.g. lowercase type words, Rust serde externally-tagged dicts, bare 'user'/'assistant' strings); unknown shape…
channelstringMemory channel for context separation (e.g. 'chat', 'discord'). Default: '' (shared).
project_idstringv2.4.17 isolation axis. Optional — omit or pass '' to store in the global pool. Reads via γ semantics: a recall with project_id='X' returns 'X' rows + global pool. v2.5.1: pass '@auto' to resolve t…

recall

Recall relevant memories using multi-strategy search (vector + FTS5 + keyword). Message content is returned as a preview tier by default — expand selected rows with get_contents(refs), or opt out wholesale with full_content=true. v2.5.2 additive: each scored message carries match_reason={signal, score, ...} where signal is the branch the ranking / quality gate keyed on (confidence > rsf > cosine > rrf) and the remaining keys (cosine / rrf / rsf) surface the internal per-retriever contributions present on that row. Unscored rows (cascade FTS/keyword) omit match_reason. A response carrying gat…

ParameterTypeDescription
agent_id *stringAgent identifier
query *stringSearch query (empty returns recent memories)
channelstringFilter memories by channel (e.g. 'chat', 'discord'). Default: '' (all channels).
deepbooleanDeep recall — disable time and completion decay for exhaustive search
exclude_contentsarrayNormalized content strings to exclude from results (starts-with match). Used to prevent duplication with conversation context already known to the caller.
full_contentbooleanv2.5.0 preview tier opt-out. By default message content longer than the preview cap (CPERSONA_RECALL_PREVIEW_CHARS, default 500) is returned as a pure prefix with content_truncated/content_len markers…
limitintegerMax memories to return (agent-facing cap; the library layer accepts up to the scan window for direct callers)
project_idstringv2.4.17 γ filter. Omit → no filter (all projects). '' → global pool only. 'X' → 'X' bucket ∪ global pool. Threaded through cascade / RRF / vector / FTS / keyword paths. v2.5.1: pass '@auto' t…
source_idstringv2.4.20 per-user source filter. Empty (default) = no filter. Non-empty = prefix match against json_extract(source, '$.id'), e.g. 'discord:12345' to restrict to one Discord user, or 'discord:' to scope…

recall_with_context

Recall memories and merge with external conversation context. Automatically deduplicates, sorts chronologically, and returns a unified list. Replaces separate recall + manual merge in the caller. Content is preview-tiered by default — see recall's full_content / get_contents. Every external_context entry's content filters the recall (the caller already holds that text), but only role=user / role=assistant entries are merged into messages. When entries of other roles are present the response carries context_filter_only={roles:[...]} — those entries filtered the recall without appearing in t…

ParameterTypeDescription
agent_id *stringAgent ID
query *stringSearch query
channelstringMemory channel filter
deepbooleanDisable time decay
external_contextarrayConversation history entries [{role, name?, user_id?, content, timestamp?}, ...]
full_contentbooleanv2.5.0 preview tier opt-out — same semantics as in `recall`.
limitintegerMax recalled memories (agent-facing cap; the library layer accepts up to the scan window for direct callers)
project_idstringv2.4.17 γ filter — passed through to recall. Same semantics as in `recall`. v2.5.1: pass '@auto' to resolve this agent's default from the server's operating context (the resolution is echoed as res…
source_idstringv2.4.20 per-user source filter — passed through to recall. Same semantics as in `recall`.

get_contents

Fetch full, untrimmed content for recall preview refs. Use after a preview-tier recall to expand only the rows that matter instead of opting the whole recall out with full_content=true.

ParameterTypeDescription
agent_id *stringAgent identifier (ownership check — another agent's refs come back in `missing`)
refs *arrayRefs from recall messages, e.g. ['mem:123', 'ep:45'] (max 20 per call)

get_profile

Get the current profile for an agent.

ParameterTypeDescription
agent_id *stringAgent identifier

update_profile

Save a pre-computed agent profile to the database.

ParameterTypeDescription
agent_id *stringAgent identifier
profile *stringProfile text to save (pre-computed by caller)

archive_episode

Archive a conversation episode with pre-computed summary, keywords, and resolved status. All LLM processing is performed by the caller.

ParameterTypeDescription
agent_id *stringAgent identifier
summary *stringEpisode summary (pre-computed by caller)
channelstringv2.4.22 conversation-channel tag (e.g. a Discord channel id). Default '' (= unscoped). Channel-scoped recall returns episodes whose channel matches; this powers the per-channel episodic loop.
historyarrayOriginal conversation messages (used for start/end timestamp extraction; the episode embedding is computed from summary)
keywordsstringSpace-separated keywords (pre-computed by caller)
project_idstringv2.4.17 isolation axis. Omit or pass '' for the global pool. v2.5.1: pass '@auto' to resolve this agent's default from the server's operating context (the resolution is echoed as resolved_project_id;…
resolvedbooleanWhether the topic was completed/concluded

list_memories

List recent memories for an agent (for dashboard display).

ParameterTypeDescription
agent_idstringAgent identifier (empty for all agents)
limitintegerMax memories to return
project_idstringv2.4.17 γ filter. Omit → no filter; '' → global pool only; 'X' → 'X' ∪ global pool. v2.5.1: pass '@auto' to resolve this agent's default from the server's operating context (the resolution is…

list_episodes

List archived episodes for an agent (for dashboard display).

ParameterTypeDescription
agent_idstringAgent identifier (empty for all agents)
limitintegerMax episodes to return
project_idstringv2.4.17 γ filter. Same semantics as list_memories. v2.5.1: pass '@auto' to resolve this agent's default from the server's operating context (the resolution is echoed as resolved_project_id; an unmapp…

delete_agent_data

Delete ALL data (memories, profiles, episodes) for a specific agent. Used by kernel during agent deletion.

ParameterTypeDescription
agent_id *stringAgent ID whose data should be purged

calibrate_threshold

Auto-calibrate the vector search threshold from the null (random-pair) cosine distribution. Samples random memory pairs and places the threshold ABOVE the null mean so unrelated pairs are rejected. method='separation' (default) learns the operating point from two populations — null pairs vs temporally-adjacent same-session positives (nearest-neighbour fallback when too few exist); method='percentile' uses a quantile of the null distribution (robust to anisotropic models such as bge-m3); method='zscore' uses mean + z*std. No labels used, purely statistical. Adapts to both embedding model and…

ParameterTypeDescription
agent_id *stringAgent ID whose memories to sample
methodstring'separation' (default; two-population — learns the operating point from null pairs vs temporally-adjacent same-session positives, falling back to nearest-neighbour when too few exist), 'percentile',…
percentilenumberNull-distribution quantile for method='percentile' (default: 0.95, higher = stricter)
sample_sizeintegerNumber of embeddings to sample (default: 200)
z_factornumberZ-score multiplier for method='zscore' (default: 1.0, higher = stricter)

set_recall_precision

Set an agent's recall precision (knob 3) and recalibrate its quality gate. precision = strict | balanced | lenient maps to a specificity weight beta of 2.0 / 1.0 / 0.5 in the gate separation objective (sensitivity + beta*specificity): strict sits the gate higher (fewer contaminants, more misses), lenient lower (fewer misses, more contaminants). A raw beta > 0 overrides the named level; an empty precision with beta <= 0 clears the per-agent override and returns the agent to the global CPERSONA_RECALL_PRECISION default. The gate is recalibrated at the new beta immediately and persisted, so the c…

ParameterTypeDescription
agent_id *stringAgent whose precision to set
betanumberRaw specificity weight; overrides the named precision when > 0.
precisionstringstrict / balanced / lenient. Empty (with beta <= 0) clears the override.

get_recall_precision

Read an agent's effective recall precision (knob 3) — the read-back companion to set_recall_precision. Returns the resolved specificity weight (beta) and its named precision level (strict / balanced / lenient, or 'custom' for a raw beta), and flags whether the value is a per-agent override or the global CPERSONA_RECALL_PRECISION default (overridden + global_precision / global_beta). Read-only: it never recalibrates and never persists, so a UI can load the current setting, let the user edit it, and write it back instead of the control being write-only.

ParameterTypeDescription
agent_id *stringAgent whose precision to read

delete_memory

Delete a single memory by ID. Ownership is enforced when agent_id is provided.

ParameterTypeDescription
memory_id *integerMemory ID to delete
agent_idstringAgent ID for ownership verification (injected by kernel)

delete_episode

Delete a single episode by ID. Ownership is enforced when agent_id is provided.

ParameterTypeDescription
episode_id *integerEpisode ID to delete
agent_idstringAgent ID for ownership verification (injected by kernel)

update_memory

Update memory content by ID. Rejects if memory is locked. Ownership enforced when agent_id provided. The new content passes through the same sanitizer as store: it is capped at the content length limit (the response carries truncated:true when the cap bit) and [Memory from ...] annotations are stripped, so content consisting only of those is refused rather than written as an empty row.

ParameterTypeDescription
content *stringNew content for the memory
memory_id *integerMemory ID to update
agent_idstringAgent ID for ownership verification

lock_memory

Lock a memory to prevent deletion and editing. Ownership enforced when agent_id provided.

ParameterTypeDescription
memory_id *integerMemory ID to lock
agent_idstringAgent ID for ownership verification

unlock_memory

Unlock a memory to allow deletion and editing. Ownership enforced when agent_id provided.

ParameterTypeDescription
memory_id *integerMemory ID to unlock
agent_idstringAgent ID for ownership verification

get_queue_status

Get the status of the background task queue (pending tasks, retry config).

export_memories

Export memories, episodes, and profiles to a JSONL file for backup or portability.

ParameterTypeDescription
agent_id *stringAgent identifier (empty string to export all agents)
output_path *stringFile path for the JSONL output
include_embeddingsbooleanInclude embedding BLOBs as base64 (default false, usually not needed)

import_memories

Import memories, episodes, and profiles from a JSONL file. Idempotent via msg_id deduplication.

ParameterTypeDescription
input_path *stringPath to the JSONL file to import
dry_runbooleanCount records without writing to DB (preview mode)
target_agent_idstringRemap all records to this agent ID (empty to use original agent_id from file)

merge_memories

Merge memories, episodes, and profiles from one agent into another. Atomic one-shot equivalent of export→import without intermediate files. Strategy 'skip' deduplicates by msg_id (memories) and summary (episodes).

ParameterTypeDescription
source_agent_id *stringAgent ID to merge FROM
target_agent_id *stringAgent ID to merge INTO
dry_runbooleanPreview merge without writing to DB
modestringMerge mode: 'copy' (preserve source) or 'move' (delete source after merge)
strategystringMerge strategy: 'skip' (default) — skip duplicates, keep target's version

check_health

Check memory database health (25-check registry, each issue tagged with severity critical/warn/info). Detects contamination, duplicates, oversized content, embedding issues, FTS integrity (count + content-level), schema version/object drift (missing UNIQUE indexes or FTS triggers), SQLite file integrity, project_id naming drift, invalid JSON/timestamps, timestamp format drift, stale tasks, missing profiles, empty content, invalid/anonymous sources. Returns storage stats incl. project_id/channel distributions. Set fix=true to auto-repair (agent-scoped, locked-safe); critical file-integrity find…

ParameterTypeDescription
agent_idstringAgent ID to check (empty = all agents)
checksarrayRegistry check names to run (empty = all). See cpersona.checks.HEALTH_CHECK_NAMES.
fixbooleanAuto-fix detected issues

deep_check

Deep heuristic analysis of memory data quality. Detects issues requiring recovery or judgment (anonymous sources, short/trivial content, stale profiles, orphaned episodes, stale threshold calibration, embedding-space near-duplicate pairs as merge candidates). fix=true applies repairs for: anonymous_source, short_content. Report-only (fix is accepted and ignored): stale_profile, orphaned_episodes, calibration_staleness, near_duplicate — apply those decisions via merge_memories / delete_memory / calibrate_threshold / update_profile. Use checks parameter to select specific checks.

ParameterTypeDescription
agent_id *stringAgent ID to check (required)
checksarrayChecks to run (empty = all). Options: anonymous_source, short_content, stale_profile, orphaned_episodes, calibration_staleness, near_duplicate
fixbooleanApply repairs (default: dry-run preview only)

migrate_channel_axis

Re-channel bridge-type memories to their concrete channel (knob2 v2 default flip prep). Memories the kernel filed under the bridge type ('discord') are rewritten to the concrete channel recovered from the stored session_id ('{channel_id}:{user_id}:{chunk}' | '{channel_id}:shared' → channel_id), so per-channel recall can match them. Non-destructive (only the channel column changes) and idempotent (re-running is a no-op once moved). dry_run=true (default) reports the recoverable count, the channels that would be recovered, and an unrecoverable bucket (channel='discord' rows with no snowflake s…

ParameterTypeDescription
agent_idstringAgent ID to migrate (empty = all agents)
dry_runbooleanPreview counts only, no mutation (default: true)
globalize_unrecoverablebooleanAlso move channel='discord' rows with no snowflake session_id to channel='' (global). Default false.