touch
Boost a memory's strength to counteract forgetting. Use this when a memory is referenced or found relevant.
Instructions
Boost a memory's strength (simulate access, counteracts Ebbinghaus decay). Use this when a memory is referenced or found relevant.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Memory filename (with or without .md extension) | |
| boost | No | Strength boost amount (default 0.15, max 1.0) |
Implementation Reference
- nexus_mcp.py:153-164 (schema)Schema definition for the 'touch' tool: accepts 'name' (required) and 'boost' (optional, default 0.15, max 1.0).
{ "name": "touch", "description": "Boost a memory's strength (simulate access, counteracts Ebbinghaus decay). Use this when a memory is referenced or found relevant.", "inputSchema": { "type": "object", "properties": { "name": {"type": "string", "description": "Memory filename (with or without .md extension)"}, "boost": {"type": "number", "description": "Strength boost amount (default 0.15, max 1.0)"}, }, "required": ["name"], }, }, - nexus_mcp.py:262-297 (handler)Handler for the 'touch' tool: finds a memory by name, reads its frontmatter, boosts its strength (capped at 1.0), updates last_accessed and access_count, and writes back.
elif name == "touch": target = args["name"] boost = min(float(args.get("boost", 0.15)), 1.0) target_lower = target.lower().replace(".md", "") files = list_memory_files() match = None for f in files: if f["name"].lower() == target_lower: match = f break if not match: return None, {"code": -32602, "message": f"Memory not found: {target}"} filepath = os.path.join(MEMORY_DIR, match["path"]) with open(filepath, encoding="utf-8") as fh: text = fh.read() old_s = match["strength"] new_s = min(old_s + boost, 1.0) text = re.sub(r'^(strength:\s*)[\d.]+', rf'\g<1>{new_s:.2f}', text, flags=re.MULTILINE) text = re.sub(r'^(\s+strength:\s*)[\d.]+', rf'\g<1>{new_s:.2f}', text, flags=re.MULTILINE) today = date.today().isoformat() if re.search(r'last_accessed:', text): text = re.sub(r'^(last_accessed:\s*).*', rf'\g<1>{today}', text, flags=re.MULTILINE) text = re.sub(r'^(\s+last_accessed:\s*).*', rf'\g<1>{today}', text, flags=re.MULTILINE) if re.search(r'access_count:', text): ac = parse_frontmatter(text, "access_count") new_ac = int(ac) + 1 if ac else 1 text = re.sub(r'^(access_count:\s*)\d+', rf'\g<1>{new_ac}', text, flags=re.MULTILINE) text = re.sub(r'^(\s+access_count:\s*)\d+', rf'\g<1>{new_ac}', text, flags=re.MULTILINE) with open(filepath, "w", encoding="utf-8") as fh: fh.write(text) return {"content": [{"type": "text", "text": f"Touched {target}: strength {old_s:.2f} → {new_s:.2f}"}]}, None - nexus_mcp.py:120-170 (registration)TOOL_DEFS list where all tools including 'touch' are registered.
TOOL_DEFS = [ { "name": "search", "description": "Search across all memory files by keyword. Returns matching file names, titles, strengths, and context snippets.", "inputSchema": { "type": "object", "properties": {"query": {"type": "string", "description": "Keyword or phrase to search for"}}, "required": ["query"], }, }, { "name": "stats", "description": "Show memory health statistics: file counts per tier, average strength, active/decaying/archived counts.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "save", "description": "Save a new memory to a specified tier. Creates a markdown file with frontmatter. Use for recording new information, preferences, or experiences.", "inputSchema": { "type": "object", "properties": { "tier": { "type": "string", "enum": ["episodic", "semantic", "procedural", "reflection", "working"], "description": "Memory tier: episodic (experiences), semantic (facts/preferences), procedural (workflows), reflection (meta), working (in-session)", }, "name": {"type": "string", "description": "Filename slug (no extension, use dashes: my-memory-name)"}, "content": {"type": "string", "description": "Full markdown content of the memory (including title heading)"}, "tags": {"type": "string", "description": "Comma-separated tags (optional)"}, }, "required": ["tier", "name", "content"], }, }, { "name": "touch", "description": "Boost a memory's strength (simulate access, counteracts Ebbinghaus decay). Use this when a memory is referenced or found relevant.", "inputSchema": { "type": "object", "properties": { "name": {"type": "string", "description": "Memory filename (with or without .md extension)"}, "boost": {"type": "number", "description": "Strength boost amount (default 0.15, max 1.0)"}, }, "required": ["name"], }, }, { "name": "decay", "description": "Run a dry-run decay check. Calculates Ebbinghaus decay for all memories and reports which would be archived. Does NOT modify any files.", "inputSchema": {"type": "object", "properties": {}}, }, ] - nexus_mcp.py:368-375 (registration)tools/call dispatch in main loop that routes to handle_tools_call for the 'touch' tool.
elif method == "tools/call": name = params.get("name", "") args = params.get("arguments", {}) result, err = handle_tools_call(req_id, name, args) if err: respond(req_id, error=err) else: respond(req_id, result) - nexus_mcp.py:14-26 (helper)Helper function parse_frontmatter used by the touch handler to read strength, access_count, etc.
def parse_frontmatter(text, field): """Extract a YAML frontmatter field value from markdown text.""" m = re.search(rf'^{re.escape(field)}:\s*(.+)$', text, re.MULTILINE) if m: val = m.group(1).strip() val = re.sub(r'\s*#.*$', '', val).strip() return val m = re.search(rf'^\s+{re.escape(field)}:\s*(.+)$', text, re.MULTILINE) if m: val = m.group(1).strip() val = re.sub(r'\s*#.*$', '', val).strip() return val return None