Skip to content

The remote API

mait_code.remote is the part of a mait-code instance that another machine or agent may touch: read the board and its epics, raise cards, refine them, search memories, check that memory search can use its vectors, and list reminders. It is a Python module, not a server. A separate service you run — typically one that speaks MCP to remote Claude Code sessions or other agents — imports it and decides who may call what. mait-code itself never opens a port.

That split is deliberate. mait-code has no background services, so the listening, the authentication, the per-client scopes and the process lifecycle live in the host. The rules about what may happen to the instance live here, next to the data model and its tests.

What it can do

Function Does
list_cards Cards ordered priority-then-oldest; filter by project, status, tag or title. Archived cards are left out unless asked for by status.
get_card One card with its comments, in the mc-tool-board show --json shape.
list_projects The projects that have cards.
list_epics Epics with their member progress, priority-then-oldest; finished epics only when asked for. Archived epics never appear.
get_epic One epic with its non-archived members, progress and comments, in the mc-tool-board epic show --json shape.
create_card A new card, always in backlog: there is no status parameter. With origin_id, it joins that card's epic and records a from reference; inherit_epic=False keeps the reference and joins no epic.
refine_card Edit description and acceptance criteria, and move between backlog and refined only.
search_memories The same hybrid search and ranking as mc-tool-memory search, each result with a score.
memory_search_status Whether memory search can use the instance's vectors with the host's embedding settings, and why not.
list_reminders Active reminders, due time as ISO 8601, each flagged overdue or not.

Every function takes the instance's data directory as its first argument.

from pathlib import Path

from mait_code import remote

data = Path("/home/agent/.claude/mait-code-data")

card = remote.create_card(
    data, client="hermes", project="homelab", title="Rotate the forge token"
)
remote.refine_card(
    data, card["id"], client="laptop", acceptance="- token rotated\n- runbook updated"
)
follow_up = remote.create_card(
    data,
    client="hermes",
    project="homelab",
    title="Alert before the forge token expires",
    origin_id=card["id"],  # joins its epic, records `from` → #<id>
)

What it deliberately can't

Deleting or archiving cards, tags, links, setting a card's epic, moving a card into In Progress, In Review or Done, writing or retiring memories, applying reflections, and changing reminders. These are decisions for whoever owns the instance, so the functions don't exist on this surface; they aren't refused at runtime. A test pins the module's public names to an allowlist, so adding one is a visible change to this contract, not a quiet addition.

A refine of a card outside backlog/refined, or towards any other column, raises TransitionRefused and changes nothing; refining an epic raises RelationError. The status check and the write happen in one transaction, so a card the instance moves on concurrently can't be pulled back.

A card created with origin_id reaches an epic only through its origin. Since any card can be an origin, a client can reach any epic that has a member; the from reference and created_by show how the card got there. An origin's epic that is done or archived is refused with RelationError, not joined, because nothing would surface the card under it. An epic can't be an origin itself (also RelationError), and an id that names no card raises CardNotFound from any function that takes one. Pass inherit_epic=False to keep the reference without the epic.

Provenance

Every write names its caller. create_card stores client as the card's Created by field, which mc-tool-board show prints and the board TUI shows as via <client> on the card's meta line. refine_card adds a comment authored by client saying what changed. A card raised by an agent is identifiable before anyone picks it up, which matters once card text becomes a prompt.

Running it as a different user

A host service should run as its own user rather than as the one that owns the instance, so that a compromised session on the instance can't reach the service's credentials. The module is written for that arrangement:

  • No config that executes. It reads only board.db, memory.db and reminders.db from the data directory. It never reads dashboard.toml, whose command tiles run shell commands, and never applies the settings [env] table or touches the process environment. Run anything that does read the instance's config, like the home hub, as the instance's own user.
  • No migrations. The host pins its own mait-code release. If a database's schema version isn't the one that release expects, calls raise SchemaMismatch, which names both versions, instead of upgrading or downgrading the instance. Upgrade whichever side is behind. A missing database raises FileNotFoundError; nothing is created.
  • Read-only where it can be. Memories, reminders and every board read are opened read-only. Only create_card and refine_card open the board read-write, with a 10-second busy timeout, since the instance writes it too.
  • Permissions. The service user needs read access to the data directory. To create or refine cards it also needs write access to board.db and its board.db-wal and board.db-shm files: SQLite's WAL mode writes all three, so group-write on the database alone isn't enough. A host that only reads needs no write access. Reading a database in WAL mode needs its -shm file to exist, so the instance should have opened each one at least once.
  • Its own data directory. Give the host its own MAIT_CODE_DATA_DIR (or data-dir setting), never the instance's. Memory search caches the local embedding model under the host's data directory, so pointing that at the instance would have the host writing into it.

Embeddings

search_memories runs keyword and vector search. The vector half embeds the query with the provider in the host's settings, which must match the instance's (embedding-provider, embedding-model or bedrock-model-id). The local provider downloads its model on first use, so the host needs outbound access to fetch it once, or a pre-populated model cache.

memory.db records the provider, model and width that built its vectors. When the host's settings disagree — a different model, even one of the same width, or a different width — vector search is skipped and results are keyword-only, with a warning logged once per host process. An instance with no record yet (vectors built before 0.80.0) is trusted as before; run mait-code doctor --fix on the instance to record one.

memory_search_status asks the same question up front, without embedding anything or loading the provider, so a host can surface it in a health check rather than discover it from degraded results:

status = remote.memory_search_status(data)
# {"usable": False, "state": "model",
#  "reason": "vectors were built by local 'nomic-ai/nomic-embed-text-v1.5' (768d), "
#            "configured is local 'some/other-model' (768d)",
#  "configured": {"provider": "local", "model": "some/other-model", "dim": 768},
#  "recorded": {"provider": "local", "model": "nomic-ai/nomic-embed-text-v1.5", "dim": 768}}

state is match, unknown (vectors but no record) or empty when search can use vectors, and model, dimension or absent (no vector table) when it can't. usable covers the vectors only, not whether the host's provider loads: a model that can't be downloaded, or missing boto3 or AWS credentials, still leaves search keyword-only, so a health check should not read usable as "vector search works". Like every other call, it raises FileNotFoundError for a missing memory.db and SchemaMismatch for a schema it doesn't expect. The configured side comes from the host's environment and settings file, exactly as for search_memories. See how memory works for the settings.