remove_vault
Remove a vault from the Flint Note registry while preserving the underlying files. Use this tool to unregister vaults without deleting your note data.
Instructions
Remove a vault from the registry (does not delete files)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the vault to remove |
Implementation Reference
- src/server/vault-handlers.ts:203-255 (handler)The handler function that executes the remove_vault tool logic: validates input, checks vault existence, removes from global config, handles current vault reinitialization if necessary, and formats response./** * Removes a vault from the registry (does not delete files) */ handleRemoveVault = async ( args: RemoveVaultArgs ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> => { try { // Validate arguments validateToolArgs('remove_vault', args); const vault = this.globalConfig.getVault(args.id); if (!vault) { throw new Error(`Vault with ID '${args.id}' does not exist`); } const wasCurrentVault = this.globalConfig.getCurrentVault()?.path === vault.path; // Remove vault from registry await this.globalConfig.removeVault(args.id); let switchMessage = ''; if (wasCurrentVault) { // Reinitialize server if we removed the current vault await this.initializeServer(); const newCurrent = this.globalConfig.getCurrentVault(); if (newCurrent) { switchMessage = `\n\nđ Switched to vault: ${newCurrent.name}`; } else { switchMessage = '\n\nâ ď¸ No vaults remaining. You may want to create a new vault.'; } } return { content: [ { type: 'text', text: `â Removed vault '${vault.name}' (${args.id}) from registry.\n\nâ ď¸ Note: Vault files at '${vault.path}' were not deleted.${switchMessage}` } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: `Failed to remove vault: ${errorMessage}` } ], isError: true }; } };
- src/server.ts:1285-1294 (registration)Registration of the remove_vault tool handler in the MCP server's CallToolRequestSchema switch statement.case 'remove_vault': return await this.vaultHandlers.handleRemoveVault( args as unknown as RemoveVaultArgs ); case 'get_current_vault': return await this.vaultHandlers.handleGetCurrentVault(); case 'update_vault': return await this.vaultHandlers.handleUpdateVault( args as unknown as UpdateVaultArgs );
- src/server/tool-schemas.ts:616-628 (schema)The input schema definition for the remove_vault tool.name: 'remove_vault', description: 'Remove a vault from the registry (does not delete files)', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'ID of the vault to remove' } }, required: ['id'] } },
- src/utils/global-config.ts:313-333 (helper)Core helper method that performs the actual vault removal from the global configuration file by deleting the entry and adjusting current_vault if necessary.async removeVault(id: string): Promise<void> { if (!this.#config) { await this.load(); } if (!this.#config!.vaults[id]) { throw new Error(`Vault with ID '${id}' does not exist`); } delete this.#config!.vaults[id]; // Clear current vault if it was the one being removed if (this.#config!.current_vault === id) { // Set to the first available vault, or null if no vaults left const remainingVaults = Object.keys(this.#config!.vaults); this.#config!.current_vault = remainingVaults.length > 0 ? remainingVaults[0] : null; } await this.save(); }
- src/server/types.ts:144-146 (schema)TypeScript interface defining the input arguments for remove_vault.export interface RemoveVaultArgs { id: string; }