Skip to content

API Reference parrot.tools.obsidian

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.obsidian

View source

ObsidianToolkit — agent tools for managing an Obsidian vault.

Built on the shared vault interface (parrot.interfaces.obsidian): the same parsing, wikilink-resolution and backlink engine used by the FEAT-392 vault loader and the wikitoolkit vault scanner. Supports both vault backends — direct filesystem (backend="local") and the Obsidian Local REST API community plugin (backend="rest").

Follows the one-tool-per-operation design (see FileManagerToolkit): every public async method becomes an LLM-callable tool named obsidian_<method>; destructive operations are declared in confirming_tools for human-in-the-loop confirmation.

Alias AbstractToolkit

Re-exported from parrot.tools.toolkit.AbstractToolkit.

Alias ObsidianNote

Re-exported from parrot.interfaces.obsidian.ObsidianNote.

Class ObsidianToolkit

Toolkit for AI agents to manage an Obsidian vault.

Tool names (with tool_prefix="obsidian"):

  • obsidian_read_note — read one note (parsed + content)
  • obsidian_read_notes — bulk-read several notes
  • obsidian_list_notes — list notes with file info
  • obsidian_search_notes — keyword search over the vault
  • obsidian_search_by_tag — notes carrying a tag
  • obsidian_search_with_backlinks— search + link neighborhood
  • obsidian_get_backlinks — notes linking to a note
  • obsidian_get_outgoing_links — a note's resolved outlinks
  • obsidian_get_note_metadata — frontmatter + stat, no body
  • obsidian_catalog_notes — vault catalog and health report
  • obsidian_create_note — create a note (confirming)
  • obsidian_update_note — replace note body (confirming)
  • obsidian_append_note — append to a note (confirming)
  • obsidian_delete_note — delete a note (confirming)
  • obsidian_move_note — move/rename a note (confirming)
  • obsidian_get_okf_metadata — read a note's OKF block
  • obsidian_validate_okf_frontmatter — lint OKF metadata
  • obsidian_classify_note — suggest OKF ConceptTypes
  • obsidian_apply_okf_frontmatter— write OKF block (confirming)

Example::

toolkit = ObsidianToolkit(vault_path="~/vaults/notes")
tools = toolkit.get_tools()
result = await toolkit.search_notes(query="retrieval")
Parameter Type Default Description
vault_path Optional[str | Path] None Vault directory (local backend). Ignored when a prebuilt vault is injected.
backend Literal['local', 'rest'] 'local' "local" (filesystem) or "rest" (Local REST API plugin; pass base_url/api_key via backend_kwargs).
vault Optional[ObsidianVaultInterface] None Optional prebuilt backend instance (overrides vault_path/backend).
allowed_operations Optional[Set[str]] None Restrict which operations become tools. Subset of {"read", "bulk_read", "list", "search", "search_tag", "search_backlinks", "backlinks", "outlinks", "metadata", "catalog", "create", "update", "append", "delete", "move"}. None exposes all.
**backend_kwargs Any {} Forwarded to the backend constructor.

Attributes:

Attribute Type Description
tool_prefix Optional[str]
auto_open bool
confirming_tools frozenset
allowed_operations Set[str]

Method ObsidianToolkit.read_note

Read one Obsidian note: content plus parsed structure.

read_note(path: str, include_content: bool = True) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path (.md optional).
include_content bool True Include the full markdown body (default True).

Returns: Dict[str, Any] — Dict with path, title, content, frontmatter, tags, aliases, links and dataview_queries.

Raises:

  • FileNotFoundError — If the note does not exist.

Method ObsidianToolkit.read_notes

Bulk-read several notes in one call.

read_notes(paths: list[str], include_content: bool = True) -> Dict[str, Any]

Parameter Type Default Description
paths list[str] Vault-relative note paths (max 50 per call).
include_content bool True Include full markdown bodies (default True).

Returns: Dict[str, Any] — Dict with notes (successfully read, parsed payloads) and errors (path -> error message for failed reads).

Method ObsidianToolkit.list_notes

List markdown notes in the vault (or one folder).

list_notes(folder: Optional[str] = None, recursive: bool = True) -> Dict[str, Any]

Parameter Type Default Description
folder Optional[str] None Vault-relative folder; None for the whole vault.
recursive bool True Descend into subfolders (default True).

Returns: Dict[str, Any] — Dict with notes (path/name/size/mtime descriptors) and count.

Method ObsidianToolkit.get_note_metadata

Read a note's frontmatter and file info without its body.

get_note_metadata(path: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path.

Returns: Dict[str, Any] — Dict with path, title, frontmatter, tags, aliases and file stat info (size, mtime when available).

Raises:

  • FileNotFoundError — If the note does not exist.

Method ObsidianToolkit.search_notes

Search notes by keywords over titles, tags, aliases and bodies.

search_notes(query: str, limit: int = 20) -> Dict[str, Any]

Parameter Type Default Description
query str Search terms (space-separated keywords).
limit int 20 Maximum results (default 20).

Returns: Dict[str, Any] — Dict with hits (path, score, snippet, matched fields) and count.

Method ObsidianToolkit.search_by_tag

Find notes carrying a tag (inline #tag or frontmatter).

Nested tags match by prefix: searching project also returns notes tagged project/status.

search_by_tag(tag: str, limit: int = 50) -> Dict[str, Any]

Parameter Type Default Description
tag str Tag name with or without the leading #.
limit int 50 Maximum results (default 50).

Returns: Dict[str, Any] — Dict with paths of matching notes and count.

Method ObsidianToolkit.search_with_backlinks

Search notes, expanding each hit with its link neighborhood.

For every search hit, includes up to expand backlinks (notes pointing at the hit) and expand outgoing links — the hand-curated context Obsidian users build via wikilinks.

search_with_backlinks(query: str, limit: int = 10, expand: int = 5) -> Dict[str, Any]

Parameter Type Default Description
query str Search terms.
limit int 10 Maximum primary hits (default 10).
expand int 5 Maximum backlinks/outlinks listed per hit (default 5).

Returns: Dict[str, Any] — Dict with hits; each hit carries path, score, snippet, backlinks and outlinks.

Method ObsidianToolkit.get_backlinks

List notes whose wikilinks resolve to this note.

get_backlinks(path: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path.

Returns: Dict[str, Any] — Dict with backlinks (note paths) and count.

Method ObsidianToolkit.get_outgoing_links

List a note's outgoing wikilinks/embeds with resolution status.

get_outgoing_links(path: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path.

Returns: Dict[str, Any] — Dict with links (target, alias, heading, is_embed, resolved_path or null) and unresolved targets.

Method ObsidianToolkit.catalog_notes

Catalog the vault: folders, tags, orphans, broken links, aliases.

catalog_notes(folder: Optional[str] = None) -> Dict[str, Any]

Parameter Type Default Description
folder Optional[str] None Restrict the folder statistics to one subtree; the link/tag analysis always covers the whole vault.

Returns: Dict[str, Any] — Dict with note_count, notes_per_folder, tags (tag -> count), orphans, broken_links (from_path -> target) and aliases (alias -> path).

Method ObsidianToolkit.create_note

Create a new note (fails if it already exists).

create_note(path: str, content: str, frontmatter: Optional[Dict[str, Any]] = None) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative path for the new note.
content str Markdown body.
frontmatter Optional[Dict[str, Any]] None Optional YAML frontmatter mapping (tags, aliases, custom keys) rendered ahead of the body.

Returns: Dict[str, Any] — Descriptor of the created file.

Raises:

  • FileExistsError — If a note already exists at path.

Method ObsidianToolkit.update_note

Replace a note's markdown body.

update_note(path: str, content: str, preserve_frontmatter: bool = True) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path (must exist).
content str New markdown body.
preserve_frontmatter bool True Keep the existing YAML frontmatter block (default True); False replaces the whole file with content.

Returns: Dict[str, Any] — Descriptor of the updated file.

Raises:

  • FileNotFoundError — If the note does not exist.

Method ObsidianToolkit.append_note

Append markdown to the end of an existing note.

append_note(path: str, content: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path (must exist).
content str Markdown to append.

Returns: Dict[str, Any] — Descriptor of the updated file.

Raises:

  • FileNotFoundError — If the note does not exist.

Method ObsidianToolkit.delete_note

Delete a note from the vault.

delete_note(path: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path.

Returns: Dict[str, Any] — Dict with deleted (bool) and the affected backlinks that now point at a missing note.

Method ObsidianToolkit.move_note

Move or rename a note within the vault.

move_note(source: str, destination: str) -> Dict[str, Any]

Parameter Type Default Description
source str Current vault-relative path.
destination str New vault-relative path.

Returns: Dict[str, Any] — Dict with the new file descriptor and affected_backlinks — notes whose [[wikilinks]] referenced the old path/name and may now be broken (links are NOT rewritten automatically).

Raises:

  • FileNotFoundError — If the source note does not exist.
  • FileExistsError — If a note already exists at the destination.

Method ObsidianToolkit.get_okf_metadata

Read a note's OKF metadata (the okf: frontmatter block).

get_okf_metadata(path: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path.

Returns: Dict[str, Any] — Dict with okf (the parsed block, or null when absent) and has_okf.

Raises:

  • FileNotFoundError — If the note does not exist.
  • ValueError — If the okf block exists but is malformed.

Method ObsidianToolkit.validate_okf_frontmatter

Lint OKF frontmatter for one note or the whole vault.

Checks type/relation values against the OKF controlled vocabulary and verifies that relates_to targets resolve to real notes.

validate_okf_frontmatter(path: Optional[str] = None, folder: Optional[str] = None) -> Dict[str, Any]

Parameter Type Default Description
path Optional[str] None Lint one note; when omitted the whole vault (or the given folder) is linted.
folder Optional[str] None Restrict the vault-wide lint to one folder.

Returns: Dict[str, Any] — Dict with findings (list of human-readable strings), notes_checked and notes_with_okf.

Method ObsidianToolkit.classify_note

Suggest OKF ConceptType classifications for a note.

Deterministic heuristic over the note's frontmatter, tags and title against the OKF controlled vocabulary — no LLM inside the tool (the agent applies its own reasoning on top and can persist a choice via apply_okf_frontmatter).

classify_note(path: str) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path.

Returns: Dict[str, Any] — Dict with ranked candidates (type + rationale) and the note's tags/title evidence.

Method ObsidianToolkit.apply_okf_frontmatter

Write/replace a note's okf: frontmatter block.

Native frontmatter keys are preserved; the okf subtree is regenerated wholesale (single-writer rule — hand edits to it are overwritten). The note body is untouched.

apply_okf_frontmatter(path: str, okf: Dict[str, Any], mirror_tags: bool = False) -> Dict[str, Any]

Parameter Type Default Description
path str Vault-relative note path (must exist).
okf Dict[str, Any] OKF fields — type (ConceptType value), summary, tags, relates_to (list of {concept, rel}; [[wikilink]] targets are normalized), optional title/id/source. id and resource default to the note's stable vault id.
mirror_tags bool False Also mirror OKF tags into native tags: as okf/<tag> so Obsidian search sees them.

Returns: Dict[str, Any] — Dict with the written file info and the applied okf block.

Raises:

  • FileNotFoundError — If the note does not exist.
  • ValueError — For unknown ConceptType/RelationType values or unresolvable relates_to targets.

Alias ObsidianVaultInterface

Re-exported from parrot.interfaces.obsidian.ObsidianVaultInterface.

Alias create_vault_backend

Re-exported from parrot.interfaces.obsidian.create_vault_backend.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally