get_entry_by_date
Retrieve a journal entry for a specific date using the defined YYYY-MM-DD format, enabling quick access to precise entries in the Journal MCP Server.
Instructions
Get journal entry for a specific date
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Date in YYYY-MM-DD format |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"date": {
"description": "Date in YYYY-MM-DD format",
"type": "string"
}
},
"required": [
"date"
],
"type": "object"
}
Implementation Reference
- src/mcp-server.ts:184-228 (registration)Registration of the MCP tool 'get_entry_by_date'. Includes tool name, description, Zod input schema for 'date' parameter, and the inline asynchronous handler function that fetches the journal entry using getEntryByDate helper and formats the response as MCP CallToolResult.this.server.tool( 'get_entry_by_date', 'Get journal entry for a specific date', { date: z.string().describe('Date in YYYY-MM-DD format'), }, async ({ date }) => { const entry = await getEntryByDate(date); if (!entry) { return { content: [ { type: 'text', text: `π No journal entry found for ${date}`, }, ], } satisfies CallToolResult; } let response = `π Journal Entry for ${entry.date}\n\n`; response += `**Tags:** ${entry.tags.join(', ') || 'None'}\n`; response += `**Entries:** ${entry.entries_count}\n`; response += `**Created:** ${new Date( entry.created ).toLocaleString()}\n`; response += `**Updated:** ${new Date( entry.updated ).toLocaleString()}\n\n`; for (const entryItem of entry.entries) { response += `## ${entryItem.timestamp} - ${entryItem.title}\n`; response += `${entryItem.content}\n\n`; } return { content: [ { type: 'text', text: response, }, ], } satisfies CallToolResult; } );
- src/mcp-server.ts:187-189 (schema)Zod schema defining the input parameters for the tool: a required 'date' string in YYYY-MM-DD format.{ date: z.string().describe('Date in YYYY-MM-DD format'), },
- src/journal/manager.ts:373-386 (handler)Core handler logic implementation: Retrieves the journal file path for the given date, reads the file content if it exists, and parses it into a JournalFile object using parseJournalFile, returning null if not found or parsing fails.export async function getEntryByDate( date: string ): Promise<JournalFile | null> { const filePath = getDateFilePath(date); const content = await readFileIfExists(filePath); if (!content) return null; try { return await parseJournalFile(filePath, content); } catch { return null; } }
- src/journal/manager.ts:149-169 (helper)Supporting helper function parseJournalFile that parses the raw markdown content using gray-matter, extracts frontmatter, parses individual entries, and constructs the JournalFile structure.async function parseJournalFile( filePath: string, content: string ): Promise<JournalFile> { const { data: frontmatter, content: body } = matter(content); const date = parseDateFromPath(filePath) || frontmatter.title || ''; // Parse entries from markdown content const entries = parseEntriesFromMarkdown(body, date); return { title: frontmatter.title || date, tags: frontmatter.tags || [], created: frontmatter.created || now().toISOString(), updated: frontmatter.updated || now().toISOString(), entries_count: frontmatter.entries_count || entries.length, entries, filePath, date, }; }