Diary
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Diary — MCP Server for AI Session Logs and Practice Knowledge Base
MCP server and CLI tools for maintaining a structured diary from Claude Code session logs, plus a practice knowledge base for operational rules and structured work history. Records what was done, on which cases, with what outcome — and makes it searchable across sessions.
Features
Diary management: chronologically ordered markdown entries with search, pagination, and case-based filtering
Session log parsing: extract summaries, outlines, and user messages from Claude Code JSONL session logs
New entry detection: automatically identifies sessions that need diary entries (NEW, STALE, ONGOING, CAUGHT UP)
Stale session suppression: mark finished sessions as "done" to keep check output clean; auto-unsuppresses if a session is re-opened
Supplemental entries: append follow-up notes to existing entries when a session continues
Custom prompts: per-project prompt templates for controlling diary entry style
Practice rules database: accumulate operational rules tagged by context, with duplicate detection and refinement
Work log: structured record of activities (date, matter, client, action type, outcome) with filtering and aggregation
Setup check: one-shot report on diary, practice DB, session dir, prompt files, and MEMORY.md wiring
Rules export: dump the practice DB to human-readable markdown or plain text
Dual interface: works as an MCP server or standalone CLI
A companion document, HOW_THE_MEMORY_WORKS.md, explains how the diary, practice DB, auto-memory, CLAUDE.md, and raw session logs relate to one another.
Related MCP server: work-tracker
Requirements
Python 3.10+
mcppackage (the FastMCP SDK)
pip install -r requirements.txtQuick start
As MCP server
Add to your Claude Code MCP configuration (~/.claude.json or project .mcp.json):
{
"mcpServers": {
"diary": {
"command": "python",
"args": ["/path/to/tools/diary_mcp.py"]
}
}
}Restart Claude Code. The diary tools will appear as mcp__diary__*.
As CLI
# List all tools
python tools/diary_mcp.py --list-tools
# Run a tool directly
python tools/diary_mcp.py diary_list
python tools/diary_mcp.py diary_check_new
python tools/diary_mcp.py session_outline <session_id>
# Standalone diary CLI (diary commands only)
python tools/diary_tool.py list
python tools/diary_tool.py check
python tools/diary_tool.py page 3Architecture
diary_mcp.py ← MCP server entry point (also CLI: diary_mcp.py <tool> [args])
diary_mcp_shared.py ← Shared FastMCP instance, paths, parsing helpers, prompt templates
mcp_diary_tools.py ← Diary management MCP tools (list, page, search, insert, supplement, etc.)
mcp_session_tools.py ← Session log parsing MCP tools (list, summary, outline, user_messages)
mcp_practice_tools.py ← Practice-knowledge MCP tools (work_log_*, practice_rules_*, practice_check_setup)
practice_db.py ← SQLite backend for the practice knowledge base (schema + CRUD helpers)
diary_tool.py ← Standalone CLI wrapper (thin layer over the MCP tool functions)
session_parser.py ← Legacy standalone CLI for session parsing (works independently)
seed_practice_db.py ← One-time seed of initial practice rules
seed_work_log.py ← One-time seed of initial work_log entries
export_practice_db.py ← Dump practice.db to human-readable markdown or text
test_practice.py ← Pytest suite for the practice DBData files live under diary/ in the working project:
diary/
diary.md ← the diary itself
practice.db ← SQLite: work_log + practice_rules
diary_prompt.md ← custom entry prompt (optional)
diary_supplemental_prompt.md ← custom supplemental prompt (optional)
suppressed.json ← suppression list (auto-managed)
tmp/ ← staging area for entries before insertionMCP Tools
Diary tools
Tool | Args | Description |
| — | List all entries with date, session ID, and title |
| — | List session IDs in the diary (for deduplication) |
|
| Paginate through full entry text (default: page 1, 5/page) |
|
| Search entries by space-separated keywords (AND logic). Paginated (default 3/page). |
|
| Get entries by date (e.g. "25 February" or "2026-02-25") |
|
| Insert entry from file at correct chronological position |
|
| Insert entry from raw text |
|
| Append supplemental section to existing entry |
| — | List all case codes with entry counts |
|
| Find all entries mentioning a case. Paginated (default 3/page). |
| — | Show the prompt template for generating new entries |
| — | Show the prompt template for generating supplemental entries |
|
| Check: NEW, STALE, ONGOING, SUPPRESSED, CAUGHT UP. Optional auto-suppress threshold. |
|
| Suppress sessions from diary_check_new (comma-separated IDs or 8-char prefixes) |
|
| Remove sessions from the suppression list |
Session tools
Tool | Args | Description |
| — | List all sessions with dates, sizes, message counts |
|
| Compact summary: tools, matter codes, files, messages |
|
| Full conversation outline; |
|
| Just the user messages from a session |
Practice-knowledge tools
All data lives in diary/practice.db (SQLite). The DB and its tables are created automatically on first use.
Work log — structured record of activities:
Tool | Args | Description |
|
| Record a work activity. |
|
| Query the log with optional filters. Returns matching rows ordered newest-first. |
|
| Aggregate counts. |
Practice rules — accumulated operational rules tagged by context:
Tool | Args | Description |
| — | List all context tags in use with rule counts. Call this before |
|
| Find active rules matching ANY of the comma-separated context tags (e.g. |
|
| Add a new rule. Automatically flags near-duplicates (>40% keyword overlap with an existing rule sharing a tag) so you can refine the existing rule instead. |
|
| Force-add a rule, bypassing duplicate detection. Use only after confirming the candidate is distinct from the flagged rule. |
|
| Edit an existing rule. Set |
|
| Dump all rules. Set |
Setup check
Tool | Args | Description |
| — | One-shot status report: presence and counts for |
Context tags
Context tags are free-text labels attached to each practice rule and normalised to lowercase on insert. They are the primary retrieval axis: when about to start a task, call practice_rules_lookup with the relevant tags to surface any applicable rules.
Typical tag patterns in use:
Activity:
oa_response,client_letter,reporting_letter,idf_drafting,claim_draft,claim_amendment,patentability_assessment,prior_art_analysis,case_analysis,docx_editing,track_changes,filing_prepJurisdiction / procedure:
ep,pct,problem_solution_approach,oral_proceedings,amended_descriptionCross-cutting:
basis_check,inventive_step,clarity,samsung,email
Rules typically carry two or three tags (activity + cross-cutting). Add tags liberally — broader tagging means rules surface more often. Use practice_rules_contexts to see what tags already exist before inventing new ones.
Duplicate detection
practice_rules_add runs a cheap heuristic before inserting:
Strip stopwords and short tokens from the proposed rule to get distinctive keywords.
Find existing active rules that share at least one context tag.
Score them by how many keywords appear in their rule text.
If the top match has ≥40% keyword overlap, return it instead of inserting.
When a duplicate is flagged, the correct response is almost always practice_rules_update on the existing rule (to refine or expand it) rather than practice_rules_add_force. Force-add only when the new rule is genuinely distinct and simply happens to share vocabulary.
Exporting the practice database
export_practice_db.py dumps diary/practice.db to human-readable form for review, diffing, or archival.
# Markdown to stdout, rules grouped by context tag (default)
python export_practice_db.py
# Write to file
python export_practice_db.py -o rules.md
# Include retired (inactive) rules
python export_practice_db.py --include-inactive
# Group by id instead of context (each rule appears once)
python export_practice_db.py --by id
# Also dump the work_log table
python export_practice_db.py --work-log
# Plain-text output instead of markdown
python export_practice_db.py --format text
# Work log only
python export_practice_db.py --work-log-onlyThe default grouping by context means a rule tagged a,b appears under both a and b; the #id header is the canonical reference. Use --by id for a flat, deduplicated dump.
Diary entry format
## DD Month YYYY, HH:MM–HH:MM — <case(s)>: <short title>
**Session**: `<session-uuid>`
**Entry written**: 2026-03-12T16:46
**Last updated**: 2026-03-12T18:30 ← only present if supplementals added
**Case**: <matter_code> (description)
**Task**: What was being worked on
**What happened**: Detailed narrative...
**Difficulties**: Problems encountered...
**Outcome**: Deliverables and results...
**Strategic notes for future reference**: Insights not in the deliverables...
### Supplemental — 12 March 2026, 18:30 ← appended when session continues
**Task**: Continuation work...
**What happened**: ...Workflow for writing new diary entries
Run
diary_check_newto see which sessions need entriesIt reports 5 categories:
NEW — sessions with no diary entry → use
diary_prompttemplateSTALE — sessions with an entry but significant new activity → use
diary_supplemental_prompttemplateONGOING — sessions active within the last 2 hours → skip for now
SUPPRESSED — sessions explicitly marked as done (count only)
CAUGHT UP — everything accounted for
For NEW sessions: use the template from
diary_prompt(replacing{SESSION_ID}and{SESSION_SHORT})For STALE sessions: use the template from
diary_supplemental_prompt(replacing{SESSION_ID},{SESSION_SHORT}, and{AFTER_TIMESTAMP})To dismiss stale sessions you don't intend to process:
diary_suppresswith their session IDsTo auto-suppress old stale sessions:
diary_check_newwithmax_stale_days=14Re-run
diary_check_newto confirm
Project-specific prompts
The prompt templates served by diary_prompt and diary_supplemental_prompt can be customised per project. Place the prompt files alongside diary.md (see the directory layout in the Architecture section above).
If a custom prompt file exists, it is used verbatim. If not, the server returns a generic default.
Custom prompts must contain {SESSION_ID} and {SESSION_SHORT} placeholders (and {AFTER_TIMESTAMP} for supplementals).
Testing
# Syntax check
python -c "import diary_mcp"
# List all tools with signatures
python diary_mcp.py --list-tools
# Run any tool directly
python diary_mcp.py diary_check_new
python diary_mcp.py practice_check_setup
python diary_mcp.py practice_rules_contexts
# Practice database tests
python -m pytest test_practice.py -vSession log location
Session logs are auto-detected from ~/.claude/projects/. The server converts the working directory to a Claude Code project slug and looks for the matching session log directory.
Safety note
Session logs can be very large (20+ MB). Never read them directly with the Read tool. Always use the session parsing tools, which handle truncation automatically.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Running journal for Claude & ChatGPT: logs runs, reads your history, writes your next session.
MCP-native notes and memory for ChatGPT, Claude, and other AI tools.
Persistent memory layer for AI tools. Save and recall notes across Claude and other MCP clients.
Persistent AI memory shared across Claude, ChatGPT, coding agents, and compatible MCP clients.
Related MCP Servers
- AlicenseAqualityBmaintenancePersistent local memory for Claude Code that indexes every session's JSONL file verbatim into SQLite + ChromaDB. Exposes 17 MCP tools for semantic recall, deterministic file replay, and fuzzy "do you remember when..." queries across your entire session history — no API calls, nothing leaves the machine.17202 PyPI17MIT
- AlicenseNot gradedqualityCmaintenanceAutomatically tracks AI-assisted work sessions, code changes, and commands in Claude Code or Codex CLI, and provides daily stats, weekly reports, and data export through MCP tools.23 npmMIT
- FlicenseNot gradedqualityDmaintenanceCollects session JSONL from Codex and Claude Code into local SQLite memory, exposed through MCP with tools for memory context, search, get, put, forget, sleep, and status.-
- AlicenseNot gradedqualityDmaintenanceKeeps a structured log of every Claude Code session and provides it as context at the start of the next session, using local SQLite.61 PyPI2MIT