MCP tools
These are the tools the sklad MCP server exposes: generic, file-like tools at the core, and typed tools only where they save real effort. A test (crates/server/tests/tool_catalog.rs) fails CI when a registered tool is missing from this page.
No tool names a kind. Kinds, paths, fields, states and templates come from the
KB’s .kb/framework.toml; the server instructions carry the conventions that
definition implies, so a client knows where things go before it writes. The
two shortcut tools write the kinds named by the server config inbox_kind and
journal_kind (default inbox and journal), since the definition has no
property that marks a kind as either.
Paths are checked against the server’s snapshot of the vault. A tool that
takes a path accepts only files the walk lists (for kb_git_log, also a
directory holding such files), so hidden paths and paths the definition
excludes answer exactly like a missing file. The write pipeline refuses any
write into a hidden or excluded path the same way (-32001 not_found).
Read tools (scope: kb:read)
Section titled “Read tools (scope: kb:read)”kb_ping
Section titled “kb_ping”- Description: Health-check — returns server version and current time.
- Args: none
- Returns:
{ ok, server_version, server_time }as JSON text. - Errors: none.
kb_search
Section titled “kb_search”- Description: Ranked search over sections of every note (in-memory BM25; terms are stemmed).
- Args:
{ query: string, kinds?: string[], status?: string, tags?: string[], include_archived?: bool, limit?: number, cursor?: string }(cursor is reserved; not yet honored) - Matching: every term is optional; sections matching more terms rank higher, and a word of four or more letters missing from the KB also matches its nearest KB words.
kindsare checked against the definition;statusmatches each kind’s state field (kinds without a state drop out);tagsmatch frontmatter. Notes under the archive prefix are left out unlessinclude_archived. At most three hits per note. - Returns:
Page<SearchHit>with{path, kind, slug, title, heading, lines, snippet, score, blob_sha};headingis the section’s heading trail andlinesits first and last line. - Errors:
-32602invalid args;-32603internal.
kb_read
Section titled “kb_read”- Description: Read a file, or one section of it with its subsections. Reads the file on disk, so it sees every write at once.
- Args:
{ path: string, section?: string, from_line?: number }—sectionis an anchor (#next-action) or a heading trail (Goal > Details, matched from its end and case-insensitively, soDetailsalone works when it is unique). - Returns:
{ path, blob_sha, content, lines: [first, last], heading?, anchor?, next_line? };blob_shais always the whole file’s, ready forkb_edit’sexpected_sha.contentstops at 256 KB on a line boundary (a single longer line is cut);next_linethen says where to continue withfrom_line. - Errors:
-32001not_found, also for hidden paths and paths the definition excludes;-32602for a section that matches nothing or more than one heading (the message lists the anchors) and for a file that is not UTF-8.
kb_grep
Section titled “kb_grep”- Description: Regex over the lines of every markdown file the definition does not exclude (archived files included), in path order.
- Args:
{ pattern: string, paths?: string[], context?: number, max_matches?: number }—patternuses Rust regex syntax ((?i)for case-insensitive);pathsare globs, any of which must match (*within one segment,**across);context0–10 lines (default 0);max_matches1–500 (default 50). - Returns:
{ matches: { path, line, text, before?, after? }[], truncated }. Lines longer than 500 characters are cut with…; the output stops near 128 KB of text, andtruncatedsays it stopped early. - Errors:
-32602invalid pattern or glob.
kb_list
Section titled “kb_list”- Description: List the live units of a kind, by path;
statusmatches the kind’s state field. Pagination via opaque cursors. - Args:
{ kind: string, status?: string, tags?: string[], since?: string (YYYY-MM-DD), limit?: number, cursor?: string }— the advertised schema lists the definition’s kinds askind’s enum; callkb_kindsfor their descriptions. - Returns:
Page<EntitySummary>—{ items, next_cursor? }; an item is{ path, kind, slug, state?, dates?, tags, mtime, blob_sha }:stateis the kind’s state field,datesits date and datetime fields that are set. - Errors:
-32602invalid args (incl. malformed cursor / unknown kind);-32603internal.
kb_kinds
Section titled “kb_kinds”- Description: Enumerate the kinds of the KB’s
.kb/framework.toml, in definition order. No args. - Args:
{} - Returns:
{ kinds: { name: string, label: string, description: string }[] }. - Errors:
-32603internal.
kb_next
Section titled “kb_next”- Description:
sklad nexton the server: active work items (kinds withstateandnext) with their next action, then open tasks in bucketsoverdue,today,in-progress,upcoming,priority;staleandlaterare counted unlessall. - Args:
{ all?: bool, horizon?: number (days, default 7), today?: string (YYYY-MM-DD, default today injournal_tz), limit?: number, in?: string (a file or directory) } - Returns: the
sklad next --jsonshape:{ today, tickets, tasks, hidden }. - Errors:
-32602invalid date.
kb_backlinks
Section titled “kb_backlinks”- Description: Find notes whose links resolve to a target, in any link style (root-relative, file-relative, wikilink), from the index’s link graph.
- Args:
{ target: string, limit?: number }—targetis a vault path (.mdoptional), a unique file name, or a unique note title, matched case-insensitively. - Returns:
{ target, items: { path, kind, slug, title, links: { line, heading, anchor?, embed }[] }[] };targetis the resolved path,nullwhen nothing matches. - Errors:
-32602invalid args;-32603internal.
kb_related
Section titled “kb_related”- Description: Find notes related to a source note: linked within two hops, or sharing values of list-valued frontmatter keys such as
tags(reciprocal-rank fusion of both). - Args:
{ path: string } | { kind: string, slug: string }plus optionallimit?: number. - Returns:
{ source_path, items: { path, kind, slug, title, score, reasons: string[] }[] };reasonsholdslink:Nandshared:KEY=VALUE. - Errors:
-32602invalid args (incl. source not found);-32603internal.
kb_git_log
Section titled “kb_git_log”- Description: Recent commit history of the KB repo, newest first, optionally filtered to commits touching a path.
- Args:
{ limit?: number, path?: string }—pathis a file or directory the snapshot lists; the history of a deleted file is out of reach. Commits whose every change is a path the definition excludes are left out, filtered or not. - Returns:
{ commits: { sha, short_sha, author, email, time, summary, message }[], truncated? }. At most 2000 commits are examined per call;truncated: truemeans the walk stopped there, so older matching commits may exist. - Errors:
-32603internal.
Write tools (scope: kb:write)
Section titled “Write tools (scope: kb:write)”The writing tools (kb_create, kb_edit, inbox_capture, journal_append)
accept dry_run: bool and return WriteResult:
{path, blob_sha, commit_sha?, pushed?, diff, dry_run, violations?}.
pushed is present when a commit was made and auto-push is enabled: the write
waits for its git push, and false means the commit is saved on the server
but has not reached the remote (the write itself still succeeded).
violations lists the sklad check findings ({path, line, rule, severity, message}) for the file as written. kb_create refuses error-level findings;
kb_edit only reports them, so an agent can fix them with further edits.
The policy scan runs on every write, whatever [policy] include says (that
key narrows only sklad check): a blocking hit on a changed line refuses it.
The pipeline creates missing parent directories itself, never through a
symlink or inside an excluded directory.
Common errors: -32001 path_denied/not_found, -32002 conflict (stale
expected_sha), -32003 policy_violation, -32004 mutation, -32603 internal.
Templates are rendered with {{var}} substitution ({{title}}, {{date}},
{{datetime}}, {{weekday}}, and the path placeholders such as {{slug}});
{{date:FORMAT}} is supported with Moment.js tokens (YYYY, YY,
MMMM, MMM, MM, dddd, ddd, DD, HH, mm, ss). Any other unknown
placeholder is left verbatim so the authoring mistake is visible.
kb_create
Section titled “kb_create”- Description:
sklad newas one commit: a unit of a kind, or a standalone template at a given path. The path comes from the kind’s pattern, the content from its template. - Args:
{ kind: string, title: string, bind?: {string: string}, set?: {string: any}, path?: string, body?: string, dry_run?: bool }— the advertised schema lists the definition’s kinds and standalone templates askind’s enum.bindfills path placeholders (slug, which defaults to the title’s slug;path, the directory prefix of a{path}pattern;handle, …).setfills frontmatter fields, checked against the kind’s schema.bodyis appended below the rendered template. - Returns:
WriteResultwithviolations(warnings and infos only). - Errors:
-32602for a path that is not markdown, an unknown kind, an unbound placeholder, a taken path (its other form and its archive mirror count), a field the schema rejects, or a result (template plus body) that fails the KB’s error-level checks, assklad newrefuses it. Auniquekind whose unit exists (today’s journal entry, say) is refused too: edit that file withkb_edit.
kb_edit
Section titled “kb_edit”- Description: Change one existing markdown file with ordered
str_replaceedits, as one commit. Cannot create, move or delete files. Violations are reported, never refused, so a broken file can be repaired step by step. - Args:
{ path: string, edits: { old_str: string, new_str: string }[], expected_sha?: string, dry_run?: bool }— eachold_strmust occur exactly once in the text the earlier edits left, overlapping occurrences counted; an emptynew_strdeletes. All edits apply or none. At most 100 edits. - Returns:
WriteResultwithviolationsfor the edited file. - Errors:
-32602for a path that is not markdown or an emptyold_str;-32001not_found (also hidden and excluded paths) or path_denied (archive, templates,.kb/);-32002conflict on a staleexpected_sha;-32003policy_violation on a changed line;-32004mutation when anold_strmatches zero or several times (the message names the edit).
inbox_capture
Section titled “inbox_capture”- Description: One-call capture: a new unit of the inbox kind from its template,
tagsin the frontmatter, the body below. The slug comes from the title (or the body’s first line), suffixed-1,-2, … when taken. - Args:
{ title?: string, body: string, tags?: string[], dry_run?: bool } - Returns:
WriteResult.
journal_append
Section titled “journal_append”- Description: Append to a day’s unit of the journal kind, under
## Notesor under a new## <heading>. A missing day is created from its template in the same commit. - Args:
{ date?: string (YYYY-MM-DD, default today injournal_tz), heading?: string, body: string, expected_sha?: string, dry_run?: bool } - Returns:
WriteResult.expected_shafor a day without an entry is a conflict.
share_create
Section titled “share_create”- Description: Mint a share link for one KB page. Returns the URL to send. Writes a registry row only — no commit, no key rotation, no change to the working tree.
- Args:
{ path: string, label?: string }—pathis a vault path with or without.md; a directory-form entity resolves to itsindex.md.labelis free text recorded with the link (who it went to and why). - Returns:
ShareView—{ id, path, url, label, created_at, last_used_at, revoked_at }. - Errors:
-32602invalid_args when the path names no Markdown page inside the KB;-32603internal (also when the HTML surface is disabled, so no link could be served). - Note: Minting the same page twice creates two independent links, so two recipients can be tracked and revoked separately.
share_list
Section titled “share_list”- Description: List share links with their page, label, URL, creation and last-used time.
- Args:
{ include_revoked?: boolean }— revoked links are hidden by default. - Returns:
{ links: ShareView[] }, newest first. - Errors:
-32603internal.
share_revoke
Section titled “share_revoke”- Description: Revoke a share link by id. Takes effect immediately; no commit, no key rotation, and no other link is disturbed.
- Args:
{ id: string } - Returns:
{ id, revoked }—revokedisfalsewhen the id was unknown or already revoked; revoking twice is not an error. - Errors:
-32602invalid_args on an empty id;-32603internal.
Admin tools (scope: kb:admin)
Section titled “Admin tools (scope: kb:admin)”kb_health
Section titled “kb_health”- Description: Structured server status — version, uptime, repo head, watcher lag, last write outcome, index counts.
- Args:
{} - Returns:
{ version, uptime_seconds, kb_path, kb_repo_head, kb_repo_dirty, kb_repo_unpushed_commits, index_entities, index_tasks, watcher_lag_ms, last_write_outcome? } - Errors:
-32603if invoked on a server instance without health state.
archive_move
Section titled “archive_move”- Description: Move a file to
archive/<path>. Destructive. Copies the file underarchive/first, then deletes the original (two commits). - Args:
{ path: string, expected_sha?: string, confirm?: bool, dry_run?: bool } - Returns:
WriteResultwithentity={ archived_path, former_path }. - Errors:
-32005confirm_required withoutconfirm: true;-32001not_found;-32002conflict on staleexpected_sha.
archive_restore
Section titled “archive_restore”- Description: Inverse of
archive_move. Recreates the file at its original path fromarchive/<path>, then deletes the archived copy. - Args:
{ path: string, dry_run?: bool }(a leadingarchive/is stripped). - Returns:
WriteResultwithentity={ restored_path, former_archive_path }. - Errors:
-32001not_found (no archived copy);-32001path_denied if the original path already exists.
Total surface
Section titled “Total surface”10 read + 7 write + 3 admin = 20 tools.