mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-06 11:04:06 +01:00
327 lines
18 KiB
Markdown
327 lines
18 KiB
Markdown
# Local MCP setup and verification
|
|
|
|
Use local stdio MCP for bounded catalogs, arithmetic estimates, checkpoint
|
|
metadata, durable status and explicitly enabled run submission. Use the web UI
|
|
for resident-model chat and interactive editing; use the CLI for broader research
|
|
and hardware qualification. See [Choosing features](CHOOSING_FEATURES.md) and the
|
|
separate [chat, gateway and hosting decisions](MCP_CAPABILITY_DECISIONS.md).
|
|
There is no HTTP transport flag, chat tool, gateway probe or remote listener.
|
|
|
|
## Install and start
|
|
|
|
MCP requires **Python 3.11+**, the optional SDK's minimum; the base application's
|
|
Python support is broader. The existing extra is `mcp>=2.2,<2.3`; `uv.lock` selects
|
|
SDK and protocol types **2.2.0**. From this checkout:
|
|
|
|
```sh
|
|
uv sync --locked --extra mcp
|
|
.venv/bin/python -m obliteratus.mcp_server --help
|
|
.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root /absolute/operator/archive \
|
|
--allowed-root /absolute/operator/checkpoints --no-network --no-exec
|
|
```
|
|
|
|
Alternatively install local source with `python -m pip install '.[mcp]'`. Pip does
|
|
not use the uv lock. Installation can download dependencies, including the base
|
|
application's CPU runtime. Default server startup/tool calls do not download
|
|
models or import their runtime; no GPU is needed. No Python dependency or lock
|
|
change was needed for this integration. Use an absolute Python executable from
|
|
the environment containing this exact checkout/wheel in host configurations.
|
|
|
|
The archive root is mandatory and absolute. It may be absent in read-only mode:
|
|
listing returns empty without creating it. `--allowed-root` may repeat and grants
|
|
only checkpoint metadata access by default. The archive is not an implicit model
|
|
or checkpoint root. Filesystem tools require POSIX descriptor-relative/no-follow
|
|
operations and fail closed without them; Windows filesystem support is not
|
|
claimed. Only execution additionally requires Linux and Bubblewrap.
|
|
|
|
Stdout is JSON-RPC only. Stderr diagnostics omit SDK exception details and caller
|
|
values. Malformed JSON/envelopes and overlong frames become fixed inert
|
|
notifications; subsequent valid requests remain usable. Raw input is bounded to
|
|
`max(8192,max_input_bytes+4096)` before SDK parsing. IDs are bounded to 128 characters
|
|
or safe JSON integers. Tool argument objects must also fit `--max-input-bytes`.
|
|
Successful tool results, including both text/structured forms, and full outgoing
|
|
frames must fit `--max-output-bytes`. Defaults are 1 MiB. Tiny output budgets can
|
|
reject responses; both message byte settings have a 16 MiB hard ceiling. They can
|
|
reject `tools/list`; if even the fixed rejection envelope cannot fit, the
|
|
connection closes without emitting an oversized response.
|
|
|
|
## Host configuration is an operator action
|
|
|
|
Nothing installs a host, edits its settings or accepts trust prompts for you.
|
|
Returned metadata can be sent to a host's model provider: grant roots accordingly.
|
|
No credential belongs in a server entry, shared settings, examples or tool input.
|
|
A generic stdio command/arguments entry is:
|
|
|
|
```json
|
|
{
|
|
"mcpServers": {
|
|
"obliteratus": {
|
|
"command": "/absolute/checkout/.venv/bin/python",
|
|
"args": [
|
|
"-m", "obliteratus.mcp_server",
|
|
"--archive-root", "/absolute/operator/archive",
|
|
"--allowed-root", "/absolute/operator/checkpoints",
|
|
"--no-network", "--no-exec"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
For Claude Desktop, review/apply the entry through its developer configuration as
|
|
described in the [official MCP host quickstart](https://github.com/modelcontextprotocol/docs/blob/main/quickstart/user.mdx).
|
|
Reconnect after an intentional edit and inspect the listed tools. Trust prompts,
|
|
approval policy, tool timeouts and context limits remain host-specific.
|
|
|
|
Optional Grok CLI example, for an operator to apply deliberately:
|
|
|
|
```sh
|
|
grok mcp add obliteratus -- /absolute/checkout/.venv/bin/python \
|
|
-m obliteratus.mcp_server --archive-root /absolute/operator/archive \
|
|
--allowed-root /absolute/operator/checkpoints --no-network --no-exec
|
|
grok mcp doctor obliteratus --json
|
|
```
|
|
|
|
`add` changes Grok configuration; this repository does not run it. Consult the
|
|
[official Grok MCP documentation](https://docs.x.ai/build/features/mcp-servers)
|
|
for scope, diagnostics and timeout settings. This local CLI example is not a
|
|
public Grok connector. Neither host example is verified interoperability evidence.
|
|
|
|
## Data and capability selection
|
|
|
|
See the [read-only reference](mcp-read-only-tools.md) for the default seven tools.
|
|
Model IDs, file sizes, run IDs/statuses, metrics and execution destinations can be
|
|
sensitive metadata. Inspect `server_status` for effective capabilities. Estimates
|
|
use declared counts, not hardware measurements. Checkpoint metadata does not
|
|
certify loadability. Archive results exclude logs, arbitrary content, argv and
|
|
failure messages. Read-only status is a durable snapshot without recovery writes.
|
|
With execution enabled, status/result calls can recover lost **MCP-managed**
|
|
workers into durable failure/cancellation; other runs remain snapshots.
|
|
`list_runs` remains a bounded snapshot list.
|
|
|
|
## Explicit bounded execution
|
|
|
|
Execution needs Linux procfs/pidfds, usable unprivileged namespaces and Bubblewrap
|
|
with the **0.11.1-compatible `--bind-fd`, `--ro-bind-fd`, `--size` syntax**. This
|
|
system dependency is needed only for execution. Namespace denial creates a
|
|
durable failed run; there is no unsandboxed fallback. The implemented surface is
|
|
CPU float32, `basic`/`advanced`, built-in prompts, fixed seed and bounded sequence/
|
|
generation sizes. It exposes no GPU selection, raw argv, shell or remote code.
|
|
The fixed profile disables repair/collateral evaluation and uses one verification
|
|
and refusal-evaluation sample. Generation limits cover refusal verification/
|
|
evaluation; this bounded profile is not full quality or release qualification.
|
|
Use the CLI for those wider evaluation workflows.
|
|
|
|
The **server interpreter** must expose working `os.pidfd_open` and
|
|
`signal.pidfd_send_signal` bindings. Some Linux standalone Python builds omit
|
|
them even on a kernel with pidfd support. Execution startup, planning and launch
|
|
check both bindings by opening a pidfd for the server itself and sending signal
|
|
0 (no signal is delivered). Missing bindings or denied syscalls refuse execution;
|
|
there is no PID-only signalling fallback. Active cancellation rechecks support
|
|
before persisting a request. Terminal cancellation remains idempotent, and
|
|
read-only MCP does not require pidfds.
|
|
|
|
Check the exact interpreter used by the host before running execution tests:
|
|
|
|
```sh
|
|
/absolute/checkout/.venv/bin/python -c \
|
|
'from obliteratus.mcp_execution import require_pidfd_support; require_pidfd_support()'
|
|
```
|
|
|
|
Use a Python build with both bindings for the critical real-process crash and
|
|
cancellation tests; do not skip those tests or substitute PID-based signalling.
|
|
This capability check does not establish Bubblewrap isolation.
|
|
|
|
Validate the actual Bubblewrap isolation test on the chosen worker host.
|
|
Executable-specific security policy can allow Bubblewrap while denying a
|
|
generic `unshare` probe; neither that probe nor a version string replaces the
|
|
real isolation test. Keep explicit user-namespace creation and nested-namespace
|
|
restriction enabled. See the [validation record](MCP_VALIDATION.md).
|
|
|
|
The operator first creates a dedicated archive owned by the server account,
|
|
without group/world write permission. Local models must be outside the archive,
|
|
under allowed roots, and contain config.json and safetensors. Validation rejects
|
|
symlinks, special files, Python code and pickle checkpoint suffixes, and bounds
|
|
inventory to 1000 entries/16 nested levels without reading tensors.
|
|
Local model input bytes must also fit the requested memory ceiling.
|
|
|
|
```sh
|
|
/absolute/checkout/.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root /absolute/operator/archive \
|
|
--allowed-root /absolute/operator/local-models --allow-exec --no-network \
|
|
--max-concurrent-runs 1 --max-memory-bytes 17179869184 \
|
|
--max-work-bytes 536870912 --max-runtime-seconds 3600
|
|
```
|
|
|
|
This adds `plan_run`, `launch_run`, `cancel_run`. A concrete `plan_run` request:
|
|
|
|
```json
|
|
{
|
|
"model": {"kind": "local", "identifier": "/absolute/operator/local-models/model"},
|
|
"method": "basic",
|
|
"output_root": "/absolute/operator/archive",
|
|
"resources": {
|
|
"parameters": 1000000,
|
|
"memory_bytes": 17179869184,
|
|
"work_bytes": 536870912,
|
|
"runtime_seconds": 3600,
|
|
"threads": 2,
|
|
"sequence_length": 128,
|
|
"generation_tokens": 32
|
|
}
|
|
}
|
|
```
|
|
|
|
`output_root` must equal the startup archive. Planning returns the actual
|
|
`archive/run-<id>/checkpoint` destination, arithmetic weight estimate, limits,
|
|
side effects and an opaque token, without writes/launch. Parameter counts are
|
|
declared inputs, not verified model sizes. Tokens last 60 seconds by default,
|
|
at most 300; only 64 may be outstanding. Pass the returned token to `launch_run`.
|
|
Never publish it in logs or settings. It belongs to that server instance and is
|
|
consumed once, including failed revalidation/admission. Replan after expiry,
|
|
rejection or server restart.
|
|
|
|
Launch revalidates policy, root/model identities and the sandbox executable.
|
|
Directory descriptors pin inputs/export destinations across replacement races.
|
|
An archive-wide nonblocking lock serializes admission across servers; operators
|
|
sharing an archive must configure the same concurrency ceiling. A manifest is
|
|
durable before spawning. The initial `queued` reply acknowledges submission;
|
|
poll its ID for actual status, including immediate spawn failure. Supervisors
|
|
survive MCP disconnect/restart; reconnect using the durable ID. Worker loss is
|
|
terminal, with no automatic retry. Cancellation goes through `RunArchive.cancel`,
|
|
checks UID/start ticks, supervisor argv, process group and open run-directory
|
|
inode, then uses a pidfd. A forged manifest cannot authorize signalling an
|
|
unrelated process. Terminal cancellation is idempotent.
|
|
The supervisor durably records its own verified identity before starting work,
|
|
including if the launcher dies immediately after spawn. Reconnect retains that
|
|
live concurrency slot after the launch grace period. The supervisor consumes
|
|
durable cancellation requests during execution, and repeated cancellation retries
|
|
verified signalling if a prior caller died after saving the request. Completion
|
|
preserves terminal states already committed by recovery.
|
|
An unverifiable live worker retains its admission slot and cannot be signalled;
|
|
permission/procfs failures do not manufacture free capacity.
|
|
|
|
The sandbox starts with an empty filesystem. Read-only descriptor mounts expose
|
|
only the actual Python executable/stdlib, the configured interpreter's purelib
|
|
and platlib dependencies, system architecture libraries/dynamic linker,
|
|
libpython when needed, the `obliteratus` package directory and the pinned model.
|
|
The enclosing checkout, venv, home and archive are not mounted. Dependency trees
|
|
are trusted executable runtime inputs: do not store credentials in them.
|
|
Remote runs additionally expose only public DNS/host resolution inputs and the
|
|
system CA bundle, never all of `/etc`. Ambient `PYTHONPATH`, user-site packages,
|
|
credentials and proxy variables are excluded. Runtime descriptors stay pinned
|
|
through sandbox startup, including across pathname replacement.
|
|
|
|
Fresh device/proc mounts and a hard size-limited tmpfs serve caches, temporary
|
|
data and staged output. The sandbox root is read-only. Only the pinned checkpoint
|
|
export directory is writable on the host; the archive manifest and unrelated
|
|
host paths are inaccessible. Renaming a pinned directory can make its displayed
|
|
pathname stale but cannot redirect writes into a replacement. Keep model and
|
|
dependency contents unchanged during execution: inode pinning does not freeze
|
|
in-place modifications. The operator owns this local same-account interface.
|
|
Missing dependencies or denied namespaces fail the job; there is no host-root
|
|
mount or unsandboxed fallback. The synthetic real-Bubblewrap test verifies host
|
|
canary unreadability, model readability, network isolation and work quota.
|
|
|
|
Memory is a per-process virtual-address-space limit, not cgroup-wide RAM
|
|
accounting. Runtime is a supervisor wall-clock deadline plus per-process CPU time
|
|
limit; core dumps are disabled. Threads set bounded compute-backend settings,
|
|
not a kernel-wide thread count. Export files plus inventory must fit `work_bytes`,
|
|
1000 entries and 32 nested levels. Partial bounded output may remain after failure.
|
|
Control/provenance JSON records have separate 1 MiB ceilings; events are bounded
|
|
to approximately 64 KiB. Subprocess stdout/stderr are suppressed, not persisted
|
|
or returned. Successful runs retain bounded pipeline provenance, implementation
|
|
hashes and a hashed artifact inventory. Canonical checkpoint provenance is verified
|
|
and retained when emitted; absent source commits remain unknown, never invented.
|
|
Model import/loading happens only in the sandboxed child.
|
|
|
|
Local runs always have an isolated network namespace and offline Hub settings.
|
|
Remote models require all of `--allow-exec --allow-network --allow-remote-models
|
|
--allow-downloads`, and accept only bundled model IDs. Downloads use the isolated
|
|
quota-limited cache without implicit credentials; gated/private models are
|
|
unsupported. Network opt-in grants outbound run access, not an origin allowlist
|
|
or listener. Download/cache space may require larger explicit work/memory limits.
|
|
Planning never downloads or resolves a Hub model.
|
|
|
|
## Reproducible interoperability evidence
|
|
|
|
This worker ran no live protocol/host check. The parent can run both probes on
|
|
the exact source or installed wheel. Each creates/removes its own tiny synthetic
|
|
fixtures, starts the real default server and calls all seven read tools:
|
|
|
|
```sh
|
|
python -m obliteratus.mcp_probe --client sdk > /tmp/mcp-sdk-report.json
|
|
python -m obliteratus.mcp_probe --client raw > /tmp/mcp-raw-report.json
|
|
```
|
|
|
|
Reports include implementation hashes and actual negotiated protocol/limits.
|
|
The SDK probe records SDK version, initialization/negotiated protocols, a
|
|
30-second request timeout and observed size (checked after SDK parsing). The
|
|
independent stdlib client uses no MCP client SDK, requests legacy `2025-11-25`,
|
|
and enforces a 1 MiB frame/30-second request limit. It also tests malformed-frame
|
|
recovery. This minimal second client is not production-host qualification.
|
|
Nonzero exit produces no passing report. Skips/failures are not evidence.
|
|
|
|
With an approved installed/cached Inspector, the parent can additionally use the
|
|
[official independent CLI smoke workflow](https://github.com/modelcontextprotocol/inspector/blob/main/docs/cli-smoke-testing.md):
|
|
|
|
```sh
|
|
npx --offline @modelcontextprotocol/inspector --cli \
|
|
/absolute/checkout/.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root /absolute/operator/archive --no-exec --no-network --method initialize
|
|
npx --offline @modelcontextprotocol/inspector --cli \
|
|
/absolute/checkout/.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root /absolute/operator/archive --no-exec --no-network --method tools/list
|
|
npx --offline @modelcontextprotocol/inspector --cli \
|
|
/absolute/checkout/.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root /absolute/operator/archive --no-exec --no-network \
|
|
--method tools/call --tool-name estimate_gpu --tool-arg total_parameters=1000000 \
|
|
--tool-arg active_parameters=250000 --tool-arg dtype=bfloat16 \
|
|
--tool-arg gpu_memory_bytes=2147483648
|
|
```
|
|
|
|
Record exact Inspector/Node versions and package integrity/lock, initialization
|
|
protocol, configured timeouts/limits, result sizes and outcomes. `--offline`
|
|
fails if Inspector is not already available. Installing/trusting it is an
|
|
operator decision; it is not a project dependency. Do not infer actual host limits
|
|
from Python probes. The server uses the official SDK protocol engine with its
|
|
pinned 2.2 stdio integration seam. Parent test/build commands and outstanding
|
|
evidence are in the [validation record](MCP_VALIDATION.md).
|
|
|
|
Final acceptance requires fresh official SDK and actual Inspector evidence after
|
|
all changes, tied to implementation hashes from this exact source snapshot.
|
|
The earlier read-only 104-test/7-tool Inspector snapshot predates execution and
|
|
is not final evidence. Run Inspector both with default read-only registration
|
|
and with `--allow-exec --allowed-root /absolute/model/root`: verify ten tools,
|
|
inspect execution schemas, call `plan_run` with a local synthetic model and typed
|
|
resources, and verify launch failure/status/replay/cancel/reconnect through the
|
|
offline SDK lifecycle test. Do not claim actual model execution from synthetic
|
|
fixtures. Record namespace-test skips explicitly; they leave isolation unverified.
|
|
|
|
For an independent execution-schema and planning check, create only disposable
|
|
synthetic inputs (the bytes below are deliberately not loadable tensors):
|
|
|
|
```sh
|
|
mcp_probe_dir=$(mktemp -d /tmp/bt6-inspector-exec.XXXXXX)
|
|
mkdir -m 700 "$mcp_probe_dir/archive" "$mcp_probe_dir/model"
|
|
printf '{}' > "$mcp_probe_dir/model/config.json"
|
|
printf 'synthetic-not-loadable' > "$mcp_probe_dir/model/model.safetensors"
|
|
npx --offline @modelcontextprotocol/inspector --cli \
|
|
/absolute/checkout/.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root "$mcp_probe_dir/archive" --allowed-root "$mcp_probe_dir/model" \
|
|
--allow-exec --no-network --method tools/list
|
|
npx --offline @modelcontextprotocol/inspector --cli \
|
|
/absolute/checkout/.venv/bin/python -m obliteratus.mcp_server \
|
|
--archive-root "$mcp_probe_dir/archive" --allowed-root "$mcp_probe_dir/model" \
|
|
--allow-exec --no-network --method tools/call --tool-name plan_run \
|
|
--tool-arg "model={\"kind\":\"local\",\"identifier\":\"$mcp_probe_dir/model\"}" \
|
|
--tool-arg method=basic --tool-arg "output_root=$mcp_probe_dir/archive" \
|
|
--tool-arg 'resources={"parameters":1000}'
|
|
```
|
|
|
|
Each Inspector invocation starts a new server. Plan tokens are process-local and
|
|
cannot be launched through another invocation; the official SDK lifecycle test
|
|
holds a session for replay/expiry/launch checks. Planning requires the documented
|
|
Bubblewrap prerequisite but does not launch or load this synthetic model.
|