Skip to main content
Glama
disnet
by disnet

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
NameRequiredDescriptionDefault
idYesID of the vault to remove

Implementation Reference

  • 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
        };
      }
    };
  • 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
      );
  • 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']
      }
    },
  • 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();
    }
  • TypeScript interface defining the input arguments for remove_vault.
    export interface RemoveVaultArgs {
      id: string;
    }

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/disnet/flint-note'

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