Docs
中文 EN

Tools, On-Demand Codemode, MCP & Skills

CONTENTS

Mizar exposes only four core tools by default to keep prompt prefixes lean; external MCP and mizar bridge tools load lazily via ToolExposure, tool_search, and QuickJS codemode, and all invocations flow through a three-stage Cordis pipeline. Separately, mizar-skills injects skill catalogs or instructions alongside read / bash without registering a standalone tool.

1. Built-in Coding Tools (mizar-tools-coding)

By default, Mizar uses the MinimalCoding preset (read, bash, edit, write), where everyday file discovery and search run via rg, fd, or ls inside bash. grep and find stay dormant at zero token cost and activate under toolsPreset: "all", --tools, or --read-only (read-only audits, read-only mizar exec subagents, --approve prompt-free search, and restrictToWorkspace sandboxing):

ToolConcurrencyCapabilities & Output Caps
readParallelPaginated text (2000 lines / 50 KB / 2000 chars per line) or image reading (32 MiB input cap)
editSerialized per pathAtomic edits[] & replaceAll (exact/fuzzy match), preserving BOM and CRLF/LF
writeSerialized per pathCreates or overwrites files and parent dirs (re-read or edit required after compaction)
bashParallelRuns shell commands (120s default / 600s max); 400-line / 20 KB summary, raw bytes spilled to temp file; 128 + sig on signals
grepParallel (dormant)Prefers $MIZAR_HOME/bin/rg (auto-installed in TUI); .gitignore-aware, capped at 100 matches / 50 KB
findParallel (dormant)Prefers fd on PATH with Rust ignore + globset fallback; capped at 1000 entries / 50 KB

2. External Extensions: MCP & Bridge Dynamic Tools

  • MCP Client (mizar-mcp): Merges ~/.mizar/mcp.json and <workspace>/.mizar/mcp.json over stdio or Streamable HTTP / SSE. Tools register as mcp__<server>__<tool> (default Codemode); when any server advertises resources, list_mcp_resources, list_mcp_resource_templates, and read_mcp_resource are registered as Direct. Returned images flow through mizar-image (max 20 per result).
  • Bridge Dynamic Tools (mizar-bridge): Under mizar bridge, hosts dynamically register/unregister callback tools via JSON-RPC tools.register / tools.unregister (dispatched via tool.invoke) and manage per-session allowlists via tools.set_session_active.

Because external MCP servers can expose dozens or hundreds of tools, pushing all schemas into Turn 0 bloats context and destabilizes prompt prefixes — handled next by tiered exposure and on-demand orchestration.

3. On-Demand Visibility & Orchestration: ToolExposure, tool_search, and codemode

FIG 02 ToolExposure Levels, On-Demand codemode & MCP tool_search
ToolExposure Visibility Matrix mizar-tools Level Schema Sandbox Typical Tools / Behavior Direct ✓ Direct ✓ Call read · bash · edit · write (Minimal) ModelOnly ✓ Direct ✕ Deny codemode (on-demand) · tool_search Codemode ○ Lazy ✓ Sandbox MCP default (ALL_TOOLS / search) Deferred ○ Sleep ✓ Hide Large MCP (search to load) Hidden ✕ Hide ✕ Ban Blocked via excludeTools Priority: excludeTools/Hidden ✕ > includeTools > override > default Loop A · tool_search BM25 Lazy Load LAZY LOAD Dormant Pool Codemode / Deferred 0 Initial Tokens BM25 Search name×4.0 · ns×2.0 defaultLimit = 8 Session Load activate_tools Session-scoped • Active only when MCP Codemode/Deferred exist (0-MCP skips) • Matched tools join schemas next turn; direct calls check allowlist NEXT TURN LLM Context Window (Tool Schemas) CONTEXT BUDGET Minimal Active Schemas • Direct + ModelOnly • + BM25-loaded tools (onlyMode hides Direct) Token Savings MinimalCoding 4 tools On-demand codemode + MCP lazy search ① Run async JS ③ Compact JSON only Loop B · On-Demand codemode JS rquickjs Async JS Orchestrator (store · 2000L/50KB) await Promise.allSettled([tools.read(), tools.grep()]) Built-ins: ALL_TOOLS / searchTools / describeTool / store ② Digest Large Payloads Inside Sandbox • Filter large files & lists in QuickJS heap • Calls Direct/Codemode/Deferred; no ModelOnly • Limits: 256 MiB RAM · 1 MiB stack · 120s · 2w Return Aggregated Summary / structuredContent return / text() / console.log → compact output Logs CodemodeNestedCall spans for /trace audit
FIG 02: Five-tier ToolExposure matrix, on-demand QuickJS codemode orchestration, and MCP-only BM25 tool_search.

Five-Tier ToolExposure Model

TierLLM SchemaCallable via codemodeTypical Tools & Behavior
Direct✓ Yes✓ YesCore MinimalCoding tools, enabled grep/find, MCP resource tools
ModelOnly✓ Yes✗ Disallowedcodemode, tool_search (no recursive nesting inside JS)
Codemode✗ Lazy✓ Yes (in sandbox)Default for external MCP tools; discovered via ALL_TOOLS / searchTools()
Deferred✗ Lazy✓ Yes (hidden list)Opt-in large MCP tools; activated per session via tool_search / searchTools()
Hidden✗ No✗ NoMatched by excludeTools; invisible to both LLM and sandbox

Activation precedence (is_default_active): global_active_overrides > includeTools (--tools / tools) > auto_default_active > tool default; Hidden and excludeTools always block activation.

On-Demand tool_search (MCP-Only)

mizar-tool-search indexes Codemode and Deferred MCP tools with BM25 (defaultLimit = 8). When zero MCP tools are configured, tool_search is omitted completely; otherwise (unless toolSearch.autoEnable is false) it activates automatically and promotes matched schemas on the next LLM turn.

On-Demand codemode (QuickJS Sandbox)

codemode (mizar-codemode) stays dormant by default, activating only on --tools codemode, codemode.enabled: true, onlyMode: true, or when an enabled MCP server uses codemode exposure (autoEnableCodemode: true); codemode.enabled: false, disabledPlugins, or excludeTools opt out explicitly.

  • Batching & Output Cap: Scripts call tools.<name>(args) (e.g. Promise.allSettled), filter large data in QuickJS heap, and return summaries capped at 2000 lines / 50 KB (spilling excess to mizar-codemode-* temp files), while image attachments pass through the outer reply. In mixed mode, codemode schemas and <mcp_servers> stay byte-identical before and after background MCP handshakes.
  • Globals & Sandbox Limits: Embedded rquickjs enforces 256 MiB heap, 1 MiB stack, workers = 2, and 120,000 ms default timeout (overridable via // @options: {"timeoutMs": ...}), with no Node, filesystem, network, timers, or Web APIs (URL, fetch, etc.). Built-ins include ALL_TOOLS, searchTools(), describeTool(), describeNamespace(), and transactional store()/load() (committed only on normal return or exit(), discarded on errors/timeouts/aborts); onlyMode: true hides Direct declarations and lists local tools within inlineBudget (3000 tokens).
  • Failure Recovery Summary: Errors, timeouts, and aborts exit immediately without blocking and put Session store status, Nested calls summary (top 8 prioritized by unconfirmed / returned error), and bounded Script error at the top with logs moved to the tail so truncation never hides root causes.

4. Execution Pipeline & Concurrency Safety

Every tool call flows sequentially through validation and the three-stage Cordis waterfall:

  1. Argument & Allowlist Checks: parse_tool_arguments rejects malformed or non-object JSON instead of coercing to {} so the model retries in-turn; direct calls are also validated against the current step’s request.tools allowlist (without blocking nested codemode calls).
  2. tools/pre-execute: Runs ApprovalGatePlugin (prompting on non-readonly tools under --approve, including nested writes in codemode) and FileGuardTracker (requiring re-read before overwriting stale files; see Security & Approvals).
  3. tools/execute: Dispatches Parallel vs Sequential execution; same-path write / edit serialize via with_file_mutation_queue, while distinct-file and read-only calls run in parallel.
  4. tools/post-execute: Runs RepeatToolGuardPlugin to catch repeated failing calls and records per-tool duration_ms into traces.

5. Progressive Skills System (mizar-skills, No Standalone Tool)

Mizar removed the standalone skill tool: SkillRegistry and SkillsPlugin inject skill catalogs or full instructions into context alongside read / bash:

  • Layered Discovery & Hot Invalidation: Scans project .agents/skills (rank 200) > runtime (250) > customDirs (300) > user ~/.agents/skills (500) > bundled (600) (--isolated skips user roots) for SKILL.md (or root <name>.md), caching snapshots by size + mtime hash and invalidating immediately when write/edit touches a skill path.
  • Catalog Injection (<available_skills>): When read or bash is declared and model-invocable skills exist, <system-reminder> injects <name>, <description> (500-char cap), and the absolute <location> path to SKILL.md, deduplicated by (seq, state) and re-injected only after hot updates or compaction pruning.
  • Slash Gesture Expansion (/<skill-name>): Whitespace-delimited /<name> gestures in user input expand the full SKILL.md body and resource base directory directly into <skill_content> so the model acts immediately without an extra read (also selectable via /skills in TUI).

Search Mizar Docs