Files
OBLITERATUS/docs/mcp-read-only-tools.md
Joseph Magly 002e6e56e1 feat: complete local readiness across UI, MCP and memory admission
Integrate bounded admission, UI ownership and controls, opt-in durable MCP execution, rank-local TP2 groundwork, regression hardening and operator guides. Physical larger-memory and two-host qualification remain separate.
2026-10-20 17:58:20 -04:00

9.3 KiB
Raw Permalink Blame History

Local MCP read-only tools

This describes the implemented #210 tools, including a bounded checkpoint descriptor with explicit verification limits described below. These tools need no GPU, model download, Hub access, gateway, or running experiment. The MCP interface uses stdio. Existing browser UI users can keep using the browser workflow; these tools expose local metadata to an MCP caller and do not add browser controls.

Only grant roots whose metadata you intend to expose to the caller. An explicit archive root is required; checkpoint access additionally requires explicit --allowed-root entries. The archive root is not implicitly a checkpoint root. A missing archive stays absent and lists as empty. Tools do not create it. Filesystem reads require descriptor-relative POSIX operations with O_NOFOLLOW; platforms without these primitives fail closed on filesystem tools.

Tool Inputs Returned information
server_status none Package version and effective capability list
list_catalog kind: model, study, strategy; offset=0, limit=50 Bundled identifiers/names, total, next offset; lexicographic identifier order
estimate_gpu total_parameters, optional active_parameters, dtype, gpu_memory_bytes, copies, overhead/reserve assumptions Resident/active weight bytes, assumed GPU requirement, declared capacity and budget comparison; units and exclusions
inspect_checkpoint absolute local path within an allowed root Typed bounded descriptor: counts, component/primary format labels, recognized model configuration, trust and verification limits
list_runs offset=0, limit=50 Archived run IDs, durable status, terminal-result availability, total, next offset
get_run_status run_id Durable status and terminal-result availability
get_run_result terminal run_id Status plus allowlisted finite numeric metrics

Pages accept integer offsets 0–1000 and limits 1–100. There is no arbitrary search expression or executable strategy input. Catalog entries are a bundled snapshot of the curated presets, checked against their source definitions by an offline test. The dynamic Bestiary refresh is excluded. Strategy identifiers are the four built-in strategies without importing their model runtime implementations.

Parameter counts must be finite positive whole numbers no larger than 10^13. active_parameters defaults to total and cannot exceed it. Dtypes are float32 (32 bits), float16/bfloat16 (16), int8 (8), int4 (4); default float16. copies is an integer 1–16. GPU capacity is optional: supply a positive whole gpu_memory_bytes up to 1 TiB; omitted capacity produces fits_budget=null. Memory units are bytes; one GiB is 2^30 bytes. No model identity is resolved and no hardware or free memory is probed.

weight_bytes=ceil(total_parameters*bits/8) includes all MoE experts. active_weight_bytes=ceil(active_parameters*bits/8) is diagnostic only; inactive experts are not subtracted from residency. estimated_bytes=weight_bytes*copies retains the old weight-only result. The GPU budget is required_gpu_bytes=ceil(estimated_bytes*(1+overhead_fraction))+reserve_bytes. Overhead defaults to 0.2 (allowed finite range 0–4); reserve defaults to 1 GiB (allowed whole-byte range 0–1 TiB). Decimal rational arithmetic avoids rounding down the required bytes. fits_budget compares this requirement with declared capacity; required_gpu_gib provides the same requirement in GiB. These assumptions do not explicitly size KV cache, activations, optimizer or training state, workspace or quantization metadata. A positive comparison is not a runtime/admission guarantee.

For example, total_parameters=8000000000, active_parameters=2000000000, dtype=bfloat16, gpu_memory_bytes=17179869184, overhead_fraction=0.25 and default reserve require 21,073,741,824 bytes, exceeding the declared 16 GiB. Legacy parameters aliases total (supplying both is rejected), and bits can select the dtype. Conflicting dtype/bits are rejected.

Checkpoint inspection calls CheckpointService.inspect(mode='bounded_metadata'). It returns schema obliteratus.mcp.checkpoint-descriptor, version 1, with counts, primary_format (safetensors, pytorch_pickle, mixed, unknown), typed components, and optional recognized model configuration. Format labels are filename classifications; pickle components explicitly require trust. Only a root config.json may be opened, bounded to the smaller of 16 KiB and the input budget. It returns only portable model_type, recognized dtype, positive integer hidden_size and num_hidden_layers (at most 10^9). Unknown configuration fields are discarded; duplicate keys, nonfinite constants, malformed/oversized JSON are rejected. No tensor headers, tensor payloads or arbitrary file contents are opened. Descriptor fields explicitly report payloads_read=false, tensor_headers_read=false, integrity_verified=false, loadability_verified=false and support_decision=not_assessed. A regular file or directory is accepted; links, hardlinks, special files, parent traversal and symlinked ancestors are rejected. The bounded inventory permits at most 1000 files, 100 directories, 32 nested directory levels and 1 TiB of apparent file sizes. File names and arbitrary content are not returned. Descriptor-relative directory traversal prevents a pathname replacement from redirecting a read through a symlink.

The default full CheckpointService.inspect performs SHA-256 inventory and revalidation passes over every regular file, including .safetensors, pickle checkpoints and unrecognized files. Calling it would violate the no-payload/arbitrary-content read contract even if its response were truncated. MCP therefore uses its separate no-payload mode with descriptor-relative anchoring and a distinct schema. It does not claim the payload hashes, tensor structure or integrity checks of the full descriptor. inspect_metadata remains available to other Python callers requiring counts without even recognized configuration reads.

Archive IDs must exactly match run- followed by 32 lowercase hexadecimal digits; the manifest ID must match its containing directory. Archive reads open only the fixed manifest.json using no-follow descriptors, bounded to the smaller of 1 MiB and the configured input budget. Listing scans at most 1000 directory entries before sorting; larger archives are rejected. Invalid selected manifests reject the request. Listing order is by run ID, not chronological time.

States are snapshots of committed manifests. A disconnected or vanished worker can leave a stale running status: these tools never inspect processes or perform recovery writes. Terminal states are succeeded, failed, and cancelled; get_run_result rejects other states. Result metrics are limited to numeric perplexity, refusal_rate, accuracy, and kl_divergence with absolute value at most 10^100. Paths, argv, notes, logs, worker IDs, failure text, software inventories, arbitrary metric keys and provenance contents are excluded.

Tool argument objects (including tool name) are checked against --max-input-bytes before SDK argument conversion. Successful SDK tool results, including both text and structured forms, must fit --max-output-bytes; oversized results are rejected rather than silently truncated. The stdio adapter also bounds raw input before SDK parsing and bounds outgoing frames. Rejections use a fixed short message without caller values, filesystem paths, or exception contents. If the minimum error envelope cannot fit, the connection closes without emitting an oversized frame. Page limits and metadata inventory limits apply even when the operator raises byte budgets.

The default tools advertise read-only, idempotent, non-destructive, closed-world hints backed by their behavior. Execution tools are registered only with explicit --allow-exec; their hints describe their different semantics. See setup and bounded execution for policy and durable plan/launch/cancel behavior. Default startup still registers only read tools and never creates archives, launches, downloads, loads tensors or probes a gateway.

The #209 foundation audit found lazy optional SDK import, stdio startup, immutable policy and explicit lexical roots already present. It also found only the status tool registered, unused byte-budget settings, and capability flags reporting preferences rather than implemented authority. #210 adds actual read boundaries and reports effective capabilities. Legacy RunArchive.status() can recover and write state, so default MCP uses separate read_snapshot()/read_ids() methods and a read_only=True instance that refuses legacy path access. Ordinary archive creation and execution callers retain their existing behavior.

Offline contracts live in tests/test_mcp_read_tools.py, alongside the foundation, archive and checkpoint service suites. SDK annotations and subclass tool dispatch follow the installed 2.2 source/docstrings; the public SDK tool API reference provides additional context. Runtime validation evidence and any unavailable external checks are recorded in the validation record. Its claims apply only to the named implementation, clients and tested modes.