rename_note
Update a note's display title while preserving file links and automatically adjusting references in connected notes.
Instructions
Rename a note by updating its title field (display name). The filename and ID remain unchanged to preserve links. Automatically updates wikilinks in other notes that reference the old title.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes | Note identifier in format "type/filename" or full path | |
| new_title | Yes | New display title for the note | |
| content_hash | Yes | Content hash of the current note for optimistic locking | |
| vault_id | No | Optional vault ID to operate on. If not provided, uses the current active vault. |
Implementation Reference
- src/server/note-handlers.ts:454-558 (handler)Primary handler function for the 'rename_note' MCP tool. Validates input, updates note title metadata via noteManager while preserving content, bypasses protections, and automatically updates wikilinks and broken links across the vault.
handleRenameNote = async (args: RenameNoteArgs) => { try { // Validate arguments validateToolArgs('rename_note', args); const { noteManager, hybridSearchManager } = await this.resolveVaultContext( args.vault_id ); // Get the current note to read current metadata const currentNote = await noteManager.getNote(args.identifier); if (!currentNote) { throw new Error(`Note '${args.identifier}' not found`); } // Update the title in metadata while preserving all other metadata const updatedMetadata = { ...currentNote.metadata, title: args.new_title }; // Use the existing updateNoteWithMetadata method with protection bypass for rename const result = await noteManager.updateNoteWithMetadata( args.identifier, currentNote.content, // Keep content unchanged updatedMetadata, args.content_hash, true // Bypass protection for legitimate rename operations ); let brokenLinksUpdated = 0; let wikilinksResult = { notesUpdated: 0, linksUpdated: 0 }; // Update links using the vault-specific hybrid search manager const db = await hybridSearchManager.getDatabaseConnection(); const noteId = this.generateNoteIdFromIdentifier(args.identifier); // Update broken links that might now be resolved due to the new title brokenLinksUpdated = await LinkExtractor.updateBrokenLinks( noteId, args.new_title, db ); // Always update wikilinks in other notes wikilinksResult = await LinkExtractor.updateWikilinksForRenamedNote( noteId, currentNote.title, args.new_title, db ); let wikilinkMessage = ''; if (brokenLinksUpdated > 0) { wikilinkMessage = `\n\nš Updated ${brokenLinksUpdated} broken links that now resolve to this note.`; } if (wikilinksResult.notesUpdated > 0) { wikilinkMessage += `\nš Updated ${wikilinksResult.linksUpdated} wikilinks in ${wikilinksResult.notesUpdated} notes that referenced the old title.`; } return { content: [ { type: 'text', text: JSON.stringify( { success: true, message: `Note renamed successfully${wikilinkMessage}`, old_title: currentNote.title, new_title: args.new_title, identifier: args.identifier, filename_unchanged: true, links_preserved: true, broken_links_resolved: brokenLinksUpdated, wikilinks_updated: true, notes_with_updated_wikilinks: wikilinksResult.notesUpdated, total_wikilinks_updated: wikilinksResult.linksUpdated, result }, null, 2 ) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: JSON.stringify( { success: false, error: errorMessage }, null, 2 ) } ], isError: true }; } }; - src/server.ts:1317-1320 (registration)Tool dispatch registration in the main MCP server CallToolRequestHandler switch statement, routing 'rename_note' calls to NoteHandlers.handleRenameNote method.
case 'rename_note': return await this.noteHandlers.handleRenameNote( args as unknown as RenameNoteArgs ); - src/server.ts:1114-1139 (schema)Tool schema definition provided in the ListToolsRequestHandler response for the 'rename_note' tool, including description and input schema.
name: 'rename_note', description: 'Rename a note by updating its title field (display name). The filename and ID remain unchanged to preserve links. Automatically updates wikilinks in other notes that reference the old title.', inputSchema: { type: 'object', properties: { identifier: { type: 'string', description: 'Note identifier in format "type/filename" or full path' }, new_title: { type: 'string', description: 'New display title for the note' }, content_hash: { type: 'string', description: 'Content hash of the current note for optimistic locking' }, vault_id: { type: 'string', description: 'Optional vault ID to operate on. If not provided, uses the current active vault.' } }, required: ['identifier', 'new_title', 'content_hash'] } - src/server/types.ts:188-193 (schema)TypeScript interface defining the input arguments for the rename_note tool handler.
export interface RenameNoteArgs { identifier: string; new_title: string; content_hash: string; vault_id?: string; } - src/server/tool-schemas.ts:816-841 (schema)Standalone tool schema configuration for 'rename_note' in TOOL_SCHEMAS array (potentially used for documentation or external reference).
name: 'rename_note', description: 'Rename a note and update any wikilinks that reference it', inputSchema: { type: 'object', properties: { identifier: { type: 'string', description: 'Current note identifier in type/filename format' }, new_title: { type: 'string', description: 'New title for the note' }, content_hash: { type: 'string', description: 'Content hash for optimistic locking to prevent conflicts' }, vault_id: { type: 'string', description: 'Optional vault ID to operate on. If not provided, uses the current active vault.' } }, required: ['identifier', 'new_title', 'content_hash'] } },