Batch: Preferences page is "MCP"; Copy Prompt for an Agent

The page only holds the MCP connection, so Edit › Preferences › AI Integrations… is now
Edit › Preferences › MCP… (command id and the `integrations` preference keys unchanged).

Copy Prompt for an Agent puts a text on the clipboard that an agent with a terminal
(Claude Code, Codex, Cursor's agent) pastes to register `photocraft-cli mcp --live` itself
and check the connection; Claude Desktop has no terminal and keeps Add to Claude Desktop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-11-12 02:56:45 +01:00
1 parent 7444ab6c03
commit cd41d63394
30 files changed
+115 -54

No files matched your search

+1 -1
View File
@@ -246,7 +246,7 @@ photocraft-cli batch --help
photocraft-cli mcp
```
To let Claude or another AI app drive the open PhotoCraft window without a terminal, turn on **Edit › Preferences › AI Integrations › Let AI agents connect**, then click **Add to Claude Desktop** (or Claude Code, or Cursor) in the same panel. See [`docs/mcp.md`](docs/mcp.md).
To let Claude or another AI app drive the open PhotoCraft window without a terminal, turn on **Edit › Preferences › MCP › Let AI agents connect**, then click **Add to Claude Desktop** (or Claude Code, or Cursor) in the same panel. See [`docs/mcp.md`](docs/mcp.md).
The desktop app also offers an authenticated, loopback-only control channel (`photocraft --control`) for inspecting UI state, driving tools with pointer events, and taking offscreen screenshots. Every image in this README was rendered that way. See [`docs/control-protocol.md`](docs/control-protocol.md).
+2 -2
View File
@@ -276,7 +276,7 @@ pub(crate) struct CommandsArgs {
/// Headless: each automation root grants that direction of file access; an omitted root denies it.
/// Prefer absolute root paths in MCP client configurations. Bridge: set the roots on the desktop
/// app; root flags are refused. The token flags require --bridge (or PHOTOCRAFT_CONTROL_PORT).
/// Live: the desktop app with Edit › Preferences › AI Integrations › Let AI agents connect on,
/// Live: the desktop app with Edit › Preferences › MCP › Let AI agents connect on,
/// found again on every call (no port or token to configure); the roots are for a headless session
/// while the app is closed.
#[derive(Args)]
@@ -284,7 +284,7 @@ pub(crate) struct CommandsArgs {
pub(crate) struct McpArgs {
#[command(subcommand)]
pub(crate) action: Option<McpCommand>,
/// Find the desktop app by itself on every call (Edit › Preferences › AI Integrations ›
/// Find the desktop app by itself on every call (Edit › Preferences › MCP ›
/// Let AI agents connect), with no port or token to configure
#[arg(long)]
pub(crate) live: bool,
+2 -2
View File
@@ -2031,7 +2031,7 @@ fn info_detail_adds_text_runs_and_antialiasing() {
}
/// `mcp install --client json` prints the configuration MCP clients start `mcp --live` with;
/// Cursor's file gets the same entry, other servers kept (Preferences › AI Integrations).
/// Cursor's file gets the same entry, other servers kept (Preferences › MCP).
#[test]
fn mcp_install_writes_the_live_entry() {
let home = tmp("mcp-install");
@@ -2110,7 +2110,7 @@ fn mcp_live_without_the_app_explains_what_to_do() {
send(json!({"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"ui_inspect","arguments":{}}}));
let r = recv(2);
assert_eq!(r["result"]["isError"], true, "{r}");
assert!(r["result"]["content"][0]["text"].as_str().unwrap().contains("AI Integrations"), "{r}");
assert!(r["result"]["content"][0]["text"].as_str().unwrap().contains("MCP"), "{r}");
drop(stdin);
let _ = child.kill();
let _ = child.wait();
+10 -2
View File
@@ -1,4 +1,4 @@
//! Preferences › AI Integrations on the desktop: while *Let AI agents connect* is on, the app
//! Preferences › MCP on the desktop: while *Let AI agents connect* is on, the app
//! serves the control protocol by itself (no `--control`) and publishes the connection file
//! `photocraft-cli mcp --live` finds it by ([`photocraft_automation::agent_link`]). Turning it on
//! or off, or changing the port or folders, applies at once. The token stays in the settings
@@ -119,9 +119,14 @@ pub fn mcp_launch() -> Option<McpLaunch> {
(appimage.is_some() || dir.join(agent_link::cli_file_name()).is_file()).then_some(launch)
}
/// The "Add to …" buttons: add `mcp` to a client, or return the configuration to paste.
/// The "Add to …" buttons: add `mcp` to a client, or return the configuration to paste; and
/// "Copy Prompt for an Agent" (`prompt`): the text an agent with a terminal sets itself up from.
pub fn clients(mcp: Option<McpLaunch>) -> AgentClientFn {
Box::new(move |id: &str| {
if id == "prompt" {
let launch = mcp.as_ref().ok_or("photocraft-cli isn't installed beside PhotoCraft, so an agent can't start it")?;
return Ok(launch.agent_prompt());
}
let client = Client::parse(id).ok_or_else(|| format!("unknown MCP client `{id}`"))?;
let launch = mcp.as_ref().ok_or_else(|| format!("photocraft-cli isn't installed beside PhotoCraft, so {} can't start it", client.name()))?;
agent_link::install(client, launch, &ClientEnv::from_env()).map(|done| done.message(client)).map_err(|e| e.to_string())
@@ -261,5 +266,8 @@ mod tests {
let mut add = clients(None);
assert!(add("cursor").unwrap_err().contains("photocraft-cli"));
assert!(add("nope").unwrap_err().contains("unknown"));
assert!(add("prompt").unwrap_err().contains("photocraft-cli"));
let mut add = clients(Some(McpLaunch::cli(Path::new("/x/photocraft-cli"))));
assert!(add("prompt").unwrap().contains("mcp --live"));
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
//! Localhost JSON-lines control server (one request per line, one reply per line).
//! Loopback only. This is the transport the MCP server will wrap.
//!
//! `--control` starts it for the whole run ([`start`]); Preferences › AI Integrations starts and
//! `--control` starts it for the whole run ([`start`]); Preferences › MCP starts and
//! stops it while the app runs ([`listen`], see `agent_link`).
use std::io::{BufReader, Write};
+8 -8
View File
@@ -95,7 +95,7 @@ fn custom_titlebar(prefs_file: Option<&std::path::Path>) -> bool {
CUSTOM_TITLEBAR && !prefs.interface.system_title_bar
}
/// Preferences › Integrations, read before the window opens the way [`custom_titlebar`] is:
/// Preferences › MCP, read before the window opens the way [`custom_titlebar`] is:
/// whether agents may drive this launch at all, the port to listen on when no `--control`
/// was given (0 = only with `--control`) and the automation folders used when no
/// `--automation-read-root` / `--automation-write-root` was given. A missing or unreadable file
@@ -147,7 +147,7 @@ fn integration_fields(section: &serde_json::Value, out: &mut photocraft_engine::
}
/// The automation roots: `--automation-read-root` / `--automation-write-root` (or their
/// variables) win; a direction without one takes Preferences › Integrations' folder. A flag's
/// variables) win; a direction without one takes Preferences › MCP' folder. A flag's
/// root that can't be opened stops the launch (exit status 2) as before. A preference's root that
/// can't be opened, or isn't an absolute path (it would depend on the folder the app was started
/// from), is left out, so that direction fails closed, and the warning says why: a folder moved
@@ -177,7 +177,7 @@ fn automation_workspace(
Ok(w) => workspace = w,
Err(e) => {
let which = if read { "Automation Read Folder" } else { "Automation Write Folder" };
warnings.push(format!("Preferences › Integrations › {which} is not used: {e}"));
warnings.push(format!("Preferences › MCP › {which} is not used: {e}"));
}
}
}
@@ -192,7 +192,7 @@ fn control_port_for(cli: Option<u16>, prefs: &photocraft_engine::prefs::Integrat
if !prefs.allow_agent_control {
let warning = cli.map(|p| {
format!(
"photocraft: Preferences › Integrations › Allow Agent Control is off: not listening on port {p}
"photocraft: Preferences › MCP › Allow Agent Control is off: not listening on port {p}
"
)
});
@@ -359,7 +359,7 @@ struct ControlNotice {
}
/// The `--control` server's port, token and workspace, when it is on (exits 2 on a bad
/// configuration). Preferences › Integrations' folders stand in for automation roots no flag
/// configuration). Preferences › MCP' folders stand in for automation roots no flag
/// names. The server Preferences start (*Let AI agents connect*) is `agent_link`'s, not this.
fn control_setup(
cli_port: Option<u16>,
@@ -369,7 +369,7 @@ fn control_setup(
control_setup_in(services::config_dir(), &integrations(services::prefs_file().as_deref()), cli_port, auth, automation)
}
/// [`control_setup`] with the settings folder and Preferences › Integrations given.
/// [`control_setup`] with the settings folder and Preferences › MCP given.
fn control_setup_in(
settings: Option<std::path::PathBuf>,
prefs: &photocraft_engine::prefs::Integrations,
@@ -720,7 +720,7 @@ fn main() -> eframe::Result {
log::warn!("couldn't remember GPU backend {}: {e}", b.name());
}
});
// Preferences › AI Integrations: agents connect without a terminal, unless the launch
// Preferences › MCP: agents connect without a terminal, unless the launch
// flags (`--control`) manage the connection.
let mcp = agent_link::mcp_launch();
app.agent_link.mcp_command = mcp.as_ref().map(photocraft_automation::agent_link::McpLaunch::shell_line);
@@ -1197,7 +1197,7 @@ mod tests {
}
}
/// Preferences › Integrations' folders are the automation roots when no flag names one, and
/// Preferences › MCP' folders are the automation roots when no flag names one, and
/// a flag wins over its preference, direction by direction.
#[test]
fn automation_folders_come_from_the_preferences_unless_a_flag_names_one() {
+1 -1
View File
@@ -4,7 +4,7 @@
- **Headless:** an in-process `Headless` session owns the engine and performs file I/O.
- **Bridge:** `BridgeClient` forwards tools to a desktop application started with `photocraft --control <port>`.
- **Live:** `photocraft-cli mcp --live` finds the desktop application through the connection file it publishes while Edit › Preferences › AI Integrations › *Let AI agents connect* is on, before every tool call; while the app is closed it starts it, serves a headless session, or reports an error, as chosen there.
- **Live:** `photocraft-cli mcp --live` finds the desktop application through the connection file it publishes while Edit › Preferences › MCP › *Let AI agents connect* is on, before every tool call; while the app is closed it starts it, serves a headless session, or reports an error, as chosen there.
The simplest setup needs no terminal: turn on *Let AI agents connect* in PhotoCraft, then click *Add to Claude Desktop* (or Claude Code, or Cursor) in the same panel. See [`docs/mcp.md`](../../../docs/mcp.md#connecting-the-desktop-app-no-terminal).
+1 -1
View File
@@ -29,7 +29,7 @@ Automation is a privilege boundary because requests can cause filesystem access,
Screenshots are decoded under separate dimension, pixel, and allocation ceilings before
downscaling; the 5 MiB PNG limit applies to the returned image.
- MCP normally uses stdio and can optionally bridge to loopback control TCP.
- Preferences › AI Integrations › *Let AI agents connect* (off by default) opens that loopback
- Preferences › MCP › *Let AI agents connect* (off by default) opens that loopback
listener without launch flags. Its token is regenerated each time the connection starts and is
kept in a user-only file; the published `agent-connection.json` holds the port and the token
file's path, never the token. `photocraft-cli mcp --live` probes the port before sending the
+38 -2
View File
@@ -170,7 +170,7 @@ fn read_small(path: &Path) -> Result<Option<String>, AutomationError> {
}
}
/// The AI Integrations preferences saved in `dir/preferences.json` (defaults when the file or
/// The MCP preferences saved in `dir/preferences.json` (defaults when the file or
/// the section is missing or unreadable: the CLI must not fail over the app's settings).
pub fn read_integrations(dir: &Path) -> Integrations {
read_small(&dir.join("preferences.json"))
@@ -218,6 +218,29 @@ impl McpLaunch {
serde_json::to_string_pretty(&v).unwrap_or_default()
}
/// A prompt to paste into an agent that has a terminal (Claude Code, Codex, Cursor's agent):
/// it registers PhotoCraft as its own MCP server, then checks the connection. Claude Desktop
/// has no terminal, so it is set up by [`install`] instead. Holds no port and no token.
pub fn agent_prompt(&self) -> String {
let line = self.shell_line();
let config = self.config_json();
format!(
"Please connect yourself to PhotoCraft, the image editor running on this computer, as an MCP server, then check that it works.
1. Register a stdio MCP server named \"{SERVER_NAME}\" that runs this command:
{line}
- Claude Code: claude mcp add --scope user {SERVER_NAME} -- {line}
- Codex: codex mcp add {SERVER_NAME} -- {line}
- Any other client: add this to its MCP configuration:
{config}
2. Reload your MCP servers if your client needs that (or tell me to restart you).
3. Call the {SERVER_NAME} tool `ui_inspect` and tell me which document is open.
PhotoCraft must be running with Edit › Preferences › MCP › Let AI agents connect turned on. The command needs no port or token: it finds the app by itself on every call.
"
)
}
/// The command line, quoted for a POSIX shell (Windows paths are double-quoted).
pub fn shell_line(&self) -> String {
std::iter::once(&self.command).chain(&self.args).map(|s| shell_quote(s)).collect::<Vec<_>>().join(" ")
@@ -767,6 +790,19 @@ mod tests {
let _ = std::fs::remove_dir_all(&home);
}
/// The prompt an agent pastes names the exact command, the Claude Code and Codex lines and a
/// configuration for any other client, and no token.
#[test]
fn the_agent_prompt_registers_the_live_command() {
let launch = McpLaunch::cli(Path::new("/x/photocraft-cli"));
let prompt = launch.agent_prompt();
assert!(prompt.contains("claude mcp add --scope user photocraft -- /x/photocraft-cli mcp --live"), "{prompt}");
assert!(prompt.contains("codex mcp add photocraft -- /x/photocraft-cli mcp --live"), "{prompt}");
assert!(prompt.contains(&launch.config_json()), "{prompt}");
assert!(prompt.contains("Edit › Preferences › MCP › Let AI agents connect"), "{prompt}");
assert!(!prompt.contains(TOKEN_FILE) && !prompt.contains("token\":"), "{prompt}");
}
#[test]
fn claude_command_is_found_where_its_installers_put_it() {
let home = temp("claude-find");
@@ -843,7 +879,7 @@ mod tests {
assert!(install(Client::Cursor, &launch, &env).is_err(), "no home folder: an error, not a panic");
}
// ---- connection file (Preferences › Integrations) ----
// ---- connection file (Preferences › MCP) ----
#[test]
fn a_published_connection_reads_back_in_the_documented_shape() {
+1 -1
View File
@@ -12,7 +12,7 @@
//! control protocol's envelope, used by `photocraft-cli serve`.
//! * [`files`]: open/save any supported format, `.pcraft` natively.
//! * [`agent_link`] and [`live`]: connecting agents to the desktop app without a terminal
//! (Edit › Preferences › AI Integrations, `photocraft-cli mcp --live` and `mcp install`).
//! (Edit › Preferences › MCP, `photocraft-cli mcp --live` and `mcp install`).
//!
//! L6, no UI-toolkit dependencies.
#![forbid(unsafe_code)]
+3 -3
View File
@@ -3,7 +3,7 @@
//! quit or move to another port while the MCP client stays connected, and the MCP client's own
//! start never opens a window.
//!
//! While the app is closed, AI Integrations › When PhotoCraft Is Closed (or `--when-closed`)
//! While the app is closed, MCP › When PhotoCraft Is Closed (or `--when-closed`)
//! decides: start the app and wait for it, serve a headless session with the folders chosen in
//! the app (then for the rest of the MCP session, so documents don't move under the agent), or
//! report an error that says what to do.
@@ -122,7 +122,7 @@ impl Live {
}
if Instant::now() >= deadline {
return Err(format!(
"PhotoCraft didn't accept agents within {} s of starting. If it's still opening, try again in a moment; otherwise check Edit › Preferences › AI Integrations.",
"PhotoCraft didn't accept agents within {} s of starting. If it's still opening, try again in a moment; otherwise check Edit › Preferences › MCP.",
self.cfg.launch_timeout.as_secs()
));
}
@@ -160,7 +160,7 @@ fn closed(integrations: &Integrations) -> String {
if integrations.connect_agents {
"PhotoCraft isn't running: open it, then try again.".into()
} else {
"PhotoCraft doesn't accept AI agents: open it, turn on Edit › Preferences › AI Integrations › Let AI agents connect, then try again.".into()
"PhotoCraft doesn't accept AI agents: open it, turn on Edit › Preferences › MCP › Let AI agents connect, then try again.".into()
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
//! `photocraft-cli mcp --live` (Preferences › AI Integrations): the MCP server finds the desktop
//! `photocraft-cli mcp --live` (Preferences › MCP): the MCP server finds the desktop
//! app through its connection file before every call, follows it to a new port and token, and
//! applies the closed-app choice (start it, headless, or an error) when no app answers.
+1 -1
View File
@@ -121,7 +121,7 @@ choice!(
RawDemosaic { Ahd = "ahd", Mhc = "mhc", Bilinear = "bilinear" } default Ahd
);
choice!(
/// AI Integrations › When PhotoCraft Is Closed: what `photocraft-cli mcp --live` does when an
/// MCP › When PhotoCraft Is Closed: what `photocraft-cli mcp --live` does when an
/// agent calls a tool and the app isn't running.
WhenAppClosed { Launch = "launch", Headless = "headless", Error = "error" } default Launch
);
+1 -1
View File
@@ -189,7 +189,7 @@ pub fn specs() -> Vec<CommandSpec> {
section!("edit.preferences.type", "Type…"),
section!("edit.preferences.enhancedControls", "Enhanced Controls…"),
section!("edit.preferences.rawDefaults", "RAW Defaults…"),
section!("edit.preferences.integrations", "Integrations…"),
section!("edit.preferences.integrations", "MCP…"),
spec!(
"edit.keyboardShortcuts",
"Keyboard Shortcuts…",
+1 -1
View File
@@ -25,7 +25,7 @@ pub const SECTIONS: [(&str, &str); 18] = [
("type", "Type"),
("enhancedControls", "Enhanced Controls"),
("rawDefaults", "RAW Defaults"),
("integrations", "Integrations"),
("integrations", "MCP"),
];
/// Preferences that nothing reads yet, so Edit › Preferences doesn't show them: a control that
+1 -1
View File
@@ -460,7 +460,7 @@ pub struct PhotocraftApp {
/// The first digit of a two-digit opacity typed on the number keys (`opacity_keys`, #352).
pub(crate) opacity_keys: opacity_keys::Pending,
control_rx: Option<Receiver<ControlRequest>>,
/// Preferences › AI Integrations: the agent connection's state (see [`Services::agent_link`]).
/// Preferences › MCP: the agent connection's state (see [`Services::agent_link`]).
pub agent_link: AgentLinkStatus,
/// `ui.screenshot` requests: bounded admission, a weak-slot callback per issuance, monotonic
/// deadlines and a capture-time geometry epoch (see `screenshot.rs`).
+1 -1
View File
@@ -151,7 +151,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[
(&["Edit"], "---", None, "---"),
(&["Edit", "Preferences"], "General…", Some("Cmd+K"), "edit.preferences.general"),
(&["Edit", "Preferences"], "---", None, "---"),
(&["Edit", "Preferences"], "AI Integrations…", None, "edit.preferences.integrations"),
(&["Edit", "Preferences"], "MCP…", None, "edit.preferences.integrations"),
(&["Edit", "Preferences"], "Interface…", None, "edit.preferences.interface"),
(&["Edit", "Preferences"], "Workspace…", None, "edit.preferences.workspace"),
(&["Edit", "Preferences"], "Tools…", None, "edit.preferences.tools"),
@@ -16,7 +16,7 @@ fn preferences_submenu_reads_in_the_reference_order_with_two_separators() {
&labels[1..],
[
"---",
"AI Integrations…",
"MCP…",
"Interface…",
"Workspace…",
"Tools…",
+1 -1
View File
@@ -52,7 +52,7 @@ pub struct Runtime {
show_rulers: Option<bool>,
/// Tool options as last remembered in the preferences (see `tool_memory`).
pub(crate) tool_options: Option<crate::state::ToolOptions>,
/// AI Integrations settings the agent connection was last set up for (`agents::sync_agent_link`).
/// MCP settings the agent connection was last set up for (`agents::sync_agent_link`).
agent_link: Option<prefs::Integrations>,
pub(crate) selected_tool: Option<crate::state::Tool>,
pub(crate) tool_colors: Option<[[[f32; 4]; 2]; 2]>,
+13 -1
View File
@@ -1,4 +1,4 @@
//! Preferences › AI Integrations: the agent connection (`integrations.connectAgents`), the folders
//! Preferences › MCP: the agent connection (`integrations.connectAgents`), the folders
//! agents may use, what `photocraft-cli mcp --live` does while the app is closed, and the buttons
//! that add PhotoCraft to MCP clients. Changes apply at once, without a restart.
@@ -98,6 +98,14 @@ pub(super) fn integration_rows(ui: &mut egui::Ui, obj: &mut Map<String, Value>,
}
}
});
// Agents with a terminal (Claude Code, Codex, Cursor's agent) can set themselves up.
ui.add_space(4.0);
ui.horizontal_wrapped(|ui| {
if crate::widgets::secondary_button(ui, tl!("Copy Prompt for an Agent"), 120.0).clicked() {
f.insert("__agentAction".into(), json!("prompt"));
}
ui.label(RichText::new(tl!("Paste it into an agent with a terminal; it registers PhotoCraft by itself.")).color(t.text_faint));
});
}
if let Some(result) = f.get("__agentResult").and_then(Value::as_object) {
let ok = result.get("ok").and_then(Value::as_bool) == Some(true);
@@ -134,6 +142,10 @@ pub(super) fn agent_action(app: &mut PhotocraftApp, ctx: &egui::Context, f: &mut
ctx.copy_text(text);
json!({"ok": true, "message": tl!("Configuration copied.")})
}
Ok(text) if action == "prompt" => {
ctx.copy_text(text);
json!({"ok": true, "message": tl!("Prompt copied. Paste it into Claude Code, Codex or another agent with a terminal.")})
}
Ok(message) => json!({"ok": true, "message": message}),
Err(e) => json!({"ok": false, "message": e}),
};
@@ -1,4 +1,4 @@
//! Preferences › AI Integrations (`agents.rs`): the live agent connection and its buttons.
//! Preferences › MCP (`agents.rs`): the live agent connection and its buttons.
use super::tests::app_with_store;
use super::*;
@@ -72,13 +72,18 @@ fn ai_integrations_offer_the_client_buttons_only_when_agents_may_connect() {
assert!(h.query_by_label("Copy Configuration").is_none());
h.get_by_label("Let AI agents connect (MCP)").click();
h.run_steps(3);
for label in ["Add to Claude Desktop", "Add to Claude Code", "Add to Cursor", "Copy Configuration"] {
for label in ["Add to Claude Desktop", "Add to Claude Code", "Add to Cursor", "Copy Configuration", "Copy Prompt for an Agent"] {
assert!(h.query_by_label(label).is_some(), "{label}");
}
h.get_by_label("Add to Cursor").click();
h.run_steps(3);
assert_eq!(*clicked.lock().unwrap(), ["cursor"]);
assert!(h.query_by_label("Added PhotoCraft to cursor.").is_some(), "the answer is shown");
// The prompt for an agent with a terminal goes to the clipboard, with a note saying so.
h.get_by_label("Copy Prompt for an Agent").click();
h.run_steps(3);
assert_eq!(*clicked.lock().unwrap(), ["cursor", "prompt"]);
assert!(h.query_by_label_contains("Prompt copied").is_some(), "the copy is confirmed");
// Unticked again: the buttons go.
h.get_by_label("Let AI agents connect (MCP)").click();
h.run_steps(3);
+2 -2
View File
@@ -54,7 +54,7 @@ pub(super) fn humanize(key: &str) -> String {
if key == "notificationAutoHide" {
return "Auto Hide Notifications".into();
}
// AI Integrations: the labels its own rows show (`agents::integration_rows`), also for search.
// MCP: the labels its own rows show (`agents::integration_rows`), also for search.
match key {
"connectAgents" => return "Let AI agents connect (MCP)".into(),
"readRoot" => return "Folder agents can open from".into(),
@@ -136,7 +136,7 @@ pub(super) fn choice_label(v: &str) -> String {
"ahd" => "AHD (adaptive homogeneity)".into(),
"mhc" => "Malvar–He–Cutler".into(),
"cpu" => "CPU (no GPU acceleration)".into(),
// AI Integrations › When PhotoCraft is closed.
// MCP › When PhotoCraft is closed.
"launch" => "Open PhotoCraft".into(),
"headless" => "Work without a window".into(),
"error" => "Ask to open PhotoCraft".into(),
+1 -1
View File
@@ -1582,7 +1582,7 @@ fn unimplemented_preferences_are_hidden_from_the_dialog() {
assert!(has_visible_fields(&values, "fileHandling"));
assert!(has_visible_fields(&values, "scratchDisks"));
assert!(!prefs::is_hidden("scratchDisks.disks"));
// AI Integrations: the agent connection and its folders apply at once (`agents.rs`).
// MCP: the agent connection and its folders apply at once (`agents.rs`).
assert!(has_visible_fields(&values, "integrations"));
assert!(!prefs::is_hidden("integrations.allowAgentControl"));
assert!(!prefs::is_hidden("integrations.controlPort"));
+6 -6
View File
@@ -344,7 +344,7 @@ pub type AutomationCommandFn = Box<dyn Fn(&str, &Value) -> Result<(), String>>;
pub type AutomationAuthorizeFn = fn(&str, &Value) -> photocraft_engine::Result<()>;
/// The automation half of [`Services`]: what control and MCP requests may read, write and run.
/// Replaced as a whole when Preferences › AI Integrations starts the agent connection or
/// Replaced as a whole when Preferences › MCP starts the agent connection or
/// changes its folders ([`Services::set_automation`]).
#[derive(Default)]
pub struct AutomationServices {
@@ -356,7 +356,7 @@ pub struct AutomationServices {
pub authorize: Option<AutomationAuthorizeFn>,
}
/// Preferences › AI Integrations: the agent connection as the dialog and `ui.inspect` show it.
/// Preferences › MCP: the agent connection as the dialog and `ui.inspect` show it.
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AgentLinkStatus {
@@ -370,7 +370,7 @@ pub struct AgentLinkStatus {
pub mcp_command: Option<String>,
}
/// What [`Services::agent_link`] did after the AI Integrations settings changed.
/// What [`Services::agent_link`] did after the MCP settings changed.
#[derive(Default)]
pub struct AgentLink {
/// Requests from agents on a connection that just started (or moved to another port).
@@ -382,7 +382,7 @@ pub struct AgentLink {
pub status: AgentLinkStatus,
}
/// Starts, moves or stops the agent connection to match Preferences › AI Integrations.
/// Starts, moves or stops the agent connection to match Preferences › MCP.
pub type AgentLinkFn = Box<dyn FnMut(&photocraft_engine::prefs::Integrations, &egui::Context) -> AgentLink>;
/// Adds PhotoCraft to an MCP client (`claude-desktop`, `claude-code`, `cursor`), returning what
/// was done, or returns the configuration to paste into any client (`json`).
@@ -582,10 +582,10 @@ pub struct Services {
/// each step of `actions.play`. Installed on the session only while a control request or
/// an automation-driven [`PhotocraftApp::run`] runs, so a local play of a recorded `file.*` step still works.
pub automation_authorize: Option<AutomationAuthorizeFn>,
/// Preferences › AI Integrations (desktop): starts, moves or stops the agent connection when
/// Preferences › MCP (desktop): starts, moves or stops the agent connection when
/// its settings change. `None` on the web, and when `--control` manages the connection.
pub agent_link: Option<AgentLinkFn>,
/// Preferences › AI Integrations' buttons that add PhotoCraft to MCP clients (desktop).
/// Preferences › MCP' buttons that add PhotoCraft to MCP clients (desktop).
pub agent_clients: Option<AgentClientFn>,
/// Encode an RGBA8 image as PNG (used for screenshots and `ui.render`).
pub encode_png: Option<EncodePngFn>,
+4 -4
View File
@@ -17,9 +17,9 @@ photocraft --control 7878 --control-token-file /private/path/photocraft-control.
If the file does not exist, PhotoCraft creates it with a fresh 256-bit token. On Unix the new file is mode `0600`; on Windows, protect it with an appropriate user-only ACL. An existing file is reused. If neither a token nor token file is configured, PhotoCraft generates a token for that launch and writes it to standard error. `PHOTOCRAFT_CONTROL_TOKEN` and `PHOTOCRAFT_CONTROL_TOKEN_FILE` are the environment-variable equivalents. A flag wins over its variable and an empty variable counts as unset; with `--control` (or `PHOTOCRAFT_CONTROL_PORT`), a token together with a token file, from flags or variables, is a usage error (exit status 2). Without it no token is read, so the pair is ignored.
### Without `--control`: Preferences › Integrations
### Without `--control`: Preferences › MCP
An app started from the Dock, the Start menu or a file manager has no command line. Edit › Preferences › AI Integrations starts and stops the control server while the app runs: turning *Let AI agents connect* on or off, or changing its port or folders, applies at once, with no restart.
An app started from the Dock, the Start menu or a file manager has no command line. Edit › Preferences › MCP starts and stops the control server while the app runs: turning *Let AI agents connect* on or off, or changing its port or folders, applies at once, with no restart.
| Preference | What it does |
|---|---|
@@ -418,7 +418,7 @@ magenta alignment lines. `ui.pointer` drives the same code, so agents get identi
- **Headless** (`photocraft-cli mcp`): an in-process `photocraft_engine::Session`. There is no window. CPU composition is the default; `--gpu` or `PHOTOCRAFT_GPU=1` enables optional GPU rendering with automatic CPU fallback.
- **Bridge** (`photocraft-cli mcp --bridge 127.0.0.1:7878 --control-token-file <path>`): every tool is forwarded to a running `photocraft --control 7878 --control-token-file <path>` over this protocol, so agents see and drive the live app. Explicit `--gpu` / `--no-gpu` flags are rejected with a usage error because the desktop controls rendering; `PHOTOCRAFT_GPU` is ignored in bridge mode. `--bridge 7878` is short for `--bridge 127.0.0.1:7878`. With no `--bridge`, `PHOTOCRAFT_CONTROL_PORT` selects the bridge port (`127.0.0.1:<port>`), and the CLI says so on standard error; with neither (or the variable empty), the MCP runs headless. A value that is not a port is a usage error naming the variable. `--automation-read-root` or `--automation-write-root` with the variable set is a usage error, since the bridge would drop the roots.
- **Live** (`photocraft-cli mcp --live`): the bridge, with the address and token read before every tool call from `agent-connection.json` in the app's settings folder. The app publishes that file while Edit › Preferences › AI Integrations › *Let AI agents connect* is on (not with `--control`), and removes it when the connection stops; a file left by a crash fails the connection probe and counts as no app. See [MCP conventions](mcp.md#connecting-the-desktop-app-no-terminal).
- **Live** (`photocraft-cli mcp --live`): the bridge, with the address and token read before every tool call from `agent-connection.json` in the app's settings folder. The app publishes that file while Edit › Preferences › MCP › *Let AI agents connect* is on (not with `--control`), and removes it when the connection stops; a file left by a crash fails the connection probe and counts as no app. See [MCP conventions](mcp.md#connecting-the-desktop-app-no-terminal).
`ui.inspect` reports the connection as `agentLink`: `port` while agents can connect, `launchFlags` when `--control` manages it, `error`, and `mcpCommand` (how MCP clients start the CLI).
@@ -488,7 +488,7 @@ One explicit write-root flag overrides `PHOTOCRAFT_AUTOMATION_WRITE_ROOT`. These
variables are not supported by headless `photocraft-cli mcp` or `serve`; supply flags explicitly.
In MCP bridge mode, configure roots on the desktop process. Supplying root flags to
`photocraft-cli mcp --bridge` is a usage error; a bridge client cannot grant filesystem access.
With *Let AI agents connect*, the folders chosen in Preferences › AI Integrations (`readRoot` /
With *Let AI agents connect*, the folders chosen in Preferences › MCP (`readRoot` /
`writeRoot`) are the agents' roots; `mcp --live` uses them for a headless session only when the
app's *When PhotoCraft is closed* choice (or `--when-closed headless`) asks for one.
+1 -1
View File
@@ -324,7 +324,7 @@ At startup the desktop lists recovery metadata, then decodes one document at a t
- **Headless:** `photocraft-cli mcp --automation-read-root <project> --automation-read-root <library> --automation-write-root <project>`. It drives an in-process engine session with ordered read directories and one write directory.
- **Live app:** start `photocraft --control 7878 --control-token-file <private-path> --automation-read-root <project> --automation-read-root <library> --automation-write-root <project>`, then run `photocraft-cli mcp --bridge 127.0.0.1:7878 --control-token-file <private-path>`. The desktop process owns the roots; root flags on the bridging CLI are a usage error. See `docs/control-protocol.md#mcp-bridge`.
- **Live app, no flags:** turn on Edit › Preferences › AI Integrations › Let AI agents connect, then point the MCP client at `photocraft-cli mcp --live` (the panel's buttons, or `photocraft-cli mcp install --client <claude-desktop|claude-code|cursor|json>`, do it). The app publishes its port and token file in `agent-connection.json` in the settings folder; `--live` reads it on every call. See [MCP conventions](mcp.md#connecting-the-desktop-app-no-terminal). Test it against a scratch settings folder with `PHOTOCRAFT_CONFIG_DIR`, which both the app and the CLI honour.
- **Live app, no flags:** turn on Edit › Preferences › MCP › Let AI agents connect, then point the MCP client at `photocraft-cli mcp --live` (the panel's buttons, or `photocraft-cli mcp install --client <claude-desktop|claude-code|cursor|json>`, do it). The app publishes its port and token file in `agent-connection.json` in the settings folder; `--live` reads it on every call. See [MCP conventions](mcp.md#connecting-the-desktop-app-no-terminal). Test it against a scratch settings folder with `PHOTOCRAFT_CONFIG_DIR`, which both the app and the CLI honour.
For headless MCP clients, pass absolute paths to deliberately chosen trusted workspace directories in the launch arguments. Desktop `PHOTOCRAFT_AUTOMATION_READ_ROOT` and `PHOTOCRAFT_AUTOMATION_WRITE_ROOT` environment variables do **not** grant headless CLI access. Omitting a root flag deliberately denies that direction of access.
+1 -1
View File
@@ -2,7 +2,7 @@
## Connecting the desktop app (no terminal)
1. In PhotoCraft, open **Edit › Preferences › AI Integrations** and turn on **Let AI agents
1. In PhotoCraft, open **Edit › Preferences › MCP** and turn on **Let AI agents
connect (MCP)**. Optionally choose the folders agents can open from and save to, and what
happens when an agent needs PhotoCraft while it is closed (open it, work without a window,
or ask the user to open it). Click **Apply** or **OK**.
+2 -2
View File
@@ -1,6 +1,6 @@
# Roadmap
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-14 · **Change:** minor (M11: the desktop app connects to MCP clients from Preferences › AI Integrations, no terminal; alpha gate, focus and estimates unchanged) · **Target:** Adobe Photoshop 2026
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-12 · **Change:** minor (M11: the desktop app connects to MCP clients from Edit › Preferences › MCP, no terminal, no restart; alpha gate, focus and estimates unchanged) · **Target:** Adobe Photoshop 2026
- UI.5: Panels can detach, join other tab groups, split, resize and redock through shared docking transactions. Custom layouts persist with workspaces, respect workspace locking, and retain collapse flags for intact native groups.
@@ -116,7 +116,7 @@ Each milestone has a **definition of done (DoD)** and must leave `main` green on
| Date | Change | Summary |
|---|---|---|
| 2026-10-14 | minor | M11: AI Integrations connects MCP clients to the running app without a terminal; milestones, alpha gate and estimates unchanged |
| 2026-11-12 | minor | M11: Edit › Preferences › MCP connects MCP clients to the running app without a terminal or restart; milestones, alpha gate and estimates unchanged |
| 2026-10-11 | minor | Linked adaptive Unsharp Mask performance and quality evidence; milestones, alpha gate and estimates unchanged |
| 2026-10-10 | minor | Photomerge is implemented; real-world quality validation remains open |
| 2026-10-10 | minor | Alpha gate table (core-workflow gate): passes, stage stays alpha |
+1 -1
View File
@@ -120,7 +120,7 @@ echo "==> assembling $APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
# Executable and icon carry the display name (CFBundleExecutable / CFBundleIconFile).
cp "$WORK/bin/photocraft" "$APP/Contents/MacOS/PhotoCraft"
# The CLI too, beside the app: Preferences › AI Integrations points MCP clients at it
# The CLI too, beside the app: Preferences › MCP points MCP clients at it
# (`photocraft-cli mcp --live`), and it starts the app when an agent needs it.
cp "$WORK/bin/photocraft-cli" "$APP/Contents/MacOS/photocraft-cli"
cp "$ROOT/assets/app-icon/photocraft.icns" "$APP/Contents/Resources/PhotoCraft.icns"
+1 -1
View File
@@ -85,4 +85,4 @@ note = "automation/tests/it/agent_tasks.rs runs 10 workflows over MCP"
id = "AUTO-MCP-LIVE"
target = "Connect an MCP client to the running app without a terminal (no flags, ports or tokens to copy)"
status = "done"
note = "2026-10-14: Preferences › AI Integrations › Let AI agents connect starts the loopback control server at runtime and publishes agent-connection.json; photocraft-cli mcp --live finds the app on every call (launch / headless / error while it is closed); Add to Claude Desktop / Claude Code / Cursor and mcp install --client. automation/tests/mcp_live.rs, apps/photocraft/src/agent_link.rs tests"
note = "2026-10-14: Preferences › MCP › Let AI agents connect starts the loopback control server at runtime and publishes agent-connection.json; photocraft-cli mcp --live finds the app on every call (launch / headless / error while it is closed); Add to Claude Desktop / Claude Code / Cursor and mcp install --client. automation/tests/mcp_live.rs, apps/photocraft/src/agent_link.rs tests"