TEHAS

The MCP server

Agents outside this host, such as Hermes or OpenClaw agents, can ask a factory how it is doing over MCP: whether it is working, what is in line, what ended, a running cycle's console and the last ten days, as the dashboard shows them, one issue's story, and the sessions of the last 30 days and their logs, masked, the lines of those logs that hold a string you give, the dispatcher's and refresh's events as they are written, why an issue's last stopped run stopped, and the dispatcher's last decisions. With a shared checkout, it also gives the product's git history: its log, a commit and its diff, and who last changed each line. See what it shows. The server is read only. No tool changes anything; pause, limit, drain, labels and retries stay with a person on the host, through the factory API.

It is off until you switch it on, and it answers only a request that carries one of your keys.

What it shows

The two kinds of key

A key holder sees the public dashboard's data, plus the sessions of the last 30 days and their logs, masked. A request without a key sees nothing.

Which tools a key may call is decided by the list it stands in, and by nothing else:

Setting Called May call
TEHAS_MCP_KEYS full every tool of the table
TEHAS_MCP_DASHBOARD_KEYS dashboard the four that copy from live/: factory_status, factory_issues, factory_endings, factory_stats, and factory_contractors while outsource is on

A dashboard key is for a program that shows the factory and must not read the logs: the sessions of the last 30 days, the lines of their logs and the dispatcher's and refresh's events are the private half of what the server holds, and those four tools name none of them. A dashboard key that asks for another tool gets what the server gives any name it does not serve, the same words a full key gets for a name that is no tool: the scope is no secret, and a caller that cannot tell the four from the rest learns nothing it should not know.

The scope is the program's, not the container's. The server is one process given the same three directories whatever the two lists hold, so a dashboard key is kept out of the sessions and the logs by the tools it may call, not by a mount of its own.

The key is the boundary, not the dashboard. Its inputs are three directories, each given to it read only:

With TEHAS_MCP_CHECKOUT set, it reads a fourth: the shared checkout, read only.

It reads nothing else on the host and calls nothing: not GitHub, not Docker, not a model, and no git program. It reads the checkout itself. Each tool copies only the keys it names from those files. A key the files gain later is not served until a release names it.

On a factory that works on a private repository, a full key gives its holder that repository's code, issue text and model output as the agents saw them, in the logs. Give one only to someone who may read the repository. The four tools of a dashboard key copy the dashboard's own numbers and issue titles, which is what the dashboard publishes, and no log line: give one where the logs are what you would rather keep on the host. The mask takes out tokens, keys, passwords and private addresses it knows, but it is a net for accidents, not a wall.

Switching it on

  1. Make a key for each agent, on the host:

    tehas mcp key
    

    It prints a new key and writes nothing. A key reads the factory's logs: on a private repository, give one only to someone who may read it. A key of TEHAS_MCP_DASHBOARD_KEYS reads no log, so it is the one to give a program that only shows the factory.

  2. Put the switch and the keys in ~/.config/tehas/env, beside the host's other secrets, never in the instance directory, which is in a repository:

    TEHAS_MCP=1
    TEHAS_MCP_KEYS="<key> <key>"
    TEHAS_MCP_DASHBOARD_KEYS="<key>"
    

    Keys are separated by spaces, each at least 32 characters of A-Za-z0-9_-. At least one key stands in one list or the other, and no key stands in both: the scope of a key of both would be a guess. The server enforces both rules itself when it starts, so the check the tehas mcp command makes of the two settings is a fast reading of the same rules before it asks Docker for a container, and names the same line of the same shape. With TEHAS_MCP=1, a host with no key at all, a key that is not like that, or a key of both lists stops the server with exit 78 and one line that names the settings, never a key. TEHAS_MCP_DASHBOARD_KEYS may be left out, which leaves a server of full keys only, as it was. A line for either setting in instance.env is refused the same way. Both are host settings: a key that is not like that stops every command with 78 at the load, whether TEHAS_MCP is on or not, and the line names the key by its place.

  3. Start it, and have it start with the host:

    systemctl --user enable --now tehas-mcp.service
    

    install.sh installs the unit and never switches it on. tehas update restarts it when it is running.

  4. On the machine that publishes the dashboard, send /mcp to the host's port 8082, next to the dashboard's 8080. For Caddy:

    handle /mcp {
        request_body {
            max_size 64KB
        }
        reverse_proxy <host address>:8082
    }
    

    Rate limiting by address belongs there too: the server has none of its own. It serves /mcp only and answers any other path with 404. This page is at /mcp-server, so the route takes no page of the manual with it.

To remove a key, take it out of its list and run systemctl --user restart tehas-mcp.service. The journal names each request's key by the first 8 hex characters of its sha256, never by the key, so you can tell which agent is calling.

One line goes to the journal per request: the method, the status, the time it took, the key and that key's own scope, and for a tools/call the tool as well, as POST 200 4ms key=3511bfc5 scope=full tool=factory_log. The line goes to the unit's journal on the host, not to the client: read it with journalctl --user -u tehas-mcp. The name of the tool only: the arguments are never logged, as one can carry an issue number or text from a private repository. tool=? is a name the server does not have, which is what a probe of a tool it has not looks like. tool=- is a name that is not text, and only the 2025-11-25 handshake can carry one, as a modern request must mirror its name in Mcp-Name and no text equals a number: so a dash tells a client that is broken from one that is probing, except for a probe whose name never reached the server as text, which is a dash too. A request that is not a tools/call logs no tool=. scope= is the server's own word for the list the key was read from, full or dashboard; a request refused for want of a key has no key, and names neither field. The fields are the server's own words, never the client's text, so the line the unit writes stays one field per space-separated part: do not add a field to it without naming where its bytes come from.

How it runs

tehasbot mcp serve, run by tehas-mcp.service, checks the settings and runs the server, ~/tehas/libexec/tehas-mcp, in a container of its own. The container runs as the tehas user, not root, with a read-only root, no capabilities, no-new-privileges, 256 MB of memory and 64 processes. It is given ~/tehas/live, ~/tehas/mcp and ~/tehas/logs read only, the binary, both lists of keys as environment variables, the host's names to mask as arguments (names, not secrets), the salted sums of the host's secret values in TEHAS_MCP_MASK (not the values) and port 8082 on TEHAS_HOST_ADDR (the loopback address without it), and nothing else: no Docker socket, no SSH key, no token, nothing from ~/.config/tehas but the keys. With TEHAS_MCP_CHECKOUT set, it is also given that directory at /checkout and ~/tehas/run/mcp-fetch at /run/tehas/fetch, both read only, and --checkout /checkout --checkout-fetch /run/tehas/fetch/fetch.sock. It is on a network of its own, tehas-mcp, made without masquerade, so it cannot reach the internet; the host itself is still one hop away. The command makes the network, and refuses to start on a network of that name that lets the container out. Its image is the Caddy image the docs server runs, pinned by the same digest in versions.env; the binary is static and needs nothing from it. The command makes ~/tehas/mcp with mode 700 before it starts the container, so Docker never makes it as root.

tehas update restarts the unit when the server's binary changed. The command is part of the console, and a new console does not restart the unit: a change to the container's arguments reaches a running server at its next restart.

With TEHAS_MCP unset or 0 the command removes a container left running and exits 0, and the unit stays stopped.

The health file says whether the server answers, in checks.mcp: each run of tehasbot health sends it a POST /mcp with no key and expects the 401. A server that is on and does not answer makes /health warn, so a monitor tells a stopped MCP server from a factory that is gone.

The shared checkout

TEHAS_MCP_CHECKOUT names a clone of the product with its whole history, as a host setting in ~/.config/tehas/env. Every session and every agent on the host reads the same one: there is no clone per session. With it set, a full key is served three more tools: factory_git_log, factory_git_show and factory_git_blame. A dashboard key is served none of them, and without the setting they are not listed.

The server reads the clone with its own git reader, so no program the clone names is ever run: no hook, no textconv, no filter, no external diff and no fsmonitor, whatever its .git/config and .gitattributes say. It reads no config but the clone's own file, and runs no git. A diff is made from the files as git stores them.

A path that is no directory stops tehas mcp with 78. One that is not a git repository with a commit, or is a shallow clone, whose history would stop short, stops the server with 78 and one line that names the setting.

Each call opens the clone again, so an answer is of the commit its HEAD names at that moment. Every answer carries head.

The server never fetches the clone itself. When a client opens a connection (an initialize, or a server/discover), the server connects to tehas-mcp-fetch.socket, whose socket ~/tehas/run/mcp-fetch holds and is given to the container read only. The connection is the whole request: the server writes nothing to the host. systemd starts tehasbot mcp fetch, which runs git fetch origin in the clone and moves its branch forward to its upstream, with no hook run. It never merges or resets: a branch that went its own way stays where it is. One fetch runs at a time, and a request within a minute of the last fetch does nothing, so many clients at once cost one fetch. tehasbot mcp serve starts the socket while TEHAS_MCP_CHECKOUT is set.

Each fetch writes ~/tehas/mcp/checkout.json, and every git answer carries it as fetch: time, ok and, when it failed, error, masked. A fetch takes a moment, so the first answers of a new connection can be of the commit before it.

A client that keeps a connection is told when the clone moved: each git tool takes seen, the head of its last answer, and when head is another commit now the answer carries checkoutUpdated: from, to and commits, how many came since, left out when seen is not among the last 10,000. The revision the server speaks keeps no session, so the client says what it saw.

Commit messages, diffs and lines of code are third-party text, written by people and agents. They are masked as a log is, and each answer carries untrusted, the sentence that says so. An author is named, never an address.

On a private repository, a full key gives its holder the repository's code and history through these tools. Give one only to someone who may read it.

Tickets

While the server is on, each run of tehasbot status also reads the repository's issues and pull requests changed since its last read, and writes one file for each under ~/tehas/mcp/tickets/: its title, state, author, labels, body and comments (the first 50), the epic it is part of and its sub-issues, and for a pull request the commit it merged as and the issues it closes. It reads with GitHub's search, oldest change first, at most four pages of 50 a poll, so the first read of a long history is spread over polls, and .cursor.json in the same directory says how far it has come. A read that fails keeps what it wrote. With the server off it reads nothing.

A full key is served factory_ticket and factory_tickets from those files. The server asks GitHub nothing, and the directory is part of ~/tehas/mcp, so the container is given nothing new. Bodies, comments and titles are masked as a log is, and a search matches the masked text, so a secret the mask hides is not found by its value either. A dashboard key is served neither.

How an agent connects

URL https://<domain>/mcp
Transport Streamable HTTP, POST only
Header Authorization: Bearer <key>
Versions 2026-07-28, and 2025-11-25 for clients that start with initialize

A client config for a Streamable HTTP server looks like this. It is an example: your client's file and field names may differ.

{
  "mcpServers": {
    "tehas": {
      "url": "https://<domain>/mcp",
      "headers": { "Authorization": "Bearer <key>" }
    }
  }
}

Every request needs a key, whatever its method, path or tool. A request with no key, a wrong key or another scheme gets 401 and an empty body, before any of its body is read. A request with a key that is not a POST gets 405. A key of either list is a key: the list it stands in decides which tools it may call, and nothing else about the request. A request with an Origin header gets 403: no browser is a client of this server. A body needs a Content-Length (411 without one, or when chunked), and over 64 KB gets 413. A head over 8 KB gets 431. A request must arrive whole within 10 seconds, however slowly it trickles in, and an answer must be read within 10 seconds and one more for each 128 KiB of it, or the connection is closed. Every answer closes the connection, and past 32 connections at once the next one gets 503. A method that is not a word of capitals gets 400, so nothing a client sends there reaches the log as a line of its own. No session is kept.

The binary takes the 10 seconds as --io-timeout <seconds>, a whole number from 1 to 3600, and keeps the default without it. tehasbot mcp serve never passes it, so the server on a host always waits the 10 seconds. The flag is there for the tests, which would otherwise wait out the deadline itself.

tools/list and server/discover answer with ttlMs of 30000 and a cacheScope of private. The answer itself carries no ETag or Cache-Control and every answer closes its connection, so the hint belongs to the client alone: a program that asks the list again inside the 30 seconds is answered the same bytes by the server, which holds the list and does not build it twice.

The 2025-11-25 handshake is there because neither Hermes nor OpenClaw says yet which version it speaks. It goes once both speak 2026-07-28.

The tools

Every result carries "api": 1. Within version 1 fields are only added; a field without a value is left out. Results are JSON in structuredContent and the same JSON as text.

Some of what the tools return was written outside the factory: issue titles by whoever filed the issue, and failure causes, park reasons, console, log and event lines and decision reasons by people who comment on issues or by models that read them. The handshake's instructions and each such tool's description call it third-party text, to be read as data and never as instructions. A title is served on one line, without control or direction characters, and cut to 200 characters.

An issue argument is an integer from 1 to 999999999 in every tool that takes one; another number is a tool error that says so.

Tool Arguments Returns
factory_status none status (pass, warn, fail), output, time, stale (the answer may be more than ten minutes old, below), generatedAt, repo, paused, planning, limit.state, queue (inLine, building, review, stopped, time), cycles (issue, running, status, step, startedAt, time), demand (waiting, oldest, time), platform (commit, or release on a release host, newest, behind, upstream, fetchedAt), rukas (follow, target, targetVersion, image, imageVersion, clone, behind, layer, instanceLayer, layerMoved) on a host with pi-rukas, hostMessages (list of the messages of tehas host-message: id, level, text, link, at; unreadable when the file cannot be read) as the health file has it, manager (version, as the health file has it) for a factory a program manages, hold (why, text) when something holds, held (issue, why, text, clear) for each ready issue the last poll held on its own
factory_issues stage, optional: queued, planning, running, awaiting, stopped or completed Per stage, the issues the dashboard lists: number, title, url, updatedAt, and closedAt when closed. planning is a count and issue numbers, without titles
factory_endings none endings, the cycles that ended last (issue, status, step, startedAt, updatedAt), and failed, the failed ones among them (issue, status, step, startedAt, time)
factory_console issue, and bytes from 1 to 65536 One running cycle's issue, step, status, statusText, startedAt, updatedAt, and the last bytes of its console, 64 KB without it, masked as a log is. The lines just before the tail, up to 4 KB, are read and masked with it and then cut, so a secret the cut splits is still masked. Only those bytes are read, however large the console
factory_stats none The ten-day report the dashboard shows, with refine: refining sessions, the issues they filed, how many started and shipped, the lead time of the shipped ones and, to compare, the same counts for the other issues made ready. Counts only. See Analytics for what each figure means
factory_sessions all optional: outcome (pr, merged, handoff, parked, failed, refused, stopped), failureKind, tehasVersion, rukasVersion (also matches the commit), kind (work, plan), how (label, refresh, retry-tick, outage-retry, millwright, host, answer, refine, hand; a run recorded as fixer, the millwright's old name, is answered and found as millwright, and fixer is no filter), image (an image id sha256:<hex>, or its first 12 hex or more, with or without sha256:), issue, limit from 1 to 200 (50 without it), before The runs of the last 30 days, newest first, filters combined: id, kind, issue, attempt, how, started, ended, seconds, outcome, failedStep, failureKind, failureCause, parkReason, tehasVersion, rukasVersion, image and imageBuilt, and links to the issue and pull request (issueUrl, prUrl). next is the last id when more remain: pass it as before. A session of the snapshot that matched but has a field of another type than the schema names, or an outcome, kind or how outside its words, is left out, and leftOut counts the ones skipped while filling this page, not those of later pages. A version or failure kind is matched exactly. image is the sandbox image of the run, by its id, which names one build: for a work run the one its container started from, for a planning turn the one the image name pointed at as the turn started. imageBuilt is when that image was built, UTC. A run recorded before images were has neither. imageBuilt is left out when no run of that image recorded a build time, as when the image was gone from the host each time one of its runs ended
factory_session id, like work-12-1792485967 One run of the last 30 days: every figure of the session, its steps, its roles (model, provider, tokens), its logs as a word and a size in bytes (never a file name), filed for a planning session, and issueUrl and prUrl. A session whose snapshot line does not match the tool's schema is a tool error that names the session and the field
factory_log id or issue, file (a word below), optional gzip (false without it), and for a plain read offset (0 without it) and bytes from 1 to 1048576 (1 MiB without it) One log file of the session, masked. With issue, the logs of that issue's running cycle, which has no session yet: its id is work-<issue>-<startedAt>, and that id is taken too while the cycle runs, also before the sessions snapshot is first written. The id names the running cycle only: when the run ends it is a session with an id of its own, a little later than startedAt, so find it in factory_sessions by its issue. Its logs are the latest ones whose names carry a stamp from its start on; until the cycle writes its own, a log of an earlier run is not served for it. An issue with no running cycle, or a cycle the store marked lost, is a tool error. Plain: id, file, offset, text, and next, the offset of the rest, when more remains, and size when the read got to the end of the file. With gzip: true: the whole masked file compressed, as an embedded resource of type application/gzip at tehas://sessions/<id>/<file>.gz, and id, file, size and gzipBytes as the structured content
factory_search text (3 to 200 characters), one of issue or ids (at most 50 session ids), optional files (log words, all the session has without it) and limit from 1 to 200 matches (50 without it) The masked lines of the last 30 days that hold text, a fixed string and not a pattern, of one issue's sessions or of the sessions named: matches, each with id, file (a word below), offset in masked bytes (one to give factory_log) and line cut to 400 characters, and sessions, how many were read. days and stale as the session tools. When the reading stops early it gives next: the id, the file and the offset of the rest, which is where that session's log is read on from. See the logs
factory_issue issue, an integer from 1 to 999999999 One issue's story in one call: issue, issueUrl, stage (the first of queued, planning, running, awaiting, stopped or completed that lists it, left out when it is listed nowhere), title when the dashboard has it, running (step, status) while a cycle owns it (only a cycle that is running owns one, so a cycle the store has marked lost, or one that ended between publishes, puts nothing there and does not make the stage running), and attempts: every run of it of the last 30 days, oldest first, each with its id (the one to give factory_session or factory_log), kind, attempt, how, started, ended, seconds, outcome, failedStep, failureKind, failureCause, parkReason and prUrl. firstSeen and lastSeen are the started of the oldest and newest run, and outcome is the newest run's. An issue with no run in the window and no stage is a tool error that names it
factory_events all optional: after, the next of an earlier answer, and limit from 1 to 500 (100 without it) The events of dispatch.log and refresh.log, masked, oldest first: events, each with time, kind (below), issue when the line names one among its first words, log (dispatch or refresh) and text, the line after its time cut to 1000 characters. next is the cursor to pass as after, just past the last event returned. more is true when the call stopped early and more can be read now. gaps names a log that was replaced or truncated with nothing left of what was read: events of it may be missing. Without after, the last events. See following the factory
factory_failures all optional: by (version or image), rukasVersion (also matches the commit) The work runs of the last 30 days per tehas and pi-rukas version pair, the most runs first, an entry with either version unknown after every entry that names both: runs, outcomes and failureKinds as counts, outcomesUnknown for the runs with no outcome word on record, none or a word that is not one of the seven outcomes (outcomes holds only those seven), and causes, the five most common as cause, kind, count and up to ten issue links, newest first. With by: image each pair is split by the sandbox image its runs used, and an entry also has image and imageBuilt, so two builds of one pi-rukas version can be compared; runs with no image on record are an entry without them. Planning sessions are not counted
factory_outcomes all optional: tehasVersion, rukasVersion (both matched exactly), since and until (a day YYYY-MM-DD, or a full UTC time YYYY-MM-DDTHH:MM:SSZ), by (version or week) How the factory has done further back than 30 days, as far back as the analytics reaches: 365 days. by (version without it), days, generatedAt and stale, and entries: grouped by version, one per tehas and pi-rukas pair with tehasVersion, rukasVersion, runs, outcomes, failureKinds and parkReasons as counts, the most runs first; grouped by week, the same counts per week (the Monday that opens the UTC week), newest first. With since or until, a week entry whose week is missing or no date is kept, as no window can bound it, and carries unwindowed: true. A run is counted on its end, and one that never ended on its start. Counts only: no issue number, title, failure cause or log content
factory_park issue, an integer from 1 to 999999999 Why the issue's last stopped work run of the last 30 days stopped: a run whose outcome is handoff, parked, failed or refused. id, started, ended, outcome, status, exitCode, latest (no later work run of the issue in the window), latestOutcome when there is one (the outcome of the issue's newest work run, such as stopped for a run interrupted or whose issue closed under it, which is no park), and as the park comment's tehas:park marker has them step, kind (the failure kind), cap, reason (the park reason), cause, provider and sig, and forksRefused and oomKills when the container refused a start of a process or had one killed for memory. From the run's result log: result (read, none, gone or unreadable), errorCode and error when the runner itself stopped, such as a crash, message, causeClass, causeReason, userAction and checks, the failing check lines, masked, at most 20 of 400 characters each, with checksCut when there were more. days and stale as the session tools. An issue with no stopped run in the window is a tool error that names it
factory_decisions limit from 1 to 200, optional (50 without it) The dispatcher's last decisions, newest last: decisions, each with time, decision (start, skip, wait, hold, drop or finish; a hold is an issue the dispatcher keeps parked without starting it, such as one whose last cycle parked on the same text, or one whose attachment the model cannot read; a drop is a refresh request the dispatcher dropped; a finish is a finish ask the poll took, opened or refused, with who asked), issue as a number and reason as the dispatcher logs it, masked and cut to 400 characters; for a start the reason says who started it and how, and for a hold it says why the parked issue does not start. whole is true when the read reached the start of the log. They are the last limit lines of the log that hold start #, skip #, wait #, hold #, drop the refresh of # or finish # after the time. Only the last 1 MiB of the log is read
factory_disk none How full this host is and what fills it, as tehas disk --publish wrote it: time (when the answer was made), stale (the reading is more than three hours old, or its time cannot be read), and filesystems, one entry per file system the factory cares about - the instance's home, Docker's own directory, /tmp and TEHAS_SCRATCH_DIR when the instance sets one - each with paths (the role of each watched path that stands on it: home, docker, tmp or scratch), mount (df's name for it, such as overlay; left out when df named a device path or another host), freeBytes and totalBytes. A file system whose figure could not be read has none and carries why, with each path in it named by its role: no figure is never published as 0. With full, what fills them: places (biggest first, each path, its path under the instance's home or its name alone when it is outside the home, bytes and the cut the walk ran out of), docker (state and lines, what docker system df said, masked as a log is) and stoppedContainers, how many the daemon holds back. The file is written by tehas disk --publish, which the cleaner's tehas-clean.timer runs every hour after the clean (tehas disk), so on a host that runs the timer time is under an hour old; a person or a program can ask for a reading at any moment, and time says how old the answer is. No file is a tool error that says so, and so is one that is not a whole reading: of another api, or with no file system. The server asks the host's disk nothing: no df, no docker, no walk. See tehas disk
factory_git_log all optional: path (a path in the repository, relative to its top), grep (text the message holds, as given, 1 to 200 characters), limit from 1 to 200 (50 without it), after (a commit id, from next) Only with a shared checkout. The history from HEAD, newest first: commits, each with commit, parents, author (the name only), time, subject (cut to 200 characters) and body (cut to 4000) when it has one. With path, only the commits that changed it; a merge is listed only when it differs from every parent there. more is true when there is more, and next is the commit to pass as after. A walk stops after 20,000 commits, and next then says where to go on. head, fetch and untrusted; with seen (a commit id), checkoutUpdated when the clone moved since
factory_git_show commit, 7 to 40 lowercase hex digits Only with a shared checkout. One commit: its fields as factory_git_log gives them, files (each path and change: added, modified, deleted or renamed, at most 500) against its first parent, and diff, the unified diff with three lines of context, masked and cut at 64 KiB with cut: true. A binary file is Binary files differ. An id that names no commit, or more than one, is a tool error; a name such as HEAD~1 is refused. head, fetch and untrusted; with seen (a commit id), checkoutUpdated when the clone moved since
factory_git_blame path, and optional start and end (line numbers from 1) Only with a shared checkout. Which commit last changed each line of the file at HEAD, at most 400 lines from start: lines, each with line, commit and text (cut to 400 characters), commits, each commit once with its subject, author and time, and total, the file's lines. A file of more than 2 MiB, a binary file or a path that is no file is a tool error. head, fetch and untrusted; with seen (a commit id), checkoutUpdated when the clone moved since
factory_ticket number, an integer from 1 to 999999999 One issue or pull request as the last read left it (tickets): number, kind (issue or pull), title, url, state (open, closed or merged), stateReason, author, labels, createdAt, updatedAt, closedAt, mergedAt, body (masked, cut to 20,000 characters with bodyCut: true), comments (at most 50, each author, createdAt and body cut to 4000), commentsTotal, for an issue parent (its epic) and subIssues (number, title, state), for a pull request mergeCommit and closes, and readAt. readUpTo, the last change the reads have reached, and untrusted. A number not read yet is a tool error that says so
factory_tickets grep (2 to 200 characters, any case), and optional kind (issue or pull), state (open, closed or merged) and limit from 1 to 50 (20 without it) The tickets whose title, body or comments hold the text, newest change first: tickets, each with number, kind, state, title, updatedAt and in (title, body, comments). more when there are more, read, how many tickets were searched, readUpTo and untrusted
factory_contractors none Only while outsource is on: tehasbot mcp serve starts the server with --outsource then, and without it the tool is not listed and a call of it is an unknown tool. The contractors as live/contractors.json has them: time (when the factory wrote the list, at a poll), stale (more than ten minutes old, or no time that can be read), counts (how many contractors are idle, working, stopping, silent, resting, draining and revoked, and outsourced, how many cycles are on a contractor now) and contractors, each with name, status, issue (the issue of the job in its hand), lastSeenAt, jobsDone and jobsLost, and from its last report image (the sandbox image's id), rukas (the pi-rukas version the image is labelled with), memMb, diskKb (its free memory and disk) and reportedAt, each left out when it did not say. No address and no key. A dashboard key is served it. No file is a tool error that says so

The links are built from the repo the dashboard publishes, and only when it is owner/name. Without a valid repo a session has no links and a cause has no issues. The session tools read sessions.jsonl, which tehasbot status asks for on each poll and which analytics leaves alone when nothing a poll could answer for has changed (see Sessions); stale is true when it is more than ten minutes old. A session older than 30 days, or an id that is not in it, is a tool error.

A cycle's status, in factory_status, factory_endings, factory_console and factory_issue, is one of these words and no other: the runner's running, merged, handoff, aborted, interrupted and not-started; tehas's killed, stalled, timeout, stopped, closed, refused and lost; the store's end reasons parked and failed; and unknown. A word the live files hold that is not one of them, such as a word a newer runner says, is served as unknown. The schemas list the same words.

factory_status is built from three writes, and is as old as the oldest of them: time is when the health file was written, queue.time when the queue snapshot it counted queue from was written, and generatedAt when the snapshot served beside it was. The dispatcher writes them each poll, every two minutes, but a poll that cannot read GitHub still writes the health file, so a fresh time can sit beside counts from an older snapshot. stale is true when any of the three is more than ten minutes ago, and left out when none can be read. cycles comes from the health file and queue.building from the snapshot: a cycle that started after time is in neither, so a program that acts on a free slot or an idle issue checks these times first, or reads factory_events for starts since.

factory_status answers hold from live/dispatch.json, the poll's own report, which the dashboard publishes already: why is the one reason the poll gave (slice, disk, limit, red and the rest of its words) and text the line that says it. Both are copied from that file and nothing is added: the line is masked, then cut to 400 characters, so a cut never leaves part of a secret the mask would have known whole. The field is left out when the poll named no reason, which is how "nothing holds" is answered, and left out when the report is missing, unreadable or of another shape: the rest of the answer stands on its own, and a caller is not told the poll is not on record by a field that is not there. It is also left out when the report's time is more than ten minutes before the health file's, or cannot be read: a poll that ends before it weighs room, such as a paused one, does not rewrite the report, so its reason would be of a poll long gone.

held comes from the same file: the ready issues the poll held one by one while it had room, such as one whose last cycle parked and whose body has not changed since. Each has issue, why (parked), text and clear, what a person does to release it; the two lines are masked and cut as hold.text is. It is left out when the poll held none, or the report is too old for hold. A queue view should not show these issues as next.

factory_outcomes reads outcomes.jsonl from the same directory, which tehasbot status asks for on each poll from analytics outcomes, and which is left alone the same way; stale is true when it is more than a day old, the writer being a daily one. The file is the whole of the analytics retention, and days is what the file itself says that reach is, so the tool answers where the 30-day tools cannot: whether a release changed the park or failure rates, and how often a failure kind comes back. It holds counts only, and the tool serves only the keys it names: of a group, runs and the three count maps, and the words that name its grouping. A count that is not a whole number, or a map of them that is not, is left out rather than served. The file is written grouped one way, and by says which: an argument that asks for the other is a tool error that names the one it holds, rather than an answer of nothing. A week's entry stands for seven days and is kept when any of them falls in the window, because a count of a week cannot be split between its days.

factory_park reads the same snapshot, then one file: the result log of the run it answers, by the name the snapshot gives and only when that name is the one pattern of a work run's result of that issue. A result over 1 MiB, a link, or one that is not JSON is not read, and the answer says unreadable. sig is the hash the cycle signs its park with, of the step, cap, park reason, failure kind and cause the run recorded, so it matches the marker on the issue's park comment without a call to GitHub. The check lines are the runner's own extract of the evidence, then the lines of its evidence that say FAIL, FAILED, not ok or failed checks. A line held in another, as the runner cuts or quotes one, is given once, the longer kept. When the runner itself died, the reason is the result's own error and not an issue's failure, so errorCode and error give it. Every text of the result is masked, then made one line, then cut. errorCode and causeClass are one word of the runner's, masked first: a word that is not one after the mask, such as a private name, is left out. Nothing else of the result is served: not its handoff body, its paths of the work state or its usage.

factory_issue reads the same snapshot for its attempts and the dashboard's own files for the rest: status.json for the stage and the title, running.json for the cycle that owns the issue, and health.json for the issues being planned, whose list status.json gives only as a count. It reads nothing else, and it never gives an issue's body or its labels. A file of the three that is not there is read as listing nothing; one that is there and cannot be read, or is not complete JSON, is a tool error that names it, so the tool never answers "not listed" when it could not look. factory_sessions, factory_session and factory_failures read status.json for the repository of their links the same way: without the file they give no links, and an unreadable one is a tool error.

factory_decisions reads the end of dispatch.log in the logs directory, by that fixed name, and nothing else. It reads at most the last 1 MiB, from the first whole line in it, so on a long log the oldest decisions are out of reach and whole is false. The time, the word and the issue of a decision are checked shapes; only the reason is free text, and it is masked before it is cut. A line the dispatcher wrote for a decision it did not make is left out: a hold #N: line is a decision, and a holding: line or the lift #N: line that releases a hold of the same log is not - the lift line is visible through factory_events. A log that is missing, a link or not a plain file is a tool error that names it.

factory_disk reads one file and asks the host nothing: disk.json in the live directory, which tehas disk --publish writes (see tehas disk). The server runs no df, no docker, and no walk of a tree, so the answer costs the host nothing to serve and no tool call can make it measure anything. The cleaner's tehas-clean.timer publishes the file every hour after the clean, failed or not (tehas disk), so on a host that runs the timer time is under an hour old; a person, or a program that asked, can refresh it sooner, and time is how old what is served is; stale says when that is more than three hours, a host whose timer has not run. Only the fields the tool names are copied out of it, so no other key of the host's own file reaches an answer, and no path of the host does either: the file's absolute paths and Docker's directory are served as roles and as paths under the home, a why names a path by its role, and a mount that is a device path or another host's export is left out; the ids and commands of the containers the daemon holds back are not among them, and the answer gives their count. A file that is not there is a tool error that says it was not published; one that is not one object, is of another api, or names no file system is refused rather than answered as a host with nothing on it.

Logs

factory_log names a file by a word, never by a path. The words a session has depend on its kind:

Kind Word File
work transcript work-<n>-<stamp>.jsonl, the runner's event stream
work err <transcript>.err, the runner's standard error
work preflight <transcript>.preflight, the preflight check's output
work console <transcript>.console, the console as written during the run
work result <transcript>.result.json, the runner's result
work dispatch dispatch-work-<n>.log
plan progress plan-<n>-<stamp>.jsonl, the runner's standard error and progress
plan result plan-<n>-<stamp>.json, the runner's result
plan dispatch dispatch-plan-<n>.log

dispatch is per issue: every run of the issue appends to it, and it is served whole. tehasbot clean removes the work-* and dispatch-work-* logs after seven days (see the cleaner), so a work session older than that is listed with no logs. A word the session does not have is a tool error that lists the ones it has; factory_session lists them with their sizes.

The server opens only a file name the sessions snapshot gives for that session, and only when the name is the one pattern its word allows for the session's kind and issue. The logs directory also holds the host's own logs: factory_events reads dispatch.log and refresh.log by their fixed names, factory_decisions reads dispatch.log by that one name, and nothing else in it can be named. A file that is now a link, or is gone, is a tool error that names the word.

Limits:

Every line is masked before it is sent, so size, offset and next count bytes of the masked text, not of the file on the host. The size factory_session gives is the file's. A plain read masks the log from its start only as far as the end of its piece, so a read of the head of a large log costs what it returns; such a read does not know the masked size of the whole and leaves size out. The last piece, and a gzip answer, give it. Two gzip answers at once of a generated 9 MB file, not a real transcript, kept the server under 40 MB of memory.

The mask takes out the tokens, keys, passwords and private addresses it knows, and the host's names the dashboard's console hides: the host aliases, the host of every model endpoint and the bot's email. It also takes out the secret values the console hides as text: the settings whose names say they are secret (they hold TOKEN, SECRET, PASSWORD, PASSWD, KEY or CREDENTIAL, in any case) and the literal keys of models.json, wherever they stand, a key printed alone on a line included. The server is not given these values: the host gives it a SHA-256 sum of each, salted afresh on each start, and the server hides any run of text whose sum is one of them. It is a net for accidents, not a wall: a log can hold a secret in a form the mask does not know.

A file that is missing or half written gives a tool error that names it, and the server keeps answering. factory_stats with analytics off says that analytics.json is not published.

Following the factory

factory_events is polled, not streamed. Call it once without after for the last events, then again every so often with the next it gave, and each line the two logs get comes back once, in its log's order. The two logs are merged by time, a tie going to dispatch.log. The dispatcher polls every two minutes and writes the same three or four skip and holding lines each time; they are events like the rest.

The tool opens four names in the logs directory and no other: dispatch.log, refresh.log and their rotated copies dispatch.log.1 and refresh.log.1. store upkeep rolls each long-lived log past 64 MiB by copy and truncate and keeps one .1, so these four names are the ones it rotates. A link, or anything that is not a plain file, is a tool error that names it.

The cursor is opaque. It holds, for each log, the file it was read from, how far and a hash of the file's first 128 bytes up to there, masked as the events are, and it is checked when it comes back: one of another shape is a tool error. A cursor names a line's start, or a place inside a line longer than a read, from where the tool reads on at the next line. One that names any other place in a line is taken as a file it did not read, so no part of a line is ever answered without the rest of it to mask.

When the log is no longer the file read, because it was copied and truncated or renamed and a new one made, the rest is read from the .1 copy when that copy is the file read, and then the new log from its start. When no copy is, the new log is read from its start and the answer names the log in gaps. A log rotated twice between two polls loses the older copy, so poll more often than the logs rotate. A line not yet ended by a newline waits for the next poll. A line the copy cut is joined with its rest, the start of the new log.

Rotate these logs by copy and truncate, such as logrotate's copytruncate: store upkeep does this for its long-lived logs past 64 MiB. A cycle's unit and the dispatcher's keep dispatch.log open while they run, a cycle for hours, and go on writing to the renamed file after a rename. The tool reads the .1 copy only until it reads on in the new log, so lines written to the copy after that are lost and no gap tells of them.

Without after, the last events come from the end of the log, and from the end of its .1 copy too when the log is shorter than a read.

Each line gets the closest of these kinds, by its first words:

Kind Lines
start start, a planning turn that runs as a unit or continues, refining, and the cycle's own tehas-cycle: line
done done, stop and a planning turn that ended
wait wait, holding:, hold, released:, low issues, a planning or refining turn that waits, the code index stays, another poll and nothing to do
skip skip and ignore
drop drop
tidy tidy, removed, clear and park
refresh each line of refresh.log but a WARN or an ERROR
warn WARN, and any line of no known shape, such as model endpoint: or a tool's own error output with no time
error ERROR and refuse

A line of no known shape is never left out: it is a warn, with its text. A line with no time, such as the output of a command the poll ran, has no time and is merged as if written with the line before it.

Limits: a call reads at most 256 KiB of each log, its .1 copy included, and returns at most limit events, so more is true and next points just past the last event returned when there is more. A line longer than 256 KiB gives one event of its start, and the rest of it is skipped. Each line is masked before it is answered, as the logs above are.