Skip to main content
Glama

journal_append

Append timestamped entries to a daily journal markdown file. Creates the file automatically on first use and serializes concurrent writes to prevent data loss.

Instructions

Append a timestamped entry to today's (or date's) journal markdown at knowledge/journal/YYYY-MM-DD.md. Creates the file on first use of a date with a # Journal — DATE header; subsequent calls APPEND a new ## HH:MM:SS section without rewriting prior entries. Concurrent calls for the same date are serialised by an internal lock so entries are not lost. SIDE EFFECTS: writes the file (FTS reindex + git commit via the same path as update_file/create_file); on first use, creates with default tag ['journal'] (overridable). date must match YYYY-MM-DD or throws. No external auth or rate limits. Returns {file_id, path, date, time, appended_chars, est_tokens}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesEntry text (markdown allowed)
dateNoOverride the journal date as YYYY-MM-DD (default: today, local time)
tagsNoTags to apply to the journal file (default: ['journal'])

Implementation Reference

  • The complete handler function for the journal_append MCP tool. Takes text (required), optional date (YYYY-MM-DD), and optional tags. Creates or appends to knowledge/journal/YYYY-MM-DD.md with timestamped entries, using withLock for concurrency safety.
    server.tool(
      "journal_append",
      "Append a timestamped entry to today's (or `date`'s) journal markdown at `knowledge/journal/YYYY-MM-DD.md`. Creates the file on first use of a date with a `# Journal — DATE` header; subsequent calls APPEND a new `## HH:MM:SS` section without rewriting prior entries. Concurrent calls for the same date are serialised by an internal lock so entries are not lost. SIDE EFFECTS: writes the file (FTS reindex + git commit via the same path as `update_file`/`create_file`); on first use, creates with default tag `['journal']` (overridable). `date` must match `YYYY-MM-DD` or throws. No external auth or rate limits. Returns `{file_id, path, date, time, appended_chars, est_tokens}`.",
      {
        text: z.string().min(1).describe("Entry text (markdown allowed)"),
        date: z.string().optional().describe("Override the journal date as YYYY-MM-DD (default: today, local time)"),
        tags: z.array(z.string()).optional().describe("Tags to apply to the journal file (default: ['journal'])"),
      },
      async ({ text, date, tags }) => {
        try {
          const today = (() => {
            const d = new Date();
            const pad = (n: number) => String(n).padStart(2, "0");
            return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
          })();
          const dateStr = date ?? today;
          if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr)) {
            throw new Error(`date must be YYYY-MM-DD, got: ${dateStr}`);
          }
    
          const journalPath = join(dataDir, "knowledge", "journal", `${dateStr}.md`);
          const ts = new Date();
          const pad = (n: number) => String(n).padStart(2, "0");
          const timeStr = `${pad(ts.getHours())}:${pad(ts.getMinutes())}:${pad(ts.getSeconds())}`;
          const entry = `\n\n## ${timeStr}\n\n${text.trimEnd()}\n`;
    
          const result = await withLock(`journal:${journalPath}`, async () => {
            const existing = getDatabase()
              .prepare("SELECT id FROM files WHERE path = ?")
              .get(journalPath) as { id: number } | undefined;
            if (existing) {
              const current = readFile(existing.id);
              const updated = await updateFile(existing.id, current.content + entry, dataDir);
              if (tags && tags.length > 0) addTags(existing.id, tags);
              return updated;
            }
            const initial = `# Journal — ${dateStr}${entry}`;
            return await createFile({
              title: dateStr,
              content: initial,
              destination: "knowledge",
              folder: "journal",
              tags: tags ?? ["journal"],
              dataDir,
            });
          });
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    file_id: result.id,
                    path: result.path,
                    date: dateStr,
                    time: timeStr,
                    appended_chars: entry.length,
                    est_tokens: estimateTokensFromBuffer(Buffer.from(result.content, "utf8")),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (e: any) {
          return {
            isError: true,
            content: [{ type: "text", text: JSON.stringify({ error: e?.message ?? String(e) }, null, 2) }],
          };
        }
      }
    );
  • Zod schema for journal_append: text (string, min 1), date (optional YYYY-MM-DD string), tags (optional array of strings).
    {
      text: z.string().min(1).describe("Entry text (markdown allowed)"),
      date: z.string().optional().describe("Override the journal date as YYYY-MM-DD (default: today, local time)"),
      tags: z.array(z.string()).optional().describe("Tags to apply to the journal file (default: ['journal'])"),
    },
  • Registration of the journal_append tool via server.tool() with its description, input schema, and handler callback.
    server.tool(
      "journal_append",
      "Append a timestamped entry to today's (or `date`'s) journal markdown at `knowledge/journal/YYYY-MM-DD.md`. Creates the file on first use of a date with a `# Journal — DATE` header; subsequent calls APPEND a new `## HH:MM:SS` section without rewriting prior entries. Concurrent calls for the same date are serialised by an internal lock so entries are not lost. SIDE EFFECTS: writes the file (FTS reindex + git commit via the same path as `update_file`/`create_file`); on first use, creates with default tag `['journal']` (overridable). `date` must match `YYYY-MM-DD` or throws. No external auth or rate limits. Returns `{file_id, path, date, time, appended_chars, est_tokens}`.",
  • Database journal mode set to WAL (related but not directly part of journal_append logic).
    globalThis.__ctxnestDb = db;
  • Categorizes journal_append under the 'Write' category for the web UI.
    journal_append: "Write",
Behavior5/5

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

Despite no annotations, the description thoroughly discloses behavioral traits: side effects (file write, FTS reindex, git commit), file creation logic, appending mechanism, serialization for concurrent calls, and error handling for invalid dates. This fully compensates for missing annotations.

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

Conciseness4/5

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

The description is a single dense paragraph that conveys all necessary information without redundancy. While it could be structured into bullet points, it remains clear and efficient, earning a high score.

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

Completeness5/5

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

Given no annotations and no output schema, the description is remarkably complete: it explains the tool's purpose, behavior, side effects, parameter details, error conditions, and return value. Everything needed for correct usage is present.

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

Parameters5/5

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

The input schema has 100% coverage with descriptions for all 3 parameters. The description adds significant context: file path construction, default tags, date format requirements, and error behavior, enriching the semantics beyond the schema.

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 tool appends a timestamped entry to a journal markdown file at a specific path. It specifies the date handling, file creation, and appending behavior, distinguishing it from general file tools like create_file or update_file.

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 explains when to use: for journaling with timestamped entries. It covers date validation and concurrent access serialization. However, it doesn't explicitly mention alternatives or when not to use, though the purpose is sufficiently distinct.

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/safiyu/ctxnest'

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