create_note
Create new Markdown notes in an Obsidian vault with specified path, content, optional title and tags.
Instructions
Create a new note.
Args: path: Path for the new note (e.g., "notes/new-note.md") content: Note content in Markdown title: Optional title (defaults to filename) tags: Optional list of tags
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| content | Yes | ||
| title | No | ||
| tags | No |
Implementation Reference
- server.py:106-131 (handler)MCP tool handler for 'create_note'. Receives path, content, optional title and tags, builds metadata dict, checks read-only mode, then delegates to ObsidianVaultClient.create_note(). Returns the created note dict or an error.
@mcp.tool() def create_note(path: str, content: str, title: Optional[str] = None, tags: Optional[list] = None) -> dict: """Create a new note. Args: path: Path for the new note (e.g., "notes/new-note.md") content: Note content in Markdown title: Optional title (defaults to filename) tags: Optional list of tags """ try: if is_read_only(): return read_only_error() client = get_vault_client() metadata = {} if title: metadata['title'] = title if tags: metadata['tags'] = tags note = client.create_note(path, content, metadata) return note except Exception as e: return {"error": str(e)} - server.py:106-107 (registration)The '@mcp.tool()' decorator registers create_note as an MCP tool with the FastMCP server instance.
@mcp.tool() def create_note(path: str, content: str, title: Optional[str] = None, tags: Optional[list] = None) -> dict: - obsidian_client.py:118-134 (helper)ObsidianVaultClient.create_note() - the underlying implementation that validates the path (must end with .md, must not exist), creates parent directories, builds a frontmatter Post with metadata, writes it to disk, then returns the newly created note via get_note().
def create_note(self, path: str, content: str, metadata: Optional[Dict] = None) -> Dict[str, Any]: """Create a new note.""" note_path = self._resolve_vault_path(path) if note_path.suffix.lower() != '.md': raise ValueError("Note path must end with .md") if note_path.exists(): raise ValueError(f"Note already exists: {path}") note_path.parent.mkdir(parents=True, exist_ok=True) post = frontmatter.Post(content, **(metadata or {})) with open(note_path, 'w', encoding='utf-8') as f: f.write(frontmatter.dumps(post)) return self.get_note(path) - server.py:108-115 (schema)The function signature and docstring serve as the input schema for the 'create_note' tool, specifying path (str), content (str), optional title (str), and optional tags (list).
"""Create a new note. Args: path: Path for the new note (e.g., "notes/new-note.md") content: Note content in Markdown title: Optional title (defaults to filename) tags: Optional list of tags """