create_note
Generate and save new notes directly into an Obsidian vault by specifying the file path and content. Simplifies creating structured notes within your knowledge base.
Instructions
Create a new note in the Obsidian vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Content of the note | |
| path | Yes | Path where the note should be created |
Implementation Reference
- src/index.ts:1145-1163 (registration)Registration of the 'create_note' tool in the list of available tools returned by ListToolsRequestSchema, including name, description, and input schema.{ name: 'create_note', description: 'Create a new note in the Obsidian vault', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path where the note should be created', }, content: { type: 'string', description: 'Content of the note', }, }, required: ['path', 'content'], }, }, {
- src/index.ts:1459-1474 (handler)The handler function for the 'create_note' tool call, which validates input arguments, invokes the createNote method, and returns a success response.private async handleCreateNote(args: any) { if (!args?.path || !args?.content) { throw new Error('Path and content are required'); } await this.createNote(args.path, args.content); return { content: [ { type: 'text', text: `Note created successfully at ${args.path}`, }, ], }; }
- src/index.ts:2221-2238 (handler)Core implementation of note creation: attempts to use Obsidian Local REST API POST, with fallback to direct filesystem write including directory creation.private async createNote(notePath: string, content: string): Promise<void> { try { // First try using the Obsidian API await this.api.post(`/vault/${encodeURIComponent(notePath)}`, { content }); } catch (error) { console.warn('API request failed, falling back to file system:', error); // Fallback to file system if API fails const fullPath = path.join(VAULT_PATH, notePath); const dir = path.dirname(fullPath); if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } fs.writeFileSync(fullPath, content, 'utf-8'); } }
- src/index.ts:1393-1394 (registration)Routing case in the CallToolRequestSchema handler switch statement that dispatches 'create_note' tool calls to the handleCreateNote method.return await this.handleCreateNote(request.params.arguments); case 'search_vault':