create_note
Create new notes in Obsidian vaults by specifying file paths and content for organized knowledge management.
Instructions
Create a new note in the Obsidian vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path where the note should be created | |
| content | Yes | Content of the note |
Implementation Reference
- src/index.ts:2221-2238 (handler)Core handler function that creates a new note by POSTing to the Obsidian Local REST API endpoint or falling back to direct filesystem operations including automatic 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:1459-1474 (handler)MCP tool call handler for 'create_note' that performs input validation and delegates to the createNote implementation.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:1146-1162 (registration)Tool registration in the ListToolsRequestSchema response, 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:1148-1161 (schema)Input schema definition specifying required 'path' and 'content' string parameters for the tool.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'], },