update_note
Modify existing notes in Obsidian vaults by updating content and metadata to maintain current information and organized knowledge management.
Instructions
Update an existing note
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"vault": "<vault>",
"path": "<path>",
"content": "<content>"
},
"name": "update_note"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | New content | |
| frontmatter | No | Updated frontmatter | |
| path | Yes | Path to the note | |
| vault | Yes | Vault name |
Implementation Reference
- src/index.ts:107-120 (registration)Registration of the 'update_note' tool including name, description, and input schema definition.
{ name: 'update_note', description: 'Update an existing note', inputSchema: { type: 'object', properties: { vault: { type: 'string', description: 'Vault name' }, path: { type: 'string', description: 'Path to the note' }, content: { type: 'string', description: 'New content' }, frontmatter: { type: 'object', description: 'Updated frontmatter' }, }, required: ['vault', 'path', 'content'], }, }, - src/index.ts:521-530 (handler)Primary handler for the 'update_note' tool call, which retrieves the vault connector by name and delegates the update operation to it.
case 'update_note': { const connector = this.connectors.get(args?.vault as string); if (!connector) { throw new Error(`Vault "${args?.vault}" not found`); } const result = await connector.updateNote(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) }], }; } - Implementation of updateNote for local file system vaults: serializes note content with frontmatter and writes to filesystem.
async updateNote(notePath: string, content: string, frontmatter?: Record<string, any>): Promise<VaultOperationResult<Note>> { try { const fullPath = path.join(this.config.path!, notePath); 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 update note: ${error instanceof Error ? error.message : String(error)}` }; } } - Implementation of updateNote for remote vaults: sends PUT request to remote API with serialized note content.
async updateNote(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.put(`/vault/${encodeURIComponent(path)}`, { content: serialized }); // Clear cache and refetch this.notesCache.delete(path); const result = await this.getNote(path); return result; } catch (error) { return { success: false, error: `Failed to update note: ${error instanceof Error ? error.message : String(error)}` }; } } - Abstract method definition in base connector interface that concrete implementations must provide.
* Update an existing note */ abstract updateNote(path: string, content: string, frontmatter?: Record<string, any>): Promise<VaultOperationResult<Note>>;