pub struct NbClient { /* private fields */ }Expand description
Client for invoking nb commands.
Implementations§
Source§impl NbClient
impl NbClient
Sourcepub fn new(config: &Config) -> Result<Self>
pub fn new(config: &Config) -> Result<Self>
Creates a new nb client.
Uses the notebook from config if set, otherwise falls back to a
Git-derived notebook name. Does NOT read NB_MCP_NOTEBOOK —
that is an MCP-server-specific env var resolved by the server.
Sourcepub async fn show_notebook_status(
&self,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn show_notebook_status( &self, notebook: Option<&str>, ) -> Result<String, NbError>
Returns status information about the resolved notebook.
Sourcepub async fn list_notebooks(&self) -> Result<String, NbError>
pub async fn list_notebooks(&self) -> Result<String, NbError>
Lists available notebooks.
Sourcepub async fn show_notebook_path(
&self,
notebook: Option<&str>,
) -> Result<PathBuf, NbError>
pub async fn show_notebook_path( &self, notebook: Option<&str>, ) -> Result<PathBuf, NbError>
Returns the path for a notebook.
Sourcepub async fn add_note(
&self,
title: Option<&str>,
content: &str,
tags: &[String],
folder: Option<&str>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn add_note( &self, title: Option<&str>, content: &str, tags: &[String], folder: Option<&str>, notebook: Option<&str>, ) -> Result<String, NbError>
Creates a new note.
Sourcepub async fn show_note(
&self,
id: &str,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn show_note( &self, id: &str, notebook: Option<&str>, ) -> Result<String, NbError>
Shows a note’s content.
Sourcepub async fn list_notes(
&self,
folder: Option<&str>,
tags: &[String],
limit: Option<u32>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn list_notes( &self, folder: Option<&str>, tags: &[String], limit: Option<u32>, notebook: Option<&str>, ) -> Result<String, NbError>
Lists notes in a notebook or folder.
Sourcepub async fn search_notes(
&self,
queries: &[String],
mode: SearchMode,
tags: &[String],
folder: Option<&str>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn search_notes( &self, queries: &[String], mode: SearchMode, tags: &[String], folder: Option<&str>, notebook: Option<&str>, ) -> Result<String, NbError>
Searches notes.
Sourcepub async fn edit_note(
&self,
id: &str,
content: &str,
mode: EditMode,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn edit_note( &self, id: &str, content: &str, mode: EditMode, notebook: Option<&str>, ) -> Result<String, NbError>
Edits a note using the provided content mode.
See EditMode for the vocabulary rationale (the variant
previously named Replace is now Overwrite to remove the
vocabulary trap at the root of nb-api:issues/api/6).
Requiredness on the consumer side (e.g., the mode field on
nb-mcp-server’s EditArgs) is a consumer-layer concern,
not enforced here.
Sourcepub async fn delete_note(
&self,
id: &str,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn delete_note( &self, id: &str, notebook: Option<&str>, ) -> Result<String, NbError>
Deletes a note.
Sourcepub async fn move_note(
&self,
id: &str,
destination: &str,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn move_note( &self, id: &str, destination: &str, notebook: Option<&str>, ) -> Result<String, NbError>
Moves or renames a note.
Sourcepub async fn add_todo(
&self,
title: &str,
description: Option<&str>,
tasks: &[String],
tags: &[String],
folder: Option<&str>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn add_todo( &self, title: &str, description: Option<&str>, tasks: &[String], tags: &[String], folder: Option<&str>, notebook: Option<&str>, ) -> Result<String, NbError>
Creates a todo item.
Sourcepub async fn mark_task_done(
&self,
id: &str,
task_number: Option<u32>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn mark_task_done( &self, id: &str, task_number: Option<u32>, notebook: Option<&str>, ) -> Result<String, NbError>
Marks a todo as done.
Sourcepub async fn unmark_task_done(
&self,
id: &str,
task_number: Option<u32>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn unmark_task_done( &self, id: &str, task_number: Option<u32>, notebook: Option<&str>, ) -> Result<String, NbError>
Marks a todo as not done.
Sourcepub async fn list_tasks(
&self,
folder: Option<&str>,
status: Option<TaskStatus>,
recursive: bool,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn list_tasks( &self, folder: Option<&str>, status: Option<TaskStatus>, recursive: bool, notebook: Option<&str>, ) -> Result<String, NbError>
Lists checklist items within todos.
Invokes the nb tasks subcommand. The method enumerates
the checklist items within todos (and recursively into
subfolders when recursive = true), filtered by
status if provided. The method name matches the
underlying nb CLI command (nb tasks); a future
list_todos method for the todo container listing
(invoking nb todos) is tracked at
nb-api:todos/api/5 (deferred to 0.3.0+).
Sourcepub async fn add_bookmark(
&self,
url: &str,
title: Option<&str>,
tags: &[String],
comment: Option<&str>,
folder: Option<&str>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn add_bookmark( &self, url: &str, title: Option<&str>, tags: &[String], comment: Option<&str>, folder: Option<&str>, notebook: Option<&str>, ) -> Result<String, NbError>
Creates a bookmark.
Sourcepub async fn list_folders(
&self,
parent: Option<&str>,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn list_folders( &self, parent: Option<&str>, notebook: Option<&str>, ) -> Result<String, NbError>
Lists folders in a notebook.
Sourcepub async fn add_folder(
&self,
path: &str,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn add_folder( &self, path: &str, notebook: Option<&str>, ) -> Result<String, NbError>
Creates a folder.
Sourcepub async fn import_note(
&self,
source: &str,
folder: Option<&str>,
filename: Option<&str>,
convert: bool,
notebook: Option<&str>,
) -> Result<String, NbError>
pub async fn import_note( &self, source: &str, folder: Option<&str>, filename: Option<&str>, convert: bool, notebook: Option<&str>, ) -> Result<String, NbError>
Imports a file or URL into the notebook as a note.
Invokes nb import, which only handles notes (HTML,
Markdown, plain text, and other source formats that
nb can convert into a note body). The _note suffix
is correct because nb import cannot create bookmarks
or folders — those use add_bookmark and add_folder
respectively. The source may be a local file path or
a URL; HTML sources may be converted to Markdown via
convert = true.