Skip to main content
Glama
bazylhorsey
by bazylhorsey

create_note

Create new notes in your Obsidian vault by specifying the vault name, file path, and content. Add frontmatter metadata to organize and structure your knowledge base effectively.

Instructions

Create a new note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesNote content
frontmatterNoFrontmatter metadata
pathYesPath for the new note
vaultYesVault name

Implementation Reference

  • Top-level handler for the 'create_note' tool that retrieves the vault connector and delegates to its createNote method, returning the result as JSON.
    case 'create_note': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector) {
        throw new Error(`Vault "${args?.vault}" not found`);
      }
      const result = await connector.createNote(args?.path as string, args?.content as string, args?.frontmatter as Record<string, any> | undefined);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Input schema definition and description for the 'create_note' tool, used in ListTools response.
    {
      name: 'create_note',
      description: 'Create a new note',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
          path: { type: 'string', description: 'Path for the new note' },
          content: { type: 'string', description: 'Note content' },
          frontmatter: { type: 'object', description: 'Frontmatter metadata' },
        },
        required: ['vault', 'path', 'content'],
      },
    },
  • Implementation of createNote for local vaults: creates directories, serializes note with frontmatter, writes to filesystem, and returns parsed note.
    async createNote(notePath: string, content: string, frontmatter?: Record<string, any>): Promise<VaultOperationResult<Note>> {
      try {
        const fullPath = path.join(this.config.path!, notePath);
    
        // Ensure directory exists
        await fs.mkdir(path.dirname(fullPath), { recursive: true });
    
        const note: Note = {
          path: notePath,
          title: frontmatter?.title || notePath.split('/').pop()?.replace('.md', '') || 'Untitled',
          content,
          frontmatter
        };
    
        const serialized = serializeNote(note);
        await fs.writeFile(fullPath, serialized, 'utf-8');
    
        // Parse the note to get full structure
        const result = await this.getNote(notePath);
    
        return result;
      } catch (error) {
        return {
          success: false,
          error: `Failed to create note: ${error instanceof Error ? error.message : String(error)}`
        };
      }
  • Implementation of createNote for remote vaults: serializes note and sends HTTP POST to remote vault endpoint, then fetches the created note.
    async createNote(path: string, content: string, frontmatter?: Record<string, any>): Promise<VaultOperationResult<Note>> {
      try {
        const note: Note = {
          path,
          title: frontmatter?.title || path.split('/').pop()?.replace('.md', '') || 'Untitled',
          content,
          frontmatter
        };
    
        const serialized = serializeNote(note);
    
        await this.client.post(`/vault/${encodeURIComponent(path)}`, {
          content: serialized
        });
    
        const result = await this.getNote(path);
        return result;
      } catch (error) {
        return {
          success: false,
          error: `Failed to create note: ${error instanceof Error ? error.message : String(error)}`
        };
      }

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