import { BaseTool } from './base.tool.js';
export class WriteNoteTool extends BaseTool {
readonly name = 'write_note';
readonly description = 'Create a new note or update an existing note in the Obsidian vault';
readonly inputSchema = {
type: 'object' as const,
properties: {
path: {
type: 'string',
description: 'Path where the note should be created/updated (e.g., "daily/2025-01-15.md")',
},
content: {
type: 'string',
description: 'The markdown content of the note',
},
frontmatter: {
type: 'object',
description: 'Optional YAML frontmatter metadata (tags, title, date, etc.)',
additionalProperties: true,
},
},
required: ['path', 'content'],
};
async execute(params: { path: string; content: string; frontmatter?: Record<string, any> }) {
try {
await this.vault.write(params.path, params.content, params.frontmatter);
return {
success: true,
message: `Note ${params.path} written successfully`,
path: params.path,
};
} catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : 'Failed to write note',
};
}
}
}