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