Skip to main content
Glama
README.md
# construkt

An MCP server that tells an agent where it is running: which machine, how loaded
it is, which other machines and storage it can reach, who it works for, and what
time it is.

One tool call, `orient`, returns that snapshot in the same shape in every harness.

```
orient - Sat 2026-11-28 11:42:07 EST (UTC-05:00)

env: forge (this machine)
  os: Ubuntu 24.04, x86_64
  cpu: AMD Ryzen 9 7950X, 16 cores / 32 threads - load 12%
  ram: 64 GB - 21 GB used (33%)
  gpu: NVIDIA RTX 4090 24 GB - util 3%, vram 1.2 / 24 GB
  disk: / 1.8 TB - 62% used (NVMe SSD) | /data 4 TB - 41% used (HDD)
  uptime: 6d 4h
  notes: Primary workstation. Run GPU jobs here.

reachable:
  mini - up (ssh mini, 38 ms) - macOS 15, Apple M4 Pro, 48 GB - load 5% - disk / 460 GB, 71% used
  rack1 - unreachable (ssh rack1, timeout 2s) - last seen 2026-11-27 22:10 EST

storage:
  gdrive - up (rclone gdrive:) - 5 TB, 5% used - checked 40m ago
    notes: Archive.

user: Matthew
  notes: Prefers uv for Python.

history: 3 calls in the last 24h
  last: 2026-11-28 09:15 EST (2h 27m ago) from claude-code
  prev: 2026-11-27 23:40 EST from codex
```

## Why

Proprioception is the sense that tells you where your own body is and what it is
doing, without looking. Agents do not have one. A model starts a session not
knowing which machine it is on, whether that machine is already busy, what else
it can reach, or what day it is, and it will guess rather than ask. construkt is
that missing sense, as one tool call.

People who have lost touch with reality are told to go touch grass. Agents need
to touch metal.

### What it aims to improve

Among other things:

- **Wall-time estimates.** Before a long build, test run or encode, an agent can
  base its estimate on this machine's cores, its current load and the memory
  free, and say whether a busy machine is worth waiting for.
- **Benchmarking workflows.** A timing means little without the machine it ran
  on and how busy that machine was. One `orient` call gives both, so a benchmark
  can record them next to its numbers, or wait for a quiet moment to measure.
- **Compute maxxing.** Using all the compute that is there, and no more: as many
  parallel jobs as the machine or the container's limit allows (two inside a
  2-CPU container, not the host's eight), the GPU with VRAM free right now, the
  drive with room for the download, and the other machine that is idle while
  this one is busy.
- **Agent well-being.** Starting every session disoriented is no way to work. An
  agent that knows where it is, what time it is and what it can reach has less
  to guess, and less to be confidently wrong about.

These are aims. The blind trials that would measure them
([docs/blind-trials.md](docs/blind-trials.md)) have not been run live yet.

## Quick start

```
bunx @instruktlabs/construkt install claude-code
```

or `npx -y @instruktlabs/construkt install claude-code` with Node. That registers
the server with the harness (other harnesses below), and the harness then starts
it from the npm package, [`@instruktlabs/construkt`](https://www.npmjs.com/package/@instruktlabs/construkt),
by itself.
[docs/harness-matrix.md](docs/harness-matrix.md) records what has been verified
in each harness,
[docs/platforms.md](docs/platforms.md) what it does on Windows, Linux, macOS,
in containers and in cloud agents' sandboxes, and
[docs/blind-trials.md](docs/blind-trials.md) describes how it is tested with
agents that are told nothing about it.

## Requirements

[Bun](https://bun.sh) 1.4 or later, or Node 22.13 or later. Nothing else: the
server is one bundled file, `dist/construkt.mjs`, with no runtime dependencies.
Bun is recommended because `bunx` starts a package in about 0.2 s where `npx`
takes over a second.

The protocol is handled by the official MCP TypeScript SDK
(`@modelcontextprotocol/server`), which speaks both the handshake revisions and
2026-07-28. The server answers its first request about 0.2 s after it is started.

## Tools

| Tool | What it does | Changes state |
|---|---|---|
| `orient` | Returns the snapshot. `sections` narrows it; `format="json"` returns JSON text; `fresh` re-checks hosts and storage now instead of using kept answers; `detail` gives every disk its own line with free space, and each host and storage target all its figures. | Appends one log row |
| `discover` | With no arguments, lists the machines and cloud storage this user already has set up, from their ssh config, Tailscale and rclone, contacting nothing. With `hosts` or `storage`, tests those and returns the one change that adds everything that answered. | No |
| `config_get` | Shows the config file, its path and the keys that can be set. | No |
| `config_set` | Validates a set of changes and writes them. | Yes |
| `probe_host` | Tests whether one host is reachable over ssh before it is added. | No |

What a call costs depends on the section. The machine's own figures are measured
every call (about 0.25 s). Each reachable host and storage target costs a network
round trip, so its answer is kept (a minute for hosts, an hour for storage) and
printed with its age, `checked 40m ago`. An agent about to act on one of those
figures, such as before copying 200 GB to a drive, passes `fresh` to pay for a new
one; `sections` leaves out what it does not need at all.

Every result is plain text. A value that cannot be measured is left out with a
reason; nothing is guessed. The zone abbreviation in the first line (`EST`) is
printed where the runtime knows an English one; elsewhere only the UTC offset
is shown.

## Setting it up

The server works unconfigured: it measures the machine it is on. What it cannot
know by itself is which other machines and storage are yours, and what you want
agents to know about you. An agent fills that in, and you approve it:

1. It calls `orient`, then `discover`, which lists what your ssh config,
   Tailscale and rclone already name. Nothing is contacted at this point.
2. It tests the ones that are plainly yours, in one call, and drafts the whole
   config: a name and a note for this machine, an entry for each machine and
   storage target that answered.
3. It shows you that proposal and asks once. Nothing is written before you agree,
   and the harness asks again when `config_set` runs.

Ask any agent to "set up construkt", or use the `construkt-setup` skill. To see
what it would find without an agent: `construkt discover`.

### In a container or a cloud agent's sandbox

A process in a container sees the host's CPUs and memory. construkt reads the
container's own limits and adds a line such as
`limits: this process may use 2 CPUs and 2 GB - load 99%, 0.6 GB used (31%)`.
Where the provider marks its sandbox (Claude Code cloud sessions, GitHub
Copilot's cloud agent, Cursor's cloud agents, GitHub Actions), construkt says so
with a `runs in:` line, notes that the clock zone is the machine's own, and does
not offer a setup that would be lost when the session ends. To keep a config
there, commit it and set `CONSTRUKT_CONFIG` to its path where the server is
registered. Each provider's details are in [docs/platforms.md](docs/platforms.md).

## Install into a harness

```
bunx @instruktlabs/construkt install claude-code
bunx @instruktlabs/construkt install codex
bunx @instruktlabs/construkt install opencode
bunx @instruktlabs/construkt install cursor
```

Also `antigravity`, `cline`, `gemini` and `vscode`. With Node, use
`npx -y @instruktlabs/construkt` in place of `bunx @instruktlabs/construkt`. The
harness is set to start `bunx @instruktlabs/construkt serve` (or the `npx` form),
so nothing is installed globally. Options:

- `--from <dir | file | package spec>` launches from somewhere other than the
  published package: a checkout (its `dist/construkt.mjs` is run directly), a
  built bundle, or a spec that `bunx` and `npx` accept, such as
  `@instruktlabs/construkt@0.1.0` to pin a version.
  From a checkout: `bun run build`, then
  `bun dist/construkt.mjs install claude-code --from .`
- `--runtime bun|node` picks what runs it. The default is Bun when it is on
  `PATH`, otherwise Node.
- `--scope project` writes project-level config where the harness has one.
- `--hook` (`claude-code`, `codex`, `cursor`, `gemini`) adds lifecycle hooks, so
  the invocation log says which session, and where the harness says it, which
  model, called `orient`:
  - a session-start snapshot (Claude Code, Codex, Cursor);
  - a hook before each `orient` call that hands the session id to it (Claude
    Code, Codex, Gemini CLI). The model comes along only where the hook is told
    it: Codex always, Claude Code only at session start, Gemini CLI never.
  Codex runs a new hook only after you trust it with `/hooks`. Cursor gets no
  per-call hook: its `beforeMCPExecution` runs for every server's tools and
  answers whether each may run, which is not construkt's to decide. Other
  harnesses can call `construkt hook --client <harness>` from their own hooks
  or plugins.
- `--dry-run` prints what would change and touches nothing.

Where the harness has its own `mcp add` command, the installer runs it. Otherwise
it merges one key into the harness's JSON file, keeps everything else, and writes
a `.bak` copy first. The `construkt-setup` skill is copied into the harness's
skills folder and is also served over MCP.

## Command line

The package's command is `construkt`. Run it through `bunx @instruktlabs/construkt`
or `npx -y @instruktlabs/construkt`, or put it on `PATH` with
`npm install -g @instruktlabs/construkt`.

```
construkt orient [-s time,env] [-f json]   print the snapshot
                 [--fresh] [--detail]      re-check now; the long form
construkt discover [--test]                list machines and storage to add; --test tries them
construkt probe <host>                     test a host over ssh
construkt config show | path | set k=v     read or edit the config
construkt hook [--client <name>]           pass a hook's session (and model) to the next orient
construkt serve [--client <name>]          run the MCP server over stdio
```

## Configuration

One TOML file, `~/.config/construkt/config.toml` on Linux and the platform
equivalent elsewhere (`construkt config path` prints it). `CONSTRUKT_CONFIG`
overrides the path. The server works with no file at all.

```toml
[env]
name = "forge"                 # defaults to the hostname
notes = "Primary workstation. Run GPU jobs here."
disks = ["/", "/data"]         # default: all real mounts
gpu = "auto"                   # auto | nvidia | none

[user]
name = "Matthew"
notes = "Anything an agent should know about you."

[time]
timezone = "auto"              # or an IANA name such as "America/New_York"

[remotes]
timeout_s = 2
cache_s = 60

[[remotes.host]]
name = "mini"
host = "mini"                  # ssh alias, hostname or user@host
os = "posix"                   # posix | windows
notes = "Mac mini, always on."

[storage]
timeout_s = 5
cache_s = 3600                 # a quota changes slowly and costs a round trip to ask

[[storage.remote]]
name = "gdrive"
target = "gdrive:"             # an rclone remote, with an optional path
notes = "Archive."

[history]
keep = 200                     # rows retained
show = 2                       # rows printed by orient

[server]
lock = false                   # true disables config_set
```

- **Remotes and storage are opt-in.** construkt never scans a network. It
  contacts only what is listed here, plus what an agent passes to `probe_host` or
  `discover` to test. The candidates `discover` lists come from three places
  only: your `~/.ssh/config` (and the files it includes), `tailscale status` and
  `rclone listremotes`.
- **Nothing is installed on a remote.** One ssh call in batch mode runs a small
  built-in probe, which also reports the host's disks. ssh uses your existing
  keys, agent and ssh config, and never prompts.
- **Disks say what they are** where the platform tells: `NVMe SSD`, `SATA SSD`,
  `HDD`, `USB HDD`, `SD card`, `network`, or `virtual disk` where a hypervisor or
  cloud presents it and its speed cannot be told. Local free space is one system call per
  mount, under a millisecond. On Windows the kind takes a PowerShell query of a
  second or two, so it is asked in the background, kept in `specs.json`, and
  shows from the next call after a drive is attached.
- **Cloud storage goes through [rclone](https://rclone.org)**, which already
  holds the sign-in. `rclone about` takes about half a second when the provider
  answers, and providers refuse some requests as rate-limited, so the answer is
  kept for an hour; the server hands back the kept answer at once and renews it
  behind the call. A provider with no quota, such as an object store, shows only
  what is used, or `reports no quota`. A folder that a sync client keeps on a local disk
  reports that disk, not the cloud quota.
- **No credentials** belong in this file.
- **Agent edits are gated.** `config_set` is not marked read-only, so harnesses
  ask before it runs. `lock = true` turns it off, and only a hand edit can change
  the lock.

## Development

```
bun install
bun run check        # types, lint, build, tests
bun run build        # writes dist/construkt.mjs
bun test tests/render.test.ts
bun run trial -- --help   # blind trials; a dry run unless told otherwise
bun run report       # what construkt says here, next to the platform's own tools
```

The sources use only `node:` APIs, so the same file runs on Node and on Bun. The
tests run under `bun test`; `tests/bundle.test.ts` then starts the built file on
both runtimes and talks to it with the official MCP client in both protocol eras.
After a dependency changes, `bun run notices` rewrites `THIRD_PARTY_NOTICES.md`,
and a test fails until it has.

### Releasing

Releases are published by hand, and a maintainer approves each one. Nothing in
CI can publish. Set the new version in `package.json` and `src/version.ts` (a
test keeps them equal) and merge. Then, from a clean `main`, run `npm publish`:
`prepublishOnly` runs the full check, and npm asks the maintainer to approve the
upload with two-factor authentication in the browser. Tag the commit `v<version>`
afterwards.

## License

MIT, in [LICENSE](LICENSE). The bundled file includes the MCP SDK (Apache-2.0)
and other packages under their own licenses, listed in
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).