Skip to content

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).

  • Description: Health-check — returns server version and current time.
  • Args: none
  • Returns: { ok, server_version, server_time } as JSON text.
  • Errors: none.
  • 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. kinds are checked against the definition; status matches each kind’s state field (kinds without a state drop out); tags match frontmatter. Notes under the archive prefix are left out unless include_archived. At most three hits per note.
  • Returns: Page<SearchHit> with {path, kind, slug, title, heading, lines, snippet, score, blob_sha}; heading is the section’s heading trail and lines its first and last line.
  • Errors: -32602 invalid args; -32603 internal.
  • 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 } — section is an anchor (#next-action) or a heading trail (Goal > Details, matched from its end and case-insensitively, so Details alone works when it is unique).
  • Returns: { path, blob_sha, content, lines: [first, last], heading?, anchor?, next_line? }; blob_sha is always the whole file’s, ready for kb_edit’s expected_sha. content stops at 256 KB on a line boundary (a single longer line is cut); next_line then says where to continue with from_line.
  • Errors: -32001 not_found, also for hidden paths and paths the definition excludes; -32602 for a section that matches nothing or more than one heading (the message lists the anchors) and for a file that is not UTF-8.
  • 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 } — pattern uses Rust regex syntax ((?i) for case-insensitive); paths are globs, any of which must match (* within one segment, ** across); context 0–10 lines (default 0); max_matches 1–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, and truncated says it stopped early.
  • Errors: -32602 invalid pattern or glob.
  • Description: List the live units of a kind, by path; status matches 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 as kind’s enum; call kb_kinds for their descriptions.
  • Returns: Page<EntitySummary> — { items, next_cursor? }; an item is { path, kind, slug, state?, dates?, tags, mtime, blob_sha }: state is the kind’s state field, dates its date and datetime fields that are set.
  • Errors: -32602 invalid args (incl. malformed cursor / unknown kind); -32603 internal.
  • 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: -32603 internal.
  • Description: sklad next on the server: active work items (kinds with state and next) with their next action, then open tasks in buckets overdue, today, in-progress, upcoming, priority; stale and later are counted unless all.
  • Args: { all?: bool, horizon?: number (days, default 7), today?: string (YYYY-MM-DD, default today in journal_tz), limit?: number, in?: string (a file or directory) }
  • Returns: the sklad next --json shape: { today, tickets, tasks, hidden }.
  • Errors: -32602 invalid date.
  • 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 } — target is a vault path (.md optional), a unique file name, or a unique note title, matched case-insensitively.
  • Returns: { target, items: { path, kind, slug, title, links: { line, heading, anchor?, embed }[] }[] }; target is the resolved path, null when nothing matches.
  • Errors: -32602 invalid args; -32603 internal.
  • 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 optional limit?: number.
  • Returns: { source_path, items: { path, kind, slug, title, score, reasons: string[] }[] }; reasons holds link:N and shared:KEY=VALUE.
  • Errors: -32602 invalid args (incl. source not found); -32603 internal.
  • Description: Recent commit history of the KB repo, newest first, optionally filtered to commits touching a path.
  • Args: { limit?: number, path?: string } — path is 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: true means the walk stopped there, so older matching commits may exist.
  • Errors: -32603 internal.

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.

  • Description: sklad new as 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 as kind’s enum. bind fills path placeholders (slug, which defaults to the title’s slug; path, the directory prefix of a {path} pattern; handle, …). set fills frontmatter fields, checked against the kind’s schema. body is appended below the rendered template.
  • Returns: WriteResult with violations (warnings and infos only).
  • Errors: -32602 for 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, as sklad new refuses it. A unique kind whose unit exists (today’s journal entry, say) is refused too: edit that file with kb_edit.
  • Description: Change one existing markdown file with ordered str_replace edits, 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 } — each old_str must occur exactly once in the text the earlier edits left, overlapping occurrences counted; an empty new_str deletes. All edits apply or none. At most 100 edits.
  • Returns: WriteResult with violations for the edited file.
  • Errors: -32602 for a path that is not markdown or an empty old_str; -32001 not_found (also hidden and excluded paths) or path_denied (archive, templates, .kb/); -32002 conflict on a stale expected_sha; -32003 policy_violation on a changed line; -32004 mutation when an old_str matches zero or several times (the message names the edit).
  • Description: One-call capture: a new unit of the inbox kind from its template, tags in 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.
  • Description: Append to a day’s unit of the journal kind, under ## Notes or under a new ## <heading>. A missing day is created from its template in the same commit.
  • Args: { date?: string (YYYY-MM-DD, default today in journal_tz), heading?: string, body: string, expected_sha?: string, dry_run?: bool }
  • Returns: WriteResult. expected_sha for a day without an entry is a conflict.
  • 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 } — path is a vault path with or without .md; a directory-form entity resolves to its index.md. label is 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: -32602 invalid_args when the path names no Markdown page inside the KB; -32603 internal (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.
  • 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: -32603 internal.
  • 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 } — revoked is false when the id was unknown or already revoked; revoking twice is not an error.
  • Errors: -32602 invalid_args on an empty id; -32603 internal.
  • 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: -32603 if invoked on a server instance without health state.
  • Description: Move a file to archive/<path>. Destructive. Copies the file under archive/ first, then deletes the original (two commits).
  • Args: { path: string, expected_sha?: string, confirm?: bool, dry_run?: bool }
  • Returns: WriteResult with entity = { archived_path, former_path }.
  • Errors: -32005 confirm_required without confirm: true; -32001 not_found; -32002 conflict on stale expected_sha.
  • Description: Inverse of archive_move. Recreates the file at its original path from archive/<path>, then deletes the archived copy.
  • Args: { path: string, dry_run?: bool } (a leading archive/ is stripped).
  • Returns: WriteResult with entity = { restored_path, former_archive_path }.
  • Errors: -32001 not_found (no archived copy); -32001 path_denied if the original path already exists.

10 read + 7 write + 3 admin = 20 tools.