Call Daintree From the Command Line
Install the daintree command on macOS, Windows and Linux, and use daintree call and daintree session to reach Daintree's MCP tools from scripts and git hooks: credentials, arguments, exit status, a git hook example and held sessions.
daintree call makes one call to one of Daintree's MCP tools from a shell: a script, a Make target, a git hook, or an agent CLI that can't take an MCP server at launch. It's a client, not a new surface. It adds no tools, and each call gets exactly the tier, ownership checks and audit record its credential already has, as described on Authorization & Approval.
daintree call terminal.list
daintree call actions.search --arg 'query=send to an owned terminal'
daintree call agent.launch --args '{"agentId": "codex", "prompt": "Review the last commit"}' --json Install the Command
daintree call is part of the same daintree command that opens a folder from your terminal. If you've already installed that, there's nothing more to do.
Choose Terminal > Install Daintree Command Line Tool in the menu bar. It links /usr/local/bin/daintree to the script inside the app, or ~/.local/bin/daintree when /usr/local/bin isn't writable, in which case you may need to add that folder to your PATH.
The client needs only bash, curl and awk, which macOS ships.
The installer normally puts a daintree command on your PATH: the user PATH for a per-user install, the system PATH for an all-users one. If it couldn't change PATH safely, it says so, and the command is still at bin\daintree.cmd in the install folder. There's no menu item to run. Terminals opened after the install find it; a shell that was already open keeps its old PATH until you open a new one.
call and session run through Windows PowerShell 5.1, which every supported Windows ships. The Microsoft Store build doesn't put the command on PATH.
The .deb package installs /usr/bin/daintree itself. For the AppImage, choose Terminal > Install Daintree Command Line Tool (the toolbar's application menu button opens the menu when the menu bar is hidden). It writes a wrapper to ~/.local/share/daintree/daintree-cli.sh that carries its own copy of the client, since the AppImage's files are gone whenever it isn't running, then links it as /usr/local/bin/daintree or ~/.local/bin/daintree.
The client needs only bash, curl and POSIX awk. It doesn't use jq, Python or Node.
See Daintree CLI for opening folders, --status and the rest of the command.
What It Can Reach
What a call can do depends on where it runs. The client reads DAINTREE_MCP_TOKEN, and DAINTREE_MCP_URL when it's set, and only ever talks to http://127.0.0.1:<port>, so the token never leaves the machine. Your MCP server has to be on either way.
| Where it runs | Credential | Tools | Owns |
|---|---|---|---|
| An agent pane in a project with Agent integrations set to Core or Full | The pane's own token, already in its environment | The project's tier, with the same approval prompts as the agent's own calls | What the pane created, across calls, until the pane exits |
| Anywhere else: your own terminal, a cron job, a CI step on this machine | The API key from Settings > MCP server, exported as DAINTREE_MCP_TOKEN | The external tool surface | Only what it created in the same session |
In an Agent Pane
When a project's Agent integrations (Settings > Project > General) is Core or Full and the MCP server is ready, each agent that takes an MCP server at launch gets DAINTREE_MCP_URL and DAINTREE_MCP_TOKEN in its environment: Claude Code, Codex, Gemini CLI, GitHub Copilot, OpenCode, Qwen Code, Amp and Mistral Vibe. So do the scripts, Make targets and git hooks that agent runs, wherever they pass the environment through. That's how a hook triggered by an agent's git commit reaches Daintree with no setup.
Plain terminals, and panes whose only MCP server is Decisions or a plugin's, don't get either variable. Neither do the commands Daintree runs for you through project.runCommand, which strips every DAINTREE_ variable. The Daintree Assistant's panes get their own token instead, and a URL while Daintree control is on. A pane's token ends with its agent: a call made after the pane exits gets exit status 4.
Because ownership belongs to the pane, one call can launch an agent and a later one can send to it with terminal.sendCommandOwned. Each call opens its own MCP session and closes it on exit. A pane holds at most eight sessions, and a ninth evicts the least recently used one, which can be the agent's own, so don't fire many calls in parallel from one pane.
Outside a Pane
Copy the key from Settings > MCP server > API key and export it:
export DAINTREE_MCP_TOKEN='<paste the whole copied key>'
daintree call worktree.list On macOS and Linux, the client finds the running Daintree's port on its own, from a record Daintree publishes in its profile while the MCP server is serving. Set DAINTREE_MCP_URL as well (such as http://127.0.0.1:45454/mcp) to reach a development build or another profile. On Windows, Daintree publishes no such record, so set DAINTREE_MCP_URL too. After you rotate the key in Settings, calls with the old one fail with exit status 4.
Usage
daintree call <tool> [--arg key=value]... [--json]
daintree call <tool> --args '<json object>' [--json]
daintree call <tool> --args - [--json] # the JSON object on stdin --arg key=valuepasses one argument, always as a string. Repeat it for more. The value may contain=.--argspasses every argument as one JSON object, for numbers, booleans, arrays and objects.--arg maxLines=50sends the string"50";--args '{"terminalId": "…", "maxLines": 50}'sends a number. You can't mix it with--arg.--args -reads the object from stdin. Use it for prompts and anything private:--argvalues and an inline--argsappear in the process list, where other users on the machine can see them.--jsonprints the tool's whole result as JSON. Without it, the tool's text is printed, one block per line, and anything that isn't text is noted on stderr.
There's no list command. Find tool names with actions.search and a tool's arguments with actions.getSchema; both answer only with what your credential can actually call:
daintree call actions.search --arg 'query=send to an owned terminal'
daintree call actions.getSchema --arg actionId=terminal.sendCommandOwned A call has no time limit of its own once it's sent, because it may be waiting on an approval dialog or on an agent.
Exit Status
| Code | Meaning |
|---|---|
0 | The tool succeeded. Its text is on stdout. |
1 | The tool reported an error (its text is on stderr), or Daintree refused the call or its session. |
2 | Usage error. |
3 | No answer: Daintree isn't reachable, or the reply wasn't understood. A call that was already sent may have run, so check before you repeat it. The client never retries one. |
4 | No usable credential or endpoint: DAINTREE_MCP_TOKEN is missing, malformed or refused, DAINTREE_MCP_URL is malformed, or no running Daintree has published its endpoint. |
5 | The held session in DAINTREE_MCP_SESSION is gone. Nothing ran. |
Whether the tool succeeded is read from the result's structure, not its text, so output that merely looks like an error doesn't change the exit status.
Use It From a Git Hook
A hook can check for Daintree's variables and stay quiet everywhere else. This post-commit hook asks Codex to review each commit an agent makes:
#!/bin/sh
# Both are set in an agent pane of a project with Daintree MCP on.
[ -n "$DAINTREE_MCP_TOKEN" ] && [ -n "$DAINTREE_MCP_URL" ] || exit 0
command -v daintree >/dev/null 2>&1 || exit 0
sha=$(git rev-parse HEAD) || exit 0
printf '{"agentId": "codex", "prompt": "Review commit %s (git show %s) and report any bugs you find."}' "$sha" "$sha" |
daintree call agent.launch --args - >/dev/null || true - Save it at the path
git rev-parse --git-path hooks/post-commitprints, which also works from a linked worktree, and make it executable withchmod +x. - The check also passes anywhere you exported both variables yourself, such as a shell holding the API key, and in the Daintree Assistant's panes while Daintree control is on. An API-key call launches in the project whose window you focused last, so keep the hook to agent panes if that matters.
- The hook names the commit by its hash, because the reviewer opens in the project's active worktree, which may not be the one that committed. A commit is readable from every worktree of the same repository.
- With a pane's token, the reviewer belongs to the pane whose agent committed, so that agent can send to it and read its reply.
agent.launchis a Core tool, so at Core or Full it runs without asking. A Core pane calling a Full tool can raise an approval dialog instead, and the hook waits for your answer. - Piping the arguments through
--args -keeps them offdaintree's own command line. The launched agent may still receive its prompt as an argument. || truekeeps a failed call from looking like a failed hook. In apre-commitorpre-pushhook, a non-zero exit would stop the commit or push, so decide whether that's what you want.
Hold One Session Across Calls
With the API key, a session owns what it creates, and each daintree call opens and closes its own session. So a script that launches an agent in one call and sends to it in the next is refused the second time with RESOURCE_NOT_OWNED. daintree session start holds one session open across calls:
handle=$(daintree session start) || exit
export DAINTREE_MCP_SESSION=$handle
daintree call agent.launch --arg agentId=claude --json
daintree call terminal.sendCommandOwned --args - < send.json
daintree session end && unset DAINTREE_MCP_SESSION Here send.json holds {"terminalId": "<the launch's terminalId>", "command": "…"}. The handle holds no credential and is useless without the key that opened it.
- Capture the handle in its own variable and export it only once
startsucceeded, as above.startrefuses whileDAINTREE_MCP_SESSIONalready names a session. - An API-key session ends with
daintree session end, after 30 minutes without a call (time asleep doesn't count), or when the MCP server stops, restarts or changes its key. What it created stays where it is, and a later call with the old handle fails rather than opening a new session. - Within 120 seconds, repeating a creation call with the same arguments in the same session can return the first call's answer instead of creating again. Give each its own
requestKeyto create two. - In an agent pane, the pane already owns what its calls create, so a held session adds nothing there and takes one of the pane's eight sessions.
On Windows, daintree.cmd runs inside cmd, which treats &, |, <, > and ^ outside double quotes as its own. Inline JSON needs each " written as \", in both cmd and PowerShell. It's simpler to keep arguments in a file: daintree call agent.launch --args - < args.json at a cmd prompt, or cmd /c "daintree call agent.launch --args - < args.json" from PowerShell, which doesn't take < itself. Windows PowerShell 5.1 pipes text to a native command as ASCII unless $OutputEncoding is UTF-8, so non-ASCII text piped from it arrives as ?.