obsidian_create_note
Create a Markdown note in an Obsidian vault with optional YAML frontmatter, wiki-links, and content; supports custom path and overwrite.
Instructions
Create a new Markdown note with optional frontmatter and related wiki-links.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | No | Optional configured vault name. Defaults to the server default vault. | |
| path | Yes | Vault-relative path. Absolute paths and traversal are rejected. | |
| content | No | ||
| frontmatter | No | YAML frontmatter object. | |
| related | No | ||
| overwrite | No |
Implementation Reference
- src/tools.ts:448-465 (registration)Registration of the obsidian_create_note tool with its schema (vault, path, content, frontmatter, related, overwrite) and the handler function that creates a new Markdown note.
tool( "obsidian_create_note", "Create a new Markdown note with optional frontmatter and related wiki-links.", { vault: vaultArg, path: pathArg, content: z.string().default(""), frontmatter: frontmatterArg, related: z.array(z.string()).optional().default([]), overwrite: z.boolean().optional().default(false), }, async (args) => { const body = withRelated(args.content, args.related); const text = args.frontmatter ? stringifyFrontmatter(args.frontmatter, body) : body; return vaults.writeText(vaults.notePath(args.path), text, args.vault, { overwrite: args.overwrite }); }, { destructiveHint: false, idempotentHint: false }, ); - src/tools.ts:451-458 (schema)Zod schema for obsidian_create_note defining input parameters: vault (optional), path (required), content (default empty string), frontmatter (optional record), related (optional array of wiki-link targets), and overwrite (optional boolean).
{ vault: vaultArg, path: pathArg, content: z.string().default(""), frontmatter: frontmatterArg, related: z.array(z.string()).optional().default([]), overwrite: z.boolean().optional().default(false), }, - src/tools.ts:459-463 (handler)Handler function for obsidian_create_note. Builds the note body with related wiki-links via withRelated(), optionally stringifies frontmatter, and writes the note via vaults.writeText().
async (args) => { const body = withRelated(args.content, args.related); const text = args.frontmatter ? stringifyFrontmatter(args.frontmatter, body) : body; return vaults.writeText(vaults.notePath(args.path), text, args.vault, { overwrite: args.overwrite }); }, - src/tools.ts:1366-1370 (helper)Helper function withRelated() that appends a '## Related' section with [[wiki-links]] to the note content when an array of related paths is provided.
function withRelated(content: string, related: string[]): string { if (related.length === 0) return content; const links = related.map((item) => `- [[${item.replace(/\.md$/i, "")}]]`).join("\n"); return `${content.replace(/\s*$/, "\n\n")}## Related\n${links}\n`; }