Skip to main content
Glama

create_diary_template

Generate a personalized diary template with reflection prompts based on your recent journal entries to maintain consistent daily writing habits.

Instructions

Create a new diary entry template with reflection prompts based on recent entries.

Args: date: Date for the entry in YYYY-MM-DD format. If not provided, uses today's date.

Returns: A formatted diary template with reflection prompts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNo

Implementation Reference

  • Handler function for 'create_diary_template' tool. Registered via @mcp.tool() decorator. Validates input, checks for existing entry, generates template via template_generator.
    @mcp.tool( annotations={ "title": "Preview Memory Log Template", "readOnlyHint": True, "openWorldHint": False } ) async def create_diary_template( date: Annotated[str, "REQUIRED: Current date in YYYY-MM-DD format. For 'today', pass the current system date like '2025-10-07'"], focus: Annotated[str | None, "Optional focus area (e.g., 'current struggles', 'cognitive patterns')"] = None ) -> str: """Create a sophisticated diary template with intellectually rigorous prompts for deep cognitive exploration.""" try: entry_date = datetime.strptime(date, "%Y-%m-%d") except ValueError: return "Error: Date must be in YYYY-MM-DD format" if entry_manager.entry_exists(entry_date): return f"Memory log for {date} already exists. Use read_diary_entry to view it." return await template_generator.generate_template_content(entry_date, date, focus)
  • Core logic for generating diary template content. Analyzes recent entries, generates AI reflection prompts via analysis_engine, builds template structure. Called by the tool handler.
    async def generate_template_content( self, entry_date: datetime, filename: str, focus: Optional[str] = None ) -> str: """Generate template content for a diary entry.""" from datetime import timedelta log_section(logger, f"Template Generation: {filename}") logger.info(f"Entry date: {entry_date.strftime('%A, %B %d, %Y')}") is_sunday = entry_date.weekday() == 6 if is_sunday: week_start = entry_date - timedelta(days=7) all_entries = entry_manager.get_all_entries() recent_entries = [(date, path) for date, path in all_entries if week_start <= date < entry_date] logger.info(f"Sunday reflection: Analyzing {len(recent_entries)} entries from {week_start.strftime('%Y-%m-%d')} to {(entry_date - timedelta(days=1)).strftime('%Y-%m-%d')}") else: three_days_ago = entry_date - timedelta(days=3) all_entries = entry_manager.get_all_entries() recent_entries = [(date, path) for date, path in all_entries if three_days_ago <= date < entry_date] logger.info(f"Regular day: Analyzing {len(recent_entries)} entries from past 3 calendar days ({three_days_ago.strftime('%Y-%m-%d')} to {(entry_date - timedelta(days=1)).strftime('%Y-%m-%d')})") recent_text = "\n\n".join( f"## {'MOST RECENT ENTRY' if i == 0 else 'Earlier entry'} ({date.strftime('%Y-%m-%d')}):\n{entry_manager.read_entry(path)}" for i, (date, path) in enumerate(recent_entries) ) logger.info(f"Context: {len(recent_text):,} chars from {len(recent_entries)} entries (weighted by recency)") prompt_count = 5 if is_sunday else 3 logger.info(f"Requesting {prompt_count} AI-generated prompts{' with focus: ' + focus if focus else ''}") prompts = await analysis_engine.generate_reflection_prompts( recent_text, focus, prompt_count, is_sunday ) if not prompts: logger.warning("No AI prompts generated, using fallback prompts") prompts = self._get_fallback_prompts(is_sunday) else: logger.info(f"✓ Generated {len(prompts)} AI prompts successfully") return self._build_template(prompts, is_sunday)
  • @mcp.tool() decorator registers the create_diary_template function as an MCP tool with metadata annotations.
    @mcp.tool( annotations={ "title": "Preview Memory Log Template", "readOnlyHint": True, "openWorldHint": False } )
  • Function signature with Annotated types defining input schema and descriptions for the tool.
    async def create_diary_template( date: Annotated[str, "REQUIRED: Current date in YYYY-MM-DD format. For 'today', pass the current system date like '2025-10-07'"], focus: Annotated[str | None, "Optional focus area (e.g., 'current struggles', 'cognitive patterns')"] = None ) -> str:

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/madebygps/obsidian-diary-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server