Skip to main content
Glama
coji

Journal MCP Server

by coji

add_entry

Create or append to a daily journal entry, organizing thoughts with optional tags for easy retrieval.

Instructions

Add a new journal entry. If an entry for today already exists, it will append to the same file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content of the journal entry
tagsNoOptional tags for the entry (will also extract from content)

Implementation Reference

  • Core implementation of addEntry function: creates journal entry, handles file locking, parsing existing content, appending or creating new daily file, extracting title/tags, and writing back with frontmatter.
    export async function addEntry(
      options: AddEntryOptions
    ): Promise<JournalEntry> {
      const t = now();
      const date = t.format('YYYY-MM-DD');
      const timestamp = t.format();
      const filePath = getDateFilePath(date);
    
      // Acquire file lock
      await acquireLock(filePath);
    
      let backupPath: string | null = null;
    
      try {
        // Create entry
        const entry: JournalEntry = {
          id: `${date}-${timestamp}`,
          title: extractTitle(options.content),
          content: options.content,
          tags: options.tags || extractTags(options.content),
          created: timestamp,
          updated: timestamp,
          timestamp: t.format('HH:mm'), // HH:MM format
        };
    
        // Read existing file or create new one
        const existingContent = await readFileIfExists(filePath);
        let journalFile: JournalFile;
    
        if (existingContent) {
          // Backup existing file
          backupPath = await backupFile(filePath);
    
          // Parse existing file
          journalFile = await parseJournalFile(filePath, existingContent);
    
          // Add new entry
          journalFile.entries.push(entry);
          journalFile.updated = timestamp;
          journalFile.entries_count = journalFile.entries.length;
    
          // Merge tags
          const allTags = new Set([...journalFile.tags, ...entry.tags]);
          journalFile.tags = Array.from(allTags).sort();
        } else {
          // Create new file
          journalFile = {
            title: date,
            tags: entry.tags,
            created: timestamp,
            updated: timestamp,
            entries_count: 1,
            entries: [entry],
            filePath,
            date,
          };
        }
    
        // Write file
        const content = formatJournalFile(journalFile);
        await writeFileWithDir(filePath, content);
    
        // Clean up backup file after successful write
        if (backupPath) {
          await deleteFile(backupPath);
        }
    
        return entry;
      } catch (error) {
        // If write failed and we have a backup, we can keep it for recovery
        // Log the backup path for manual recovery if needed
        if (backupPath) {
          console.error(`Write failed, backup file preserved at: ${backupPath}`);
        }
        throw error;
      } finally {
        releaseLock(filePath);
      }
    }
  • Registers the 'add_entry' MCP tool with Zod input schema (content, optional tags) and a handler that calls the addEntry function from manager.ts, returning formatted success response.
    this.server.tool(
      'add_entry',
      'Add a new journal entry. If an entry for today already exists, it will append to the same file.',
      {
        content: z.string().describe('The content of the journal entry'),
        tags: z
          .array(z.string())
          .optional()
          .describe(
            'Optional tags for the entry (will also extract from content)'
          ),
      },
      async (args) => {
        const entry = await addEntry(args);
        return {
          content: [
            {
              type: 'text',
              text: `✅ Journal entry added successfully!\n\n**Entry Details:**\n- ID: ${
                entry.id
              }\n- Title: ${entry.title}\n- Tags: ${
                entry.tags.join(', ') || 'None'
              }\n- Time: ${entry.timestamp}\n\n**Content:**\n${entry.content}`,
            },
          ],
        };
      }
    );
  • TypeScript interface defining the input options for addEntry: required content string and optional tags array. Matches the Zod schema used in registration.
    export interface AddEntryOptions {
      content: string;
      tags?: string[];
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the key behavior of appending to existing entries for today, which is valuable context beyond basic 'add' functionality. However, it lacks details on permissions, error handling, or file storage specifics, leaving gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences that are front-loaded with the core purpose and include essential behavioral context (appending rule). Every word earns its place with no redundancy or fluff, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description provides adequate purpose and key behavior (appending). However, it lacks details on return values, error cases, or system constraints, which would be needed for full completeness given the complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents the two parameters (content and tags). The description does not add any parameter-specific details beyond what the schema provides, such as format examples or usage tips, resulting in the baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Add a new journal entry') and the resource ('journal entry'), distinguishing it from sibling tools like get_entry_by_date (retrieval) or search_entries (search). It also specifies the unique behavior of appending to existing entries for today, which further differentiates its purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: for adding new journal entries, with the specific rule that if an entry for today exists, it appends instead of creating a new one. However, it does not explicitly state when not to use it or name alternatives (e.g., using get_entry_by_date to check first), which prevents a score of 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/coji/journal-mcp'

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