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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique identifier for the vault (filesystem-safe) | |
| name | Yes | Human-readable name for the vault | |
| path | Yes | Directory path where the vault should be created | |
| description | No | Optional description of the vault purpose | |
| initialize | No | Whether to initialize with default note types | |
| switch_to | No | Whether to switch to the new vault after creation |
Implementation Reference
- src/server/vault-handlers.ts:78-158 (handler)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 }; }
- src/server.ts:1279-1282 (registration)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(
- src/server/tool-schemas.ts:564-600 (schema)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'] } },
- src/server/types.ts:131-138 (schema)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; }