Skip to main content
Glama

create_vault

Set up a new vault by specifying a unique ID, name, and directory path. Optionally initialize with default note types and switch to it immediately for organized note management.

Instructions

Create a new vault and add it to the vault registry

Input Schema

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

Input Schema (JSON Schema)

{ "properties": { "description": { "description": "Optional description of the vault purpose", "type": "string" }, "id": { "description": "Unique identifier for the vault (filesystem-safe)", "type": "string" }, "initialize": { "default": true, "description": "Whether to initialize with default note types", "type": "boolean" }, "name": { "description": "Human-readable name for the vault", "type": "string" }, "path": { "description": "Directory path where the vault should be created", "type": "string" }, "switch_to": { "default": true, "description": "Whether to switch to the new vault after creation", "type": "boolean" } }, "required": [ "id", "name", "path" ], "type": "object" }

Implementation Reference

  • The primary handler function for the create_vault MCP tool. Validates input, resolves path, creates vault directory, registers with GlobalConfigManager, optionally initializes the vault workspace with default note types, and switches to the new vault.
    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 }; } };
  • MCP tool registration in the CallToolRequestSchema handler's switch statement, mapping 'create_vault' tool calls to vaultHandlers.handleCreateVault method.
    return await this.vaultHandlers.handleCreateVault( args as unknown as CreateVaultArgs ); case 'switch_vault':
  • JSON schema definition for the create_vault tool input parameters, exported in TOOL_SCHEMAS array.
    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 defining the CreateVaultArgs type used by the 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