Tools, On-Demand Codemode, MCP & Skills
CONTENTS
- 1. Built-in Coding Tools (mizar-tools-coding)
- 2. External Extensions: MCP & Bridge Dynamic Tools
- 3. On-Demand Visibility & Orchestration: ToolExposure, tool_search, and codemode
- Five-Tier ToolExposure Model
- On-Demand tool_search (MCP-Only)
- On-Demand codemode (QuickJS Sandbox)
- 4. Execution Pipeline & Concurrency Safety
- 5. Progressive Skills System (mizar-skills, No Standalone Tool)
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):
| Tool | Concurrency | Capabilities & Output Caps |
|---|---|---|
read | Parallel | Paginated text (2000 lines / 50 KB / 2000 chars per line) or image reading (32 MiB input cap) |
edit | Serialized per path | Atomic edits[] & replaceAll (exact/fuzzy match), preserving BOM and CRLF/LF |
write | Serialized per path | Creates or overwrites files and parent dirs (re-read or edit required after compaction) |
bash | Parallel | Runs shell commands (120s default / 600s max); 400-line / 20 KB summary, raw bytes spilled to temp file; 128 + sig on signals |
grep | Parallel (dormant) | Prefers $MIZAR_HOME/bin/rg (auto-installed in TUI); .gitignore-aware, capped at 100 matches / 50 KB |
find | Parallel (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.jsonand<workspace>/.mizar/mcp.jsonover stdio or Streamable HTTP / SSE. Tools register asmcp__<server>__<tool>(defaultCodemode); when any server advertises resources,list_mcp_resources,list_mcp_resource_templates, andread_mcp_resourceare registered asDirect. Returned images flow throughmizar-image(max20per result). - Bridge Dynamic Tools (
mizar-bridge): Undermizar bridge, hosts dynamically register/unregister callback tools via JSON-RPCtools.register/tools.unregister(dispatched viatool.invoke) and manage per-session allowlists viatools.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
Five-Tier ToolExposure Model
| Tier | LLM Schema | Callable via codemode | Typical Tools & Behavior |
|---|---|---|---|
Direct | ✓ Yes | ✓ Yes | Core MinimalCoding tools, enabled grep/find, MCP resource tools |
ModelOnly | ✓ Yes | ✗ Disallowed | codemode, 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 | ✗ No | Matched 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 at2000lines /50 KB(spilling excess tomizar-codemode-*temp files), while image attachments pass through the outer reply. In mixed mode,codemodeschemas and<mcp_servers>stay byte-identical before and after background MCP handshakes. - Globals & Sandbox Limits: Embedded
rquickjsenforces256 MiBheap,1 MiBstack,workers = 2, and120,000 msdefault timeout (overridable via// @options: {"timeoutMs": ...}), with no Node, filesystem, network, timers, or Web APIs (URL,fetch, etc.). Built-ins includeALL_TOOLS,searchTools(),describeTool(),describeNamespace(), and transactionalstore()/load()(committed only on normalreturnorexit(), discarded on errors/timeouts/aborts);onlyMode: truehidesDirectdeclarations and lists local tools withininlineBudget(3000tokens). - Failure Recovery Summary: Errors, timeouts, and aborts exit immediately without blocking and put
Session storestatus,Nested callssummary (top 8 prioritized byunconfirmed/returned error), and boundedScript errorat 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:
- Argument & Allowlist Checks:
parse_tool_argumentsrejects malformed or non-object JSON instead of coercing to{}so the model retries in-turn; direct calls are also validated against the current step’srequest.toolsallowlist (without blocking nestedcodemodecalls). tools/pre-execute: RunsApprovalGatePlugin(prompting on non-readonly tools under--approve, including nested writes incodemode) andFileGuardTracker(requiring re-read before overwriting stale files; see Security & Approvals).tools/execute: DispatchesParallelvsSequentialexecution; same-pathwrite/editserialize viawith_file_mutation_queue, while distinct-file and read-only calls run in parallel.tools/post-execute: RunsRepeatToolGuardPluginto catch repeated failing calls and records per-toolduration_msinto 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)(--isolatedskips user roots) forSKILL.md(or root<name>.md), caching snapshots by size +mtimehash and invalidating immediately whenwrite/edittouches a skill path. - Catalog Injection (
<available_skills>): Whenreadorbashis declared and model-invocable skills exist,<system-reminder>injects<name>,<description>(500-char cap), and the absolute<location>path toSKILL.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 fullSKILL.mdbody and resource base directory directly into<skill_content>so the model acts immediately without an extraread(also selectable via/skillsin TUI).