Skip to main content
Glama
quinny1187

Obsidian MCP Server

by quinny1187

write_note

Create or update notes in Obsidian vaults with options to overwrite, append, or prepend content for organized knowledge management.

Instructions

Create or update a note in the vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vault_pathYesPath to the Obsidian vault
note_pathYesPath to the note relative to vault root
contentYesContent of the note
modeNoHow to handle existing contentoverwrite

Implementation Reference

  • The core handler function for the 'write_note' tool. It validates the vault, ensures the directory exists, handles different write modes (overwrite, append, prepend with frontmatter awareness), writes the file, and returns success status.
    export async function handleWriteNote(
      vaultManager: VaultManager,
      vaultPath: string,
      notePath: string,
      content: string,
      mode: 'overwrite' | 'append' | 'prepend' = 'overwrite'
    ) {
      await vaultManager.validateVault(vaultPath);
      
      const filePath = vaultManager.getFilePath(vaultPath, notePath);
      
      // Ensure directory exists
      const dir = path.dirname(filePath);
      await fs.mkdir(dir, { recursive: true });
      
      let finalContent = content;
      
      if (mode !== 'overwrite') {
        try {
          const existing = await fs.readFile(filePath, 'utf-8');
          
          if (mode === 'append') {
            finalContent = existing + '\n' + content;
          } else if (mode === 'prepend') {
            // If the existing content has frontmatter, insert after it
            const parsed = matter(existing);
            if (Object.keys(parsed.data).length > 0) {
              finalContent = parsed.matter + '\n' + content + '\n' + parsed.content;
            } else {
              finalContent = content + '\n' + existing;
            }
          }
        } catch (error: any) {
          // File doesn't exist, just write the content
          if (error.code !== 'ENOENT') {
            throw error;
          }
        }
      }
      
      await fs.writeFile(filePath, finalContent, 'utf-8');
      
      return {
        path: notePath,
        success: true,
        mode,
      };
    }
  • The tool schema definition including name, description, and input schema for validation in the TOOLS array used for listing tools.
    {
      name: 'write_note',
      description: 'Create or update a note in the vault',
      inputSchema: {
        type: 'object',
        properties: {
          vault_path: {
            type: 'string',
            description: 'Path to the Obsidian vault',
          },
          note_path: {
            type: 'string',
            description: 'Path to the note relative to vault root',
          },
          content: {
            type: 'string',
            description: 'Content of the note',
          },
          mode: {
            type: 'string',
            enum: ['overwrite', 'append', 'prepend'],
            description: 'How to handle existing content',
            default: 'overwrite',
          },
        },
        required: ['vault_path', 'note_path', 'content'],
      },
    },
  • src/index.ts:190-201 (registration)
    Registration in the switch statement that dispatches calls to the handleWriteNote handler with parameter validation.
    case 'write_note':
      if (!args || typeof args !== 'object' || !('vault_path' in args) || !('note_path' in args) || !('content' in args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters');
      }
      result = await handleWriteNote(
        vaultManager,
        args.vault_path as string,
        args.note_path as string,
        args.content as string,
        (args.mode as 'overwrite' | 'append' | 'prepend') || 'overwrite'
      );
      break;
  • src/index.ts:14-14 (registration)
    Import statement registering the handleWriteNote function from the notes module.
    import { handleReadNote, handleWriteNote, handleListNotes } from './tools/notes.js';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'create or update' implies mutation, it lacks details on permissions, error handling (e.g., if vault_path is invalid), or side effects (e.g., overwriting existing notes). This is inadequate for a mutation tool with zero annotation coverage.

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 a single, efficient sentence with no wasted words, front-loading the core action ('create or update a note'). It's appropriately sized for the tool's complexity, earning full marks for conciseness.

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

Completeness2/5

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

Given the tool's mutation nature, lack of annotations, and absence of an output schema, the description is incomplete. It doesn't cover behavioral aspects like success/error responses or operational constraints, leaving gaps that could hinder an AI agent's effective use.

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 fully documents all parameters. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't clarify 'vault_path' format or 'content' expectations), resulting in the baseline score for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb ('create or update') and resource ('a note in the vault'), making the purpose understandable. However, it doesn't explicitly distinguish this tool from sibling tools like 'read_note' or 'list_notes' beyond the obvious action difference, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., vault must exist), exclusions, or compare it to siblings like 'read_note' for retrieval or 'list_notes' for browsing, leaving usage context unclear.

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

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