Skip to main content
Glama
bazylhorsey
by bazylhorsey

create_daily_note

Create a daily note for a specific date in your Obsidian vault, with optional template variables and automatic default to today's date.

Instructions

Create a daily note for a specific date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate (YYYY-MM-DD), defaults to today
variablesNoAdditional template variables
vaultYesVault name

Implementation Reference

  • src/index.ts:394-406 (registration)
    Registers the 'create_daily_note' tool with the MCP ListTools handler, including its description and input schema.
    {
      name: 'create_daily_note',
      description: 'Create a daily note for a specific date',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
          date: { type: 'string', description: 'Date (YYYY-MM-DD), defaults to today' },
          variables: { type: 'object', description: 'Additional template variables' },
        },
        required: ['vault'],
      },
    },
  • MCP tool handler for 'create_daily_note': retrieves vault connector, parses date, calls PeriodicNotesService.createPeriodicNote('daily'), and returns JSON result.
    case 'create_daily_note': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector || !connector.vaultPath) {
        throw new Error(`Vault "${args?.vault}" not found or not a local vault`);
      }
    
      const date = args?.date ? new Date(args.date as string) : undefined;
      const result = await this.periodicNotesService.createPeriodicNote(
        connector.vaultPath,
        'daily',
        date,
        args?.variables as Record<string, any> | undefined
      );
    
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Core implementation of periodic note creation (used for daily notes when type='daily'): generates filename/path, checks existence, renders template or default content, creates directories, writes file.
    async createPeriodicNote(
      vaultPath: string,
      type: PeriodicNoteType,
      date?: Date,
      variables?: Record<string, any>
    ): Promise<VaultOperationResult<string>> {
      try {
        const noteDate = date || new Date();
        const config = this.settings[type];
    
        if (!config.enabled) {
          return { success: false, error: `${type} notes are not enabled` };
        }
    
        // Generate note path
        const notePath = this.getPeriodicNotePath(type, noteDate);
        const fullPath = path.join(vaultPath, notePath);
    
        // Check if note already exists
        try {
          await fs.access(fullPath);
          return { success: true, data: notePath }; // Already exists
        } catch {
          // Note doesn't exist, continue to create
        }
    
        // Ensure directory exists
        await fs.mkdir(path.dirname(fullPath), { recursive: true });
    
        let content: string;
    
        // Use template if specified
        if (config.templatePath) {
          const renderResult = await this.templateService.renderTemplate(
            vaultPath,
            config.templatePath,
            {
              targetPath: notePath,
              variables: {
                ...this.getPeriodicNoteVariables(type, noteDate),
                ...variables,
              },
            }
          );
    
          if (!renderResult.success || !renderResult.data) {
            return { success: false, error: renderResult.error };
          }
    
          content = renderResult.data.content;
        } else {
          // Generate default content
          content = this.generateDefaultContent(type, noteDate);
        }
    
        // Write file
        await fs.writeFile(fullPath, content, 'utf-8');
    
        return { success: true, data: notePath };
      } catch (error) {
        return {
          success: false,
          error: `Failed to create ${type} note: ${error instanceof Error ? error.message : String(error)}`
        };
      }
  • Default configuration settings for daily notes, used by PeriodicNotesService (folder, format).
    daily: {
      enabled: true,
      folder: 'Daily Notes',
      format: 'YYYY-MM-DD',
    },

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/bazylhorsey/obsidian-mcp-server'

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