Resources
Guides for using iMothership at work
Get started, understand the product, and fix things when they go sideways.
imothership-agent
Run iMothership agent commands on your own computer or a Raspberry Pi. imothership-agent is a small command-line agent: your project sends it coding prompts, git commands and GPIO commands, and it runs them locally and sends the output back.
It's for teams who want their iMothership agents to work on a real machine: a developer laptop with your repositories on it, a build box, or a Raspberry Pi wired up to hardware. The command is imship.
How it works
- Bridge (recommended):
imship bridgeopens an outbound connection to the iMothership API using a project API key. When an agent in that project sends work, the job arrives over that connection, runs on your machine, and the output streams back. Nothing needs to connect in to your machine. - Local server:
imship engageruns a small HTTP server on127.0.0.1:4317. This is for setups where iMothership itself runs on the same machine or network.
Jobs come from agents that have the iMothership Agent tool turned on in your project's prompt settings (under Advanced). Each job is one of three kinds: a coding prompt, a git command, or a GPIO command.
Requirements
- Node.js 18 or later.
- A project API key. An organisation admin can create an active key of type Api in the project's API Keys & Webhook Endpoints settings. The secret is only shown once.
- For coding prompts: the coding CLI the agent drives, plus an
OPENAI_API_KEY. Runimship codex-installto install the CLI globally; if it isn't installed, the agent fetches it withnpm execwhen needed. - For git commands: git installed on the machine.
- For GPIO: Linux with GPIO sysfs at
/sys/class/gpio, such as a Raspberry Pi.
Install
npm install -g imothership-agent
imship --versionBackground running is handled by PM2, which comes bundled with the package, so there's nothing else to install.
Connect it to your project
Save your project API key on the machine. It's stored in
~/.imship/project-keys.json, andlistshows keys partly hidden.imship project-key add YOUR_PROJECT_API_KEY imship project-key listPoint the bridge at the iMothership API and start it. Set
IMSHIP_BRIDGE_BASE_URLyourself: if it isn't set, the bridge trieshttp://localhost:8000.Bash or zsh:
export IMSHIP_BRIDGE_BASE_URL='https://api.imothership.com' imship bridgePowerShell:
$env:IMSHIP_BRIDGE_BASE_URL = 'https://api.imothership.com' imship bridgeCheck the output. Once it's connected you'll see something like this, and the agent then waits for jobs:
[imship] bridger connecting to https://api.imothership.com/api/v1/imship/stream [imship][bridger] connected to stream
imship bridge runs in the terminal you start it from, so keep that terminal open. If the connection drops, it reconnects on its own, waiting a little longer each time (up to 15 seconds by default).
The bridge uses your key to sign in, and iMothership works out the project from it. Jobs are queued per project, and results can only be sent back for the project the job came from.
Using it from your project
Turn on the iMothership Agent tool for an agent in your project's prompt settings. That agent can then send work to the connected machine:
- Coding prompts: the prompt is run by the coding CLI on your machine, optionally in a given folder, and its output streams back.
- Git commands: the git arguments are run as given, in a chosen folder or the default from
IMSHIP_GIT_CWD. - GPIO commands: list, export, unexport, set the mode of, read and write Raspberry Pi pins.
For example, a git job and a GPIO job sent by the agent look like this:
{"mode":"git","gitArgs":["status","--short"]}
{"mode":"gpio","gpioArgs":["write","17","1"]}A coding prompt can run for up to 10 minutes on your machine by default. iMothership waits up to 3 minutes for a tool call by default, so keep jobs focused, and make sure the agent is connected before you send work.
Commands
Connect and run
Start the agent and keep it running.
| Command | What it does |
|---|---|
imship bridge | Connect out to iMothership, wait for jobs from your project and run them on this machine. Alias: imship bridger. |
imship engage | Start the local agent server in the background. Alias: imship start. |
imship disengage | Stop and remove the background agent. Alias: imship stop. |
imship status | Show whether the background agent is running. |
imship logs | Stream the background agent logs, starting with the last 100 lines. |
imship save | Save the background process list so it can be restored after a reboot. |
imship startup | Set the background agent to start when the machine boots. |
imship run | Run the local agent server in the foreground. |
Project keys
Store the project API keys the agent uses. Alias: imship key.
| Command | What it does |
|---|---|
imship project-key add <api-key> | Save a project API key on this machine. |
imship project-key add <project-id> <api-key> | Save a key against a specific project ID. |
imship project-key list | List saved keys, partly hidden. |
imship project-key remove <project-id> | Remove a saved key. |
Coding, git and GPIO
Run the same kinds of work yourself from the command line.
| Command | What it does |
|---|---|
imship codex [...args] | Run the coding CLI used for coding prompts. |
imship codex-install | Install that coding CLI globally. |
imship git [...args] | Run a git command. |
imship gpio [...args] | Manage Raspberry Pi GPIO pins: list, export, unexport, mode, read and write. |
Other
Everything else.
| Command | What it does |
|---|---|
imship help | Show all commands. Also -h or --help. |
imship version | Show the installed version. Also -v or --version. |
Try git and GPIO by hand first to check the machine is set up:
imship git status --short
imship git log --oneline -5Running on a Raspberry Pi
GPIO commands use Linux GPIO sysfs at /sys/class/gpio. On anything other than Linux, or if that path is missing, GPIO commands stop with a clear error. Writing a value sets the pin to output first.
imship gpio export 17 out
imship gpio write 17 1
imship gpio read 17
imship gpio unexport 17To keep the background agent running after a reboot:
imship engage
imship save
imship startupLocal server
If iMothership runs on the same machine or network, you can use the local server instead of the bridge. It runs in the background as imship-agent:
imship engage
imship status
imship logs
imship disengageOnce any key is saved, every request to the local server needs a matching key in x-imship-api-key, x-api-key or an Authorization: Bearer header. An optional x-imship-project-id header makes the key match that exact project. GET /health is always open, for health checks.
Configuration
| Environment variable | What it does |
|---|---|
IMSHIP_BRIDGE_BASE_URL | The iMothership API address the bridge connects to. Set this to https://api.imothership.com. |
IMSHIP_BRIDGE_API_KEY | Project API key for the bridge. IMSHIP_API_KEY also works, or save one with imship project-key add. |
IMSHIP_PROJECT_ID | Optional project ID sent with bridge requests. IMSHIP_BRIDGE_PROJECT_ID also works. |
IMSHIP_BRIDGE_JOB_TIMEOUT_MS | How long a coding prompt may run on this machine. Defaults to 600000 (10 minutes). |
IMSHIP_GIT_CWD | Default folder for git commands when a job does not give one. |
OPENAI_API_KEY | Used by the coding CLI that runs coding prompts. |
IMSHIP_DEBUG | Detailed logs are on by default. Set to 0 to turn them off. |
| Environment variable | What it does |
|---|---|
IMSHIP_AGENT_HOST | Address the local server listens on. Defaults to 127.0.0.1. |
IMSHIP_AGENT_PORT | Port the local server listens on. Defaults to 4317. |
IMSHIP_API_KEY | A single key accepted for any project. |
IMSHIP_PROJECT_KEYS | Several keys at once, written as projectId:key,projectId2:key2. |
IMSHIP_REQUIRE_API_KEY | Set to 1 to require a key even when none is saved. |
IMSHIP_ALLOW_INSECURE_NO_AUTH | Set to 1 to allow a non-local address without keys. Not recommended. |
Security
- It runs real work. Coding prompts and git commands run with your user account's access, in the folder the job names. Only run the agent on machines and folders you're happy for your project's agents to work in.
- Outbound only for the bridge. The bridge connects out to iMothership; it doesn't open a port on your machine.
- The local server stays local. It listens on
127.0.0.1by default and refuses to start on any other address without a key, unless you deliberately override that. - Keys are checked carefully. Keys are compared in constant time, and a key tied to a project ID only works for that project.
- Protect the key file. Saved keys are stored as plain text in
~/.imship/project-keys.json. Keep that file private, and remove keys you no longer use withimship project-key remove.
Troubleshooting
- "No bridge API key configured": save a key with
imship project-key add, or setIMSHIP_BRIDGE_API_KEY. - The bridge connects to localhost:8000: set
IMSHIP_BRIDGE_BASE_URLtohttps://api.imothership.com. - "Bridge stream failed (401)": check the project API key is active and copied in full.
- Requests time out in iMothership: check the bridge is running and connected, and that it's using a key for the same project.
- "refusing to start agent with auth disabled": you've set the local server to a non-local address with no key. Save a key, or keep the default
127.0.0.1. - Unauthorised (401) from the local server: the request's key is missing or doesn't match a saved key.
- GPIO errors: GPIO only works on Linux with
/sys/class/gpioavailable. - Checking the background agent: use
imship statusandimship logs.
Connecting an AI assistant instead? See the MCP server guide. To call iMothership from your own code, see the API documentation.