Skip to main content
Glama
disnet
by disnet

create_vault

Create a new vault in Flint Note to organize markdown notes for AI collaboration by specifying a unique ID, name, and directory path.

Instructions

Create a new vault and add it to the vault registry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUnique identifier for the vault (filesystem-safe)
nameYesHuman-readable name for the vault
pathYesDirectory path where the vault should be created
descriptionNoOptional description of the vault purpose
initializeNoWhether to initialize with default note types
switch_toNoWhether to switch to the new vault after creation

Implementation Reference

  • The core handler function that executes the create_vault tool. Validates input, creates directory, registers vault, optionally initializes with default note types and switches to it.
    handleCreateVault = async (
      args: CreateVaultArgs
    ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> => {
      try {
        // Validate arguments
        validateToolArgs('create_vault', args);
        // Validate vault ID
        if (!this.globalConfig.isValidVaultId(args.id)) {
          throw new Error(
            `Invalid vault ID '${args.id}'. Must contain only letters, numbers, hyphens, and underscores.`
          );
        }
    
        // Check if vault already exists
        if (this.globalConfig.hasVault(args.id)) {
          throw new Error(`Vault with ID '${args.id}' already exists`);
        }
    
        // Resolve path with tilde expansion
        const resolvedPath = resolvePath(args.path);
    
        // Validate path safety
        if (!isPathSafe(args.path)) {
          throw new Error(`Invalid or unsafe path: ${args.path}`);
        }
    
        // Ensure directory exists
        await fs.mkdir(resolvedPath, { recursive: true });
    
        // Add vault to registry
        await this.globalConfig.addVault(
          args.id,
          args.name,
          resolvedPath,
          args.description
        );
    
        let initMessage = '';
        if (args.initialize !== false) {
          // Initialize the vault with default note types
          const tempHybridSearchManager = new HybridSearchManager(resolvedPath);
          const workspace = new Workspace(
            resolvedPath,
            tempHybridSearchManager.getDatabaseManager()
          );
          await workspace.initializeVault();
          initMessage =
            '\n\n✅ Vault initialized with default note types (daily, reading, todos, projects, goals, games, movies)';
        }
    
        let switchMessage = '';
        if (args.switch_to !== false) {
          // Switch to the new vault
          await this.globalConfig.switchVault(args.id);
    
          // Reinitialize server with new vault
          await this.initializeServer();
    
          switchMessage = '\n\n🔄 Switched to new vault';
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ Created vault '${args.name}' (${args.id}) at: ${resolvedPath}${initMessage}${switchMessage}`
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return {
          content: [
            {
              type: 'text',
              text: `Failed to create vault: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
  • Registers the vault-handlers.handleCreateVault method as the handler for the 'create_vault' tool call in the MCP server.
        args as unknown as CreateVaultArgs
      );
    case 'switch_vault':
      return await this.vaultHandlers.handleSwitchVault(
  • JSON Schema defining the input parameters for the create_vault tool.
    {
      name: 'create_vault',
      description: 'Create a new vault with specified configuration',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description:
              'Unique identifier for the vault (letters, numbers, hyphens, underscores only)'
          },
          name: {
            type: 'string',
            description: 'Human-readable name for the vault'
          },
          path: {
            type: 'string',
            description: 'File system path where the vault will be stored'
          },
          description: {
            type: 'string',
            description: 'Optional description of the vault purpose'
          },
          initialize: {
            type: 'boolean',
            description: 'Whether to initialize the vault with default note types',
            default: true
          },
          switch_to: {
            type: 'boolean',
            description: 'Whether to switch to this vault after creation',
            default: true
          }
        },
        required: ['id', 'name', 'path']
      }
    },
  • TypeScript interface for CreateVaultArgs used in handler and registration.
    export interface CreateVaultArgs {
      id: string;
      name: string;
      path: string;
      description?: string;
      initialize?: boolean;
      switch_to?: boolean;
    }

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