Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(host): edit an installed connector in place (#316)

disbenovibdf34c21e0bf
diff --git a/docs/features/connector-credentials.md b/docs/features/connector-credentials.md
index 408f807b..229ed344 100644
--- a/docs/features/connector-credentials.md
+++ b/docs/features/connector-credentials.md
@@ -51,6 +51,9 @@ A readiness check starts the connector, performs MCP initialize and tools/list,
and stops the check process. It never invokes a business tool. Failures and a
90-second timeout remain visible and retryable. Package acquisition is performed
by the configured runtime (npx, uvx, Docker, etc.), so that runtime must be present.
+A local connector is found and started the way a bot runs it (`shell::program`, so
+npm's `.cmd` shims on Windows too), in the folder of the first bot that has it on, or
+the host's folder when none does, so a relative path means the same thing in both.
Installing a registry connector that is already installed (Add again after a failed
check, or Connect on a request card) keeps it as it is when nothing new is typed and
@@ -58,6 +61,21 @@ it would run the same way, so its sign-in survives. New values or another way to
it (package runtime or hosted) rebuild it in place, under the same id, so each bot
keeps it on or off as before (`install_server` in `host/src/market/install.rs`).
+Editing a custom local connector (`updateConnector`, loopback only, no form in the
+apps) keeps its id and each bot's choice. Omitted fields stay; `command` is an
+executable path, never split into arguments; `args` replaces the list and `args: []`
+clears it; `env` merges, with `null` removing a key. A change to how it runs (`command`,
+`args`, `env`) is checked on the edited copy and exactly that copy is saved if it passes,
+so a typo can't break a working connector and an error means the edit changed nothing. A
+save by anything else during the check refuses the edit, so overlapping edits never combine
+into settings nobody checked. A new `name` or `description` alone starts nothing: it saves
+even while the server can't start, `verify` is null in the answer and no bot restarts.
+Otherwise the bots that have the connector on are told to rebuild their tools. An agent that
+can resume restarts whole before its next turn (not only this connector's process); one
+that can't keeps its session, and the old definition, until its next new session. A bot
+that can't be told is logged and doesn't fail the saved edit. Registry and remote
+connectors are refused (`host/src/market/connector_update.rs`).
+
## Conversation requests
The built-in `connectors` MCP offers search_connectors, list_connectors,
diff --git a/docs/features/marketplace.md b/docs/features/marketplace.md
index 036f2a19..30d2de6d 100644
--- a/docs/features/marketplace.md
+++ b/docs/features/marketplace.md
@@ -30,7 +30,7 @@ Extensions shows one section at a time — Agents, Connectors, or Skills — and
Registry package installs use pinned package references: npm, PyPI and NuGet require the package’s own version; OCI uses the tag or SHA-256 digest already in its image identifier, even when the separate package version is omitted. Untagged images, `latest` tags without a digest, and invalid references are rejected; a server-level version does not pin the executable package.
-A custom connector is a command line (split like a shell), a URL, or a pasted MCP config (`importConnectors {config}`: the `mcpServers` / `servers` JSON from READMEs, Claude, Cursor or VS Code, or one server's entry); every server in a config is added.
+A custom connector is a command line (split like a shell), a URL, or a pasted MCP config (`importConnectors {config}`: the `mcpServers` / `servers` JSON from READMEs, Claude, Cursor or VS Code, or one server's entry); every server in a config is added, or none when one of them isn't valid. An `args` list must be all strings, in a config or a custom install; anything else is refused, not dropped.
A connector installed on the computer (or an app connected through Composio) is turned on for every existing bot, and a new bot starts with all of them on; each bot can turn one off in its settings. An enabled connector is passed to the agent as an MCP server when its session starts or resumes. Local connectors are spawned by the agent; remote ones always go through the host's stdio proxy (`codync-host mcp remote`, `host/src/mcp.rs`), so they work with agents that only speak stdio and always carry a fresh token. The proxy speaks streamable HTTP and falls back to the older HTTP+SSE transport when the first POST fails with 400/404/405, as the MCP spec suggests. Each server is named after its connector id. codex-acp leaves out a requested server whose name Codex's own config already uses (its `[mcp_servers.<name>]`, disabled ones too, in `$CODEX_HOME` (a saved one first, else `~/.codex`), `/etc/codex` or a `.codex` folder from the bot's folder up) and says so only in a startup notice, so for a Codex bot such a server is named `codync-<name>` instead, or `codync-<name>-2`… when that is taken too (`agent/bot/codex_names.rs`, #217). pi-acp never hands a session's servers to pi, so a Pi bot gets them when its agent starts instead (`agent/bot/pi_tools.rs`): `PI_ACP_PI_COMMAND` points pi-acp at Codync's launcher (`~/.codync/pi/pi-codync`, `pi-codync.cmd` on Windows), which starts pi with the extension beside it (`codync.js`) registering the servers in `CODYNC_PI_MCP_SERVERS` (`pi.registerMcpServer`, so pi 0.99 or later; older pi starts without them, and nothing is registered when pi-acp's own bridge `PI_ACP_MCP_SERVERS` is there). Each gets a call timeout past the host's longest (pi's default is 60 s), and a server whose name pi's own `mcp.json` has (pi's agent folder's or the project's `.pi`, `-` and `_` alike, disabled ones too) is renamed as for Codex, since pi would use its own entry. The calls of Codync's own `chat` and `memory` servers are recognized by the name the agent got, so a user's own `memory` server stays in the working steps.
diff --git a/docs/guides/connector-verification.md b/docs/guides/connector-verification.md
index e4ec0ea7..6f1e0d42 100644
--- a/docs/guides/connector-verification.md
+++ b/docs/guides/connector-verification.md
@@ -40,6 +40,11 @@ not a released-build certification.
tools in a real subprocess. Public listings omit credentials and command args.
- Check the connector record is encrypted in SQLite; restart the host and verify
it can recover credentials through the OS Keychain.
+- Edit a custom local connector through `updateConnector` (what an edit does:
+ [connector credentials](../features/connector-credentials.md)): new `args` keep
+ the id, verify as ready and `connectorRuntime` returns the new command line; an edit
+ that won't start leaves what's saved as it was. Bot assignments and the bots' tool
+ refresh are not covered here (`host/src/market/connector_update.rs` tests them).
- Import a pasted `mcpServers` configuration and verify the resulting connector.
- Reject a missing runtime and a malformed MCP initialize response.
- Verify authenticated remote MCP using JSON and streamable HTTP SSE responses,
diff --git a/docs/reference/analytics-events.md b/docs/reference/analytics-events.md
index 1891d92e..c3ad8b20 100644
--- a/docs/reference/analytics-events.md
+++ b/docs/reference/analytics-events.md
@@ -93,6 +93,7 @@ host answers and sends it once the host is up.
| `connector_installed` | host | `installConnector`; a Composio app once its connection is `active` | `connector` (catalog name, `composio` or `custom`) |
| `connectors_imported` | host | `importConnectors` | `count` |
| `connector_removed` | host | `removeConnector` | — |
+| `connector_updated` | host | `updateConnector`, whether or not the edit was saved | `outcome` (`ready`: how it runs changed and it passed its check; `saved`: name or description only; `failed`); on failure `error` (`invalid`, `refused`, `wont_start`, `conflict`, `other`). Never the connector, its fields, values or the error's message |
| `connector_signin_started` | host | `connectorSignIn` | — |
| `skill_installed` | host | `installSkill` | `custom` |
| `skill_removed` | host | `removeSkill` | — |
diff --git a/host/src/analytics.rs b/host/src/analytics.rs
index 8e26fc27..82a38897 100644
--- a/host/src/analytics.rs
+++ b/host/src/analytics.rs
@@ -90,6 +90,7 @@ pub enum Event {
ConnectorsImported,
BotsImported,
ConnectorRemoved,
+ ConnectorUpdated,
ConnectorSigninStarted,
SkillInstalled,
SkillRemoved,
@@ -159,6 +160,7 @@ impl Event {
Self::ConnectorsImported => "connectors_imported",
Self::BotsImported => "bots_imported",
Self::ConnectorRemoved => "connector_removed",
+ Self::ConnectorUpdated => "connector_updated",
Self::ConnectorSigninStarted => "connector_signin_started",
Self::SkillInstalled => "skill_installed",
Self::SkillRemoved => "skill_removed",
diff --git a/host/src/analytics/observe.rs b/host/src/analytics/observe.rs
index 94c03ae5..90be6f50 100644
--- a/host/src/analytics/observe.rs
+++ b/host/src/analytics/observe.rs
@@ -129,6 +129,7 @@ fn call_event(method: &str, b: &Value, p: &mut Map<String, Value>) -> Option<Eve
"importConnectors" => Event::ConnectorsImported,
"importBots" => Event::BotsImported,
"removeConnector" => Event::ConnectorRemoved,
+ "updateConnector" => Event::ConnectorUpdated,
"connectorSignIn" => Event::ConnectorSigninStarted,
"installSkill" => {
p.insert("custom".into(), (!b["source"].is_string()).into());
@@ -205,8 +206,8 @@ pub fn observe_call(hub: &Hub, caller: &Caller, method: &str, b: &Value) -> Opti
}
/// What only the answer tells: how many connectors or bots an import added, whether a Composio app is
-/// connected yet (its sign-in is polled until the connection is active), and whether a published
-/// artifact's card went into its bot's chat. `None`: not an event.
+/// connected yet (its sign-in is polled until the connection is active), whether a published
+/// artifact's card went into its bot's chat, and whether a connector edit needed a check. `None`: not an event.
pub fn answered(event: Event, mut p: Map<String, Value>, answer: &Value) -> Option<Map<String, Value>> {
match event {
Event::ConnectorsImported => {
@@ -224,6 +225,9 @@ pub fn answered(event: Event, mut p: Map<String, Value>, answer: &Value) -> Opti
Event::ArtifactPublished => {
p.insert("card".into(), answer["card"].is_null().into());
}
+ Event::ConnectorUpdated => {
+ p.insert("outcome".into(), if answer["verify"].is_null() { "saved" } else { "ready" }.into());
+ }
Event::ConnectorInstalled
if p.get("connector").and_then(Value::as_str) == Some("composio") && answer["status"] != "active" =>
{
@@ -235,12 +239,23 @@ pub fn answered(event: Event, mut p: Map<String, Value>, answer: &Value) -> Opti
}
/// What a failed call reports: a `network*` call's failure keeps what it was (`via` or
-/// `action`) as `network_failed` with `stage` `action`; other failures report nothing.
-pub fn failed(event: Event, mut p: Map<String, Value>) -> Option<(Event, Map<String, Value>)> {
- matches!(event, Event::NetworkJoined | Event::NetworkChanged).then(|| {
- p.insert("stage".into(), "action".into());
- (Event::NetworkFailed, p)
- })
+/// `action`) as `network_failed` with `stage` `action`, and a connector edit reports its category,
+/// never the message; other failures report nothing.
+pub fn failed(event: Event, mut p: Map<String, Value>, error: &anyhow::Error) -> Option<(Event, Map<String, Value>)> {
+ match event {
+ Event::NetworkJoined | Event::NetworkChanged => {
+ p.insert("stage".into(), "action".into());
+ Some((Event::NetworkFailed, p))
+ }
+ Event::ConnectorUpdated => {
+ let category =
+ error.downcast_ref::<crate::market::connector_update::EditFailed>().map_or("other", |e| e.category());
+ p.insert("outcome".into(), "failed".into());
+ p.insert("error".into(), category.into());
+ Some((event, p))
+ }
+ _ => None,
+ }
}
/// The bot settings a patch changes, by name (never their values), sorted.
diff --git a/host/src/analytics/observe/tests.rs b/host/src/analytics/observe/tests.rs
index 339d8673..f81cef9e 100644
--- a/host/src/analytics/observe/tests.rs
+++ b/host/src/analytics/observe/tests.rs
@@ -104,6 +104,36 @@ fn settings_routines_screen_and_devices() {
assert_eq!(props("installHostUpdate", &json!({"force": true})).map(|(e, _)| e), Some(Event::HostUpdateInstalled));
}
+#[test]
+fn a_connector_edit_reports_how_it_ended_and_nothing_it_changed() {
+ use crate::market::connector_update::EditFailure;
+ let edit = json!({"id": "mine", "command": "/Users/me/bin/server", "env": {"API_KEY": "secret"}});
+ let (event, p) = observe(&Caller::Local, "updateConnector", &edit).expect("tracked");
+ assert_eq!(event, Event::ConnectorUpdated);
+ let saved = |answer: Value| Value::Object(answered(event, p.clone(), &answer).expect("reported"));
+ let checked = json!({"connector": {"id": "mine"}, "verify": {"status": "ready"}});
+ assert_eq!(saved(checked), json!({"client": "local", "outcome": "ready"}));
+ let unchecked = json!({"connector": {"id": "mine"}, "verify": null});
+ assert_eq!(saved(unchecked), json!({"client": "local", "outcome": "saved"}));
+
+ let refused = |error: anyhow::Error| {
+ let (event, p) = failed(event, p.clone(), &error).expect("reported");
+ assert_eq!(event, Event::ConnectorUpdated);
+ Value::Object(p)
+ };
+ for (failure, category) in [
+ (EditFailure::Invalid, "invalid"),
+ (EditFailure::Refused, "refused"),
+ (EditFailure::WontStart, "wont_start"),
+ (EditFailure::Conflict, "conflict"),
+ ] {
+ let reported = refused(failure.error("/Users/me/bin/server won't start"));
+ assert_eq!(reported, json!({"client": "local", "outcome": "failed", "error": category}));
+ }
+ let locked = refused(anyhow::anyhow!("the vault is locked"));
+ assert_eq!(locked, json!({"client": "local", "outcome": "failed", "error": "other"}));
+}
+
#[test]
fn connectors_skills_and_agents() {
assert_eq!(
@@ -260,7 +290,7 @@ async fn store_lookups_add_fields_choice_and_platform() {
fn a_failed_network_call_reports_what_it_was_and_others_nothing() {
let failed_call = |method: &str, b: &Value| {
let (event, p) = observe(&Caller::Local, method, b)?;
- failed(event, p).map(|(e, p)| (e, Value::Object(p)))
+ failed(event, p, &anyhow::anyhow!("refused")).map(|(e, p)| (e, Value::Object(p)))
};
assert_eq!(
failed_call("networkJoin", &json!({"invite": "codync-network:…", "name": "laptop"})),
diff --git a/host/src/api/devices.rs b/host/src/api/devices.rs
index b3f9f1f3..492ffdce 100644
--- a/host/src/api/devices.rs
+++ b/host/src/api/devices.rs
@@ -57,6 +57,8 @@ const LOCAL_ONLY: &[&str] = &[
"connectorTarget",
"connectorRuntime",
"connectorCall",
+ // It can point a connector that holds credentials at any program; no app edits connectors yet.
+ "updateConnector",
"claimSign",
"unclaim",
"devices",
diff --git a/host/src/api/marketplace.rs b/host/src/api/marketplace.rs
index 1e814641..827db665 100644
--- a/host/src/api/marketplace.rs
+++ b/host/src/api/marketplace.rs
@@ -25,18 +25,14 @@ pub(super) async fn call(hub: &Arc<Hub>, caller: &Caller, method: &str, b: Value
}
let value = value
.as_str()
- .filter(|s| !s.is_empty() && s.len() <= 64 * 1024)
+ .filter(|s| !s.is_empty() && s.len() <= market::MAX_CREDENTIAL_BYTES)
.ok_or_else(|| anyhow!("Invalid credential value"))?;
values.insert(key.clone(), value.to_owned());
}
Ok(())
})?;
let ready = market::verify::verify(&hub.store, id, hub.port).await?;
- for row in hub.store.bots()? {
- if !row.deleted && !row.config.is_group() && row.config.connectors.iter().any(|c| c == id) {
- hub.send_cmd(&row.config.id, Cmd::RefreshTools)?;
- }
- }
+ refresh_tools_for_bots_using(hub, id);
ready
}
"credentialStatus" => market::passwords::status(&hub.store)?,
@@ -143,6 +139,15 @@ pub(super) async fn call(hub: &Arc<Hub>, caller: &Caller, method: &str, b: Value
enable_new(hub, Installed::Connectors, &before)?;
json!({"connector": c})
}
+ "updateConnector" => {
+ let id = str_arg(&b, "id")?;
+ let updated = market::connector_update::update_custom_connector(&hub.store, id, &b, hub.port).await?;
+ // Without a check how it runs didn't change, so no bot has anything to pick up.
+ if !updated["verify"].is_null() {
+ refresh_tools_for_bots_using(hub, id);
+ }
+ updated
+ }
"connectorSignIn" => {
// The browser can only reach this host's loopback page when it runs on this computer.
let callback = if matches!(caller, Caller::Local) {
@@ -191,3 +196,22 @@ pub(super) async fn call(hub: &Arc<Hub>, caller: &Caller, method: &str, b: Value
_ => return Ok(ControlFlow::Continue(b)),
}))
}
+
+/// A connector reaches an agent as part of its tools, so a bot that has it turned on asks for them
+/// again. An agent that can resume restarts whole before its next turn; one that can't keeps its
+/// session and the old definition until its next new session. No other bot is touched. The change
+/// is already saved, so a bot that can't hear of it is logged and doesn't stop the others.
+fn refresh_tools_for_bots_using(hub: &Hub, id: &str) {
+ let bots = match market::bots_using(&hub.store, id) {
+ Ok(bots) => bots,
+ Err(error) => {
+ tracing::warn!(connector = id, error = format!("{error:#}"), "couldn't list the bots using a connector");
+ return;
+ }
+ };
+ for row in bots {
+ if let Err(error) = hub.send_cmd(&row.config.id, Cmd::RefreshTools) {
+ tracing::warn!(bot = %row.config.id, error = format!("{error:#}"), "couldn't refresh a bot's tools");
+ }
+ }
+}
diff --git a/host/src/api/mod.rs b/host/src/api/mod.rs
index f6b9ef55..3769ff12 100644
--- a/host/src/api/mod.rs
+++ b/host/src/api/mod.rs
@@ -62,7 +62,7 @@ pub async fn dispatch(hub: &Arc<Hub>, caller: &Caller, method: &str, b: Value) -
let result = route(hub, caller, method, b).await;
let report = observed.and_then(|(event, properties)| match &result {
Ok(answer) => crate::analytics::answered(event, properties, answer).map(|p| (event, p)),
- Err(_) => crate::analytics::failed(event, properties),
+ Err(error) => crate::analytics::failed(event, properties, error),
});
if let Some((event, properties)) = report {
crate::analytics::capture(hub, event, properties);
diff --git a/host/src/market/command_line.rs b/host/src/market/command_line.rs
new file mode 100644
index 00000000..e87b5f80
--- /dev/null
+++ b/host/src/market/command_line.rs
@@ -0,0 +1,76 @@
+//! A connector's command line: the program and its arguments.
+
+use anyhow::{Result, anyhow, bail};
+use serde_json::Value;
+
+/// A `command` line and an optional `args` list: the program, then its arguments.
+/// Without `args` (or with `null`) the line is split like a shell would (quotes work).
+pub(super) fn split_command(line: &str, args: Option<&Value>) -> Result<(Option<String>, Vec<String>)> {
+ let line = line.trim();
+ if line.is_empty() {
+ bail!("give a command");
+ }
+ if let Some(args) = args.filter(|a| !a.is_null()) {
+ return Ok((Some(line.to_owned()), string_args(args)?));
+ }
+ let mut words = shlex::split(line).ok_or_else(|| anyhow!("the command has an unclosed quote"))?.into_iter();
+ Ok((words.next(), words.collect()))
+}
+
+/// An `args` list, every item of it a string.
+pub(super) fn string_args(args: &Value) -> Result<Vec<String>> {
+ args.as_array()
+ .and_then(|args| args.iter().map(|a| a.as_str().map(str::to_owned)).collect())
+ .ok_or_else(|| anyhow!("`args` are strings"))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::split_command;
+ use crate::market::{add_custom_connector, connectors, import_connectors};
+ use serde_json::json;
+
+ #[test]
+ fn a_line_splits_only_without_args() {
+ let split = |args: Option<serde_json::Value>| split_command("npx \"my server\"", args.as_ref()).expect("split");
+ let words = (Some("npx".to_owned()), vec!["my server".to_owned()]);
+ assert_eq!(split(None), words);
+ assert_eq!(split(Some(json!(null))), words, "null is the same as no args");
+ let whole = (Some("npx \"my server\"".to_owned()), vec!["-y".to_owned()]);
+ assert_eq!(split(Some(json!(["-y"]))), whole);
+ }
+
+ #[test]
+ fn args_that_are_not_strings_are_refused() {
+ for args in [json!(42), json!("-y"), json!(["--port", 8080])] {
+ let err = split_command("node", Some(&args)).expect_err("refused").to_string();
+ assert!(err.contains("`args` are strings"), "{err}");
+ }
+ assert!(split_command(" ", None).is_err());
+ }
+
+ #[tokio::test]
+ async fn install_and_import_read_args_the_same_way() {
+ let store = crate::store::Store::open(std::path::Path::new(":memory:")).expect("store");
+ add_custom_connector(&store, &json!({"name": "One", "command": "npx server", "args": null}))
+ .await
+ .expect("null args");
+ import_connectors(&store, r#"{"mcpServers": {"Two": {"command": "uvx tool", "args": null}}}"#)
+ .await
+ .expect("null args");
+ let lines = |store: &crate::store::Store| -> Vec<(Option<String>, Vec<String>)> {
+ connectors(store).expect("read").into_iter().map(|c| (c.command, c.args)).collect()
+ };
+ let split = vec![
+ (Some("npx".to_owned()), vec!["server".to_owned()]),
+ (Some("uvx".to_owned()), vec!["tool".to_owned()]),
+ ];
+ assert_eq!(lines(&store), split);
+
+ let bad = json!({"name": "Three", "command": "node", "args": ["--port", 8080]});
+ assert!(add_custom_connector(&store, &bad).await.is_err());
+ let pasted = r#"{"mcpServers": {"Four": {"command": "node"}, "Five": {"command": "node", "args": [1]}}}"#;
+ assert!(import_connectors(&store, pasted).await.is_err());
+ assert_eq!(lines(&store), split, "a refused install or paste adds nothing");
+ }
+}
diff --git a/host/src/market/connector_update.rs b/host/src/market/connector_update.rs
new file mode 100644
index 00000000..1b0e700c
--- /dev/null
+++ b/host/src/market/connector_update.rs
@@ -0,0 +1,402 @@
+//! Editing an installed connector in place, so its id and every bot's reference to it stay.
+
+use super::command_line::string_args;
+use super::{Connector, MAX_CREDENTIAL_BYTES, connectors, update_connectors, verify};
+use anyhow::{Result, anyhow, bail};
+use serde_json::{Value, json};
+use std::collections::BTreeMap;
+
+/// What went wrong with an edit, in words analytics may report: its message can name the user's paths.
+#[derive(Clone, Copy, Debug)]
+pub enum EditFailure {
+ /// The edit itself: a bad field, or a connector that doesn't exist.
+ Invalid,
+ /// A connector this method doesn't edit.
+ Refused,
+ /// The edited connector failed its readiness check.
+ WontStart,
+ /// Something else saved the connector during the check.
+ Conflict,
+}
+
+impl EditFailure {
+ /// An error that reads as `why` and carries this category.
+ pub fn error(self, why: impl std::fmt::Display) -> anyhow::Error {
+ EditFailed { failure: self, message: format!("{why:#}") }.into()
+ }
+}
+
+#[derive(Debug)]
+pub struct EditFailed {
+ failure: EditFailure,
+ message: String,
+}
+
+impl EditFailed {
+ pub fn category(&self) -> &'static str {
+ match self.failure {
+ EditFailure::Invalid => "invalid",
+ EditFailure::Refused => "refused",
+ EditFailure::WontStart => "wont_start",
+ EditFailure::Conflict => "conflict",
+ }
+ }
+}
+
+impl std::fmt::Display for EditFailed {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.write_str(&self.message)
+ }
+}
+
+impl std::error::Error for EditFailed {}
+
+/// Edits an installed local connector: omitted fields keep their value, `args` replaces the
+/// argument list, and `env` merges, with `null` removing a key. A change to how it runs is checked
+/// first and exactly what started is what gets saved, so an error means this edit changed nothing,
+/// and overlapping edits never combine. A new name or description starts nothing: `verify` is null.
+pub async fn update_custom_connector(store: &crate::store::Store, id: &str, b: &Value, port: u16) -> Result<Value> {
+ let before = connectors(store)?
+ .into_iter()
+ .find(|c| c.id == id)
+ .ok_or_else(|| EditFailure::Invalid.error("Unknown connector"))?;
+ ensure_custom_local(&before).map_err(|e| EditFailure::Refused.error(e))?;
+ let after = edited(&before, b).map_err(|e| EditFailure::Invalid.error(e))?;
+ let runs_the_same = after.command == before.command && after.args == before.args && after.env == before.env;
+ let check = if runs_the_same {
+ None
+ } else {
+ Some(verify::check_connector(store, &after, port).await.map_err(|e| EditFailure::WontStart.error(e))?)
+ };
+ let connector = update_connectors(store, |all| {
+ let c = all.iter_mut().find(|c| c.id == id).ok_or_else(|| EditFailure::Conflict.error("Unknown connector"))?;
+ // The check can take a minute: a save in between means it didn't prove what would be saved now.
+ if *c != before {
+ let why = format!("{} changed while it was being checked: try again", before.name);
+ return Err(EditFailure::Conflict.error(why));
+ }
+ let public = after.public();
+ *c = after;
+ Ok(public)
+ })?;
+ Ok(json!({"connector": connector, "verify": check}))
+}
+
+/// Registry installs rebuild their command line from the registry, and a remote connector's
+/// URL and OAuth handling are the registry's or the user's to redo, so those are refused here.
+fn ensure_custom_local(c: &Connector) -> Result<()> {
+ if c.command.is_none() {
+ bail!("{} is a remote connector: remove it and add the URL you want", c.name);
+ }
+ if c.registry_name.is_some() {
+ bail!("{} came from the MCP registry: install it again to change how it runs", c.name);
+ }
+ Ok(())
+}
+
+/// `before` with the edit applied. Its `command` is the executable, never split into arguments.
+fn edited(before: &Connector, b: &Value) -> Result<Connector> {
+ let mut c = before.clone();
+ if let Some(name) = text(b, "name")?.filter(|s| !s.is_empty()) {
+ c.name = name;
+ }
+ if let Some(description) = text(b, "description")? {
+ c.description = description;
+ }
+ if let Some(command) = text(b, "command")? {
+ if command.is_empty() {
+ bail!("give a command");
+ }
+ c.command = Some(command);
+ }
+ if let Some(args) = b.get("args").filter(|a| !a.is_null()) {
+ c.args = string_args(args)?;
+ }
+ if let Some(env) = b.get("env") {
+ merge_env(&mut c.env, env)?;
+ }
+ Ok(c)
+}
+
+/// A present text field: `None` when it isn't there, an error when it isn't a string.
+fn text(b: &Value, key: &str) -> Result<Option<String>> {
+ match b.get(key) {
+ None => Ok(None),
+ Some(Value::String(s)) => Ok(Some(s.trim().to_owned())),
+ Some(_) => bail!("`{key}` is a string"),
+ }
+}
+
+/// Sets `changes`' entries in `env`; `null` removes one. An empty value is a real value here, as it
+/// is at install; only the credential form refuses it, because it fills in a secret.
+fn merge_env(env: &mut BTreeMap<String, String>, changes: &Value) -> Result<()> {
+ for (key, value) in changes.as_object().ok_or_else(|| anyhow!("`env` must be an object"))? {
+ if key.is_empty() {
+ bail!("`env` names can't be empty");
+ }
+ match value {
+ Value::Null => {
+ env.remove(key);
+ }
+ Value::String(value) if value.len() <= MAX_CREDENTIAL_BYTES => {
+ env.insert(key.clone(), value.clone());
+ }
+ _ => bail!("`env` values are strings, or null to remove one"),
+ }
+ }
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::api::{devices::Caller, dispatch};
+ use crate::hub::{BotStatus, Hub};
+ use crate::market::{requests, save_connectors};
+ use crate::store::{BotConfig, Store};
+ use std::path::Path;
+ use std::time::Duration;
+
+ fn local() -> Connector {
+ serde_json::from_value(json!({
+ "id": "local", "name": "Local", "description": "kept", "command": "node",
+ "args": ["a.js", "--flag"], "env": {"API_KEY": "one", "GONE": "x"},
+ }))
+ .expect("connector")
+ }
+
+ fn store_with(saved: &[Connector]) -> Store {
+ let store = Store::open(Path::new(":memory:")).expect("store");
+ save_connectors(&store, saved).expect("save");
+ store
+ }
+
+ fn category(error: &anyhow::Error) -> &'static str {
+ error.downcast_ref::<EditFailed>().expect("a categorized failure").category()
+ }
+
+ #[test]
+ fn an_edit_merges_env_and_leaves_what_it_does_not_name() {
+ let edit = json!({"args": ["b.js"], "env": {"API_KEY": "two", "GONE": null, "NEW": "y"}});
+ let c = edited(&local(), &edit).expect("edit");
+ assert_eq!((c.id.as_str(), c.name.as_str(), c.description.as_str()), ("local", "Local", "kept"));
+ assert_eq!((c.command.as_deref(), c.args.as_slice()), (Some("node"), ["b.js".to_owned()].as_slice()));
+ assert_eq!((c.env["API_KEY"].as_str(), c.env["NEW"].as_str()), ("two", "y"));
+ assert!(!c.env.contains_key("GONE"), "null removes a key");
+ let c = edited(&c, &json!({"name": " Renamed ", "description": "new"})).expect("text");
+ assert_eq!((c.name.as_str(), c.description.as_str()), ("Renamed", "new"));
+ }
+
+ #[test]
+ fn a_new_command_keeps_the_arguments_until_they_are_named() {
+ let mut c = local();
+ for command in ["/opt/node-new/bin/node", "C:\\Program Files\\nodejs\\node.exe"] {
+ c = edited(&c, &json!({"command": command})).expect("command only");
+ assert_eq!(c.command.as_deref(), Some(command));
+ assert_eq!(c.args, ["a.js", "--flag"], "omitting args preserves the server entry point");
+ }
+ c = edited(&c, &json!({"command": "node", "args": null})).expect("null args");
+ assert_eq!((c.command.as_deref(), c.args.as_slice()), (Some("node"), local().args.as_slice()));
+ c = edited(&c, &json!({"args": []})).expect("clear arguments");
+ assert!(c.args.is_empty(), "an explicit empty list clears the arguments");
+ }
+
+ #[tokio::test]
+ async fn a_bad_field_changes_nothing() {
+ let saved = local();
+ let store = store_with(std::slice::from_ref(&saved));
+ let oversized = "x".repeat(MAX_CREDENTIAL_BYTES + 1);
+ for (b, why) in [
+ (json!({"command": " "}), "give a command"),
+ (json!({"command": 42}), "`command` is a string"),
+ (json!({"args": 42}), "`args` are strings"),
+ (json!({"args": [1]}), "`args` are strings"),
+ (json!({"name": 7}), "`name` is a string"),
+ (json!({"description": []}), "`description` is a string"),
+ (json!({"env": {"K": 1}}), "`env` values are strings"),
+ (json!({"env": {"K": oversized}}), "`env` values are strings"),
+ (json!({"env": {"": "x"}}), "`env` names can't be empty"),
+ (json!({"env": []}), "`env` must be an object"),
+ (json!({"name": "New", "args": ["b.js"], "env": {"K": 1}}), "`env` values are strings"),
+ ] {
+ let err = update_custom_connector(&store, "local", &b, 0).await.expect_err(why);
+ assert!(err.to_string().contains(why), "{err}");
+ assert_eq!(category(&err), "invalid");
+ let kept = std::slice::from_ref(&saved);
+ assert_eq!(connectors(&store).expect("read"), kept, "{why} left the connector untouched");
+ }
+ }
+
+ #[tokio::test]
+ async fn registry_and_remote_connectors_are_not_edited_in_place() {
+ let mut remote = local();
+ (remote.id, remote.command, remote.url) = ("remote".into(), None, Some("https://example.com/mcp".into()));
+ let mut registry = local();
+ (registry.id, registry.registry_name) = ("registry".into(), Some("io.example/server".into()));
+ let store = store_with(&[remote, registry]);
+ for (id, why) in [("remote", "remote connector"), ("registry", "MCP registry")] {
+ let err = update_custom_connector(&store, id, &json!({"command": "node"}), 0).await.expect_err(id);
+ assert!(err.to_string().contains(why), "{err}");
+ assert_eq!(category(&err), "refused");
+ }
+ }
+
+ /// A connector whose MCP server really starts, and the path of that server's script.
+ fn startable() -> (Connector, String) {
+ let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/credential_mcp.py");
+ let fixture = fixture.to_str().expect("utf-8 path").to_owned();
+ let mut c = local();
+ c.command = Some(if cfg!(windows) { "python" } else { "python3" }.to_owned());
+ c.args = vec![fixture.clone()];
+ c.env = [("API_KEY".to_owned(), "test-private-key".to_owned())].into();
+ (c, fixture)
+ }
+
+ #[tokio::test]
+ async fn overlapping_edits_never_save_a_combination_nobody_checked() {
+ let (saved, fixture) = startable();
+ let args = json!({"args": ["-u", &fixture]});
+ // A new description starts nothing, so it lands while the check on the arguments is running.
+ for other in [json!({"description": "edited"}), json!({"env": {"EXTRA": "x"}})] {
+ let store = store_with(std::slice::from_ref(&saved));
+ let results = tokio::join!(
+ update_custom_connector(&store, "local", &args, 0),
+ update_custom_connector(&store, "local", &other, 0)
+ );
+ let (refused, landed) = match results {
+ (Ok(_), Err(refused)) => (refused, &args),
+ (Err(refused), Ok(_)) => (refused, &other),
+ (first, second) => panic!("one edit lands and one is refused: {first:?}, {second:?}"),
+ };
+ assert!(refused.to_string().contains("try again"), "{refused}");
+ assert_eq!(category(&refused), "conflict");
+ let expected = edited(&saved, landed).expect("a valid edit");
+ assert_eq!(connectors(&store).expect("read"), [expected], "only the checked edit is saved");
+ }
+ }
+
+ #[tokio::test]
+ async fn an_edit_is_saved_only_once_the_connector_starts() {
+ let (mut saved, fixture) = startable();
+ let fixture = fixture.as_str();
+ let store = store_with(std::slice::from_ref(&saved));
+ let stored = || connectors(&store).expect("read");
+
+ let err = update_custom_connector(&store, "missing", &json!({}), 0).await.expect_err("unknown");
+ assert!(err.to_string().contains("Unknown connector"), "{err}");
+ assert_eq!(category(&err), "invalid");
+ for bad in [json!({"command": "/nonexistent/codync-connector-test"}), json!({"env": {"API_KEY": "wrong"}})] {
+ let err = update_custom_connector(&store, "local", &bad, 0).await.expect_err("it won't start");
+ assert_eq!(category(&err), "wont_start");
+ assert_eq!(stored(), [saved.clone()], "a failed check leaves the connector as it was");
+ }
+
+ let updated =
+ update_custom_connector(&store, "local", &json!({"args": ["-u", fixture]}), 0).await.expect("it starts");
+ assert_eq!(
+ (updated["connector"]["id"].as_str(), updated["verify"]["status"].as_str()),
+ (Some("local"), Some("ready"))
+ );
+ assert!(!updated.to_string().contains("test-private-key"), "the answer carries no credential");
+ saved.args = vec!["-u".to_owned(), fixture.to_owned()];
+ assert_eq!(stored(), [saved], "one connector, same id, with the edit");
+ }
+
+ #[tokio::test]
+ async fn a_new_name_is_saved_even_when_the_server_cannot_start() {
+ let mut saved = local();
+ saved.command = Some("/nonexistent/codync-connector-test".into());
+ let store = store_with(std::slice::from_ref(&saved));
+
+ let renamed = update_custom_connector(&store, "local", &json!({"name": "Renamed"}), 0).await.expect("rename");
+ assert!(renamed["verify"].is_null(), "nothing was started: {renamed}");
+ saved.name = "Renamed".to_owned();
+ assert_eq!(connectors(&store).expect("read"), [saved.clone()]);
+
+ for same in [json!({}), json!({"args": saved.args, "env": {"API_KEY": "one"}})] {
+ let answer = update_custom_connector(&store, "local", &same, 0).await.expect("no change to how it runs");
+ assert!(answer["verify"].is_null(), "{same}: {answer}");
+ }
+ let err = update_custom_connector(&store, "local", &json!({"env": {"API_KEY": "two"}}), 0).await;
+ assert_eq!(category(&err.expect_err("a new key is checked")), "wont_start");
+ }
+
+ /// A bot with the connector `on`, in `folder`, with the same agent as `bot`.
+ fn bot_using(hub: &Hub, id: &str, folder: &Path, on: &[&str]) -> BotConfig {
+ let command = hub.store.bot("bot").expect("read").expect("the fixture's bot").config.command;
+ serde_json::from_value(json!({
+ "id": id, "name": id, "backend": "fixture", "cwd": folder, "command": command,
+ "notify": false, "connectors": on,
+ }))
+ .expect("bot")
+ }
+
+ fn lines(path: &Path) -> usize {
+ std::fs::read_to_string(path).map_or(0, |s| s.lines().count())
+ }
+
+ /// Runs one turn of `bot`; how many sessions its agent (running in `folder`) has opened by then.
+ async fn sessions_after_a_turn(hub: &std::sync::Arc<Hub>, bot: &str, folder: &Path) -> usize {
+ let prompts = folder.join("prompts.jsonl");
+ let turns = lines(&prompts);
+ dispatch(hub, &Caller::Local, "send", json!({"botId": bot, "text": "hello"})).await.expect("send");
+ tokio::time::timeout(Duration::from_secs(30), async {
+ while lines(&prompts) == turns || hub.runtime(bot).status != BotStatus::Idle {
+ tokio::time::sleep(Duration::from_millis(10)).await;
+ }
+ })
+ .await
+ .expect("the turn ended");
+ lines(&folder.join("sessions.jsonl"))
+ }
+
+ #[tokio::test]
+ async fn an_edit_keeps_each_bots_choice_and_restarts_only_the_agents_using_it() {
+ // `bot` runs in `dir` with the connector off.
+ let (hub, dir) = requests::tests::fixture();
+ // No actor, as after a panic: listed ahead of the bot below, which must hear of the edit all the same.
+ hub.store.save_bot(&bot_using(&hub, "stopped", &dir, &["fixture"])).expect("save");
+ let folder = dir.join("on");
+ std::fs::create_dir_all(&folder).expect("folder");
+ let created = hub.create_bot(bot_using(&hub, "on", &folder, &["fixture"])).expect("create");
+ let on = created["id"].as_str().expect("id");
+ let choice = |id: &str| hub.store.bot(id).expect("read").expect("bot").config.connectors;
+ assert_eq!(sessions_after_a_turn(&hub, "bot", &dir).await, 1);
+ assert_eq!(sessions_after_a_turn(&hub, on, &folder).await, 1);
+
+ let edit = json!({"id": "fixture", "env": {"API_KEY": "test-private-key"}});
+ let answer = dispatch(&hub, &Caller::Local, "updateConnector", edit).await.expect("saved, whoever can't hear");
+ assert_eq!(answer["verify"]["status"], "ready");
+ assert!(connectors(&hub.store).expect("read")[0].env.contains_key("API_KEY"));
+ assert_eq!((choice("bot"), choice(on)), (vec![], vec!["fixture".to_owned()]));
+ assert_eq!(sessions_after_a_turn(&hub, on, &folder).await, 2, "the bot using it restarted its agent");
+ let log = std::fs::read_to_string(folder.join("sessions.jsonl")).expect("log");
+ assert!(log.lines().last().expect("a session").contains("session/load"), "{log}");
+ assert_eq!(sessions_after_a_turn(&hub, "bot", &dir).await, 1, "a bot with it off isn't touched");
+
+ let renamed = json!({"id": "fixture", "name": "Renamed"});
+ dispatch(&hub, &Caller::Local, "updateConnector", renamed).await.expect("rename");
+ assert_eq!(sessions_after_a_turn(&hub, on, &folder).await, 2, "a new name restarts nothing");
+
+ hub.shutdown().await;
+ let _ = std::fs::remove_dir_all(dir);
+ }
+
+ #[tokio::test]
+ async fn a_relative_path_is_checked_where_the_bots_run_it() {
+ let (mut saved, fixture) = startable();
+ saved.args = vec!["server.py".to_owned()];
+ let store = store_with(&[saved]);
+ let edit = json!({"args": ["-u", "server.py"]});
+ update_custom_connector(&store, "local", &edit, 0).await.expect_err("no server.py in the host's folder");
+
+ let dir = std::env::temp_dir().join(format!("codync-connector-{}", uuid::Uuid::new_v4()));
+ std::fs::create_dir_all(&dir).expect("folder");
+ std::fs::copy(fixture, dir.join("server.py")).expect("copy");
+ let bot = json!({"id": "bot", "name": "bot", "backend": "fixture", "cwd": dir, "connectors": ["local"]});
+ let bot: BotConfig = serde_json::from_value(bot).expect("bot");
+ store.save_bot(&bot).expect("save");
+ update_custom_connector(&store, "local", &edit, 0).await.expect("it starts in the bot's folder");
+ let _ = std::fs::remove_dir_all(dir);
+ }
+}
diff --git a/host/src/market/install.rs b/host/src/market/install.rs
index ef783b9b..1034f50e 100644
--- a/host/src/market/install.rs
+++ b/host/src/market/install.rs
@@ -349,15 +349,7 @@ async fn custom(name: &str, b: &Value, all: &[Connector]) -> Result<Connector> {
.map(str::trim)
.filter(|s| !s.is_empty())
.ok_or_else(|| anyhow!("give a command or a URL"))?;
- let mut words = match b["args"].as_array() {
- Some(args) => {
- std::iter::once(line.to_owned()).chain(args.iter().filter_map(|a| a.as_str().map(str::to_owned))).collect()
- }
- None => shlex::split(line).ok_or_else(|| anyhow!("the command has an unclosed quote"))?,
- }
- .into_iter();
- c.command = words.next();
- c.args = words.collect();
+ (c.command, c.args) = super::command_line::split_command(line, b.get("args"))?;
Ok(c)
}
diff --git a/host/src/market/mod.rs b/host/src/market/mod.rs
index 7e72b05a..20166a23 100644
--- a/host/src/market/mod.rs
+++ b/host/src/market/mod.rs
@@ -19,6 +19,7 @@
pub mod agent_sign_in;
pub mod composio;
+pub mod connector_update;
pub mod logins;
pub mod oauth;
pub mod passwords;
@@ -26,6 +27,7 @@ pub mod requests;
pub mod vault;
pub mod verify;
+mod command_line;
mod install;
mod registry;
mod skills;
@@ -56,6 +58,9 @@ const TIMEOUT: Duration = Duration::from_secs(15);
/// Registry search is slow (often 20-30 s); lookups by name are fast.
const SEARCH_TIMEOUT: Duration = Duration::from_secs(45);
+/// The largest value a connector keeps in its environment or headers.
+pub const MAX_CREDENTIAL_BYTES: usize = 64 * 1024;
+
// MARK: stored items
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
@@ -194,6 +199,13 @@ pub fn connector_ids(store: &crate::store::Store) -> Result<Vec<String>> {
.collect())
}
+/// The bots that have this connector turned on.
+pub fn bots_using(store: &crate::store::Store, id: &str) -> Result<Vec<crate::store::BotRow>> {
+ let mut bots = store.bots()?;
+ bots.retain(|row| !row.deleted && !row.config.is_group() && row.config.connectors.iter().any(|c| c == id));
+ Ok(bots)
+}
+
/// What the computer installs for its bots.
#[derive(Clone, Copy)]
pub enum Installed {
diff --git a/host/src/market/requests.rs b/host/src/market/requests.rs
index 52f238eb..d8adbd75 100644
--- a/host/src/market/requests.rs
+++ b/host/src/market/requests.rs
@@ -208,7 +208,7 @@ pub async fn finish(hub: &Arc<Hub>, args: &Value) -> Result<Value> {
}
if kind == RequestKind::Secret {
let value = text(args, "value")?;
- if value.len() > 64 * 1024 {
+ if value.len() > super::MAX_CREDENTIAL_BYTES {
bail!("Credential is too large");
}
let field = text(request, "field")?.to_owned();
@@ -319,7 +319,7 @@ pub(super) mod tests {
fn remote_control_devices_cannot_retrieve_credentials_or_forge_requests() {
let caller =
crate::api::devices::Caller::Device { key: "test".into(), scopes: vec![crate::store::Scope::Control] };
- for method in ["connectorRuntime", "connectorTarget", "connectorCall"] {
+ for method in ["connectorRuntime", "connectorTarget", "connectorCall", "updateConnector"] {
assert!(crate::api::devices::permit(&caller, method).is_err());
}
assert!(crate::api::devices::permit(&caller, "connectorRequestFinish").is_ok());
diff --git a/host/src/market/verify.rs b/host/src/market/verify.rs
index 8b1e0869..d96ba77a 100644
--- a/host/src/market/verify.rs
+++ b/host/src/market/verify.rs
@@ -2,7 +2,7 @@
use crate::store::Store;
use anyhow::{Result, anyhow, bail};
use serde_json::{Value, json};
-use std::{process::Stdio, time::Duration};
+use std::{path::Path, process::Stdio, time::Duration};
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
process::Command,
@@ -17,19 +17,30 @@ pub async fn verify(store: &Store, id: &str, port: u16) -> Result<Value> {
bail!("Finish signing in before checking this connection.");
}
let c = super::connectors(store)?.into_iter().find(|c| c.id == id).ok_or_else(|| anyhow!("Unknown connector"))?;
+ check_connector(store, &c, port).await
+}
+
+/// The same check for a definition that doesn't have to be saved yet.
+pub(super) async fn check_connector(store: &Store, c: &super::Connector, port: u16) -> Result<Value> {
if c.oauth.as_ref().is_some_and(|o| !o.signed_in()) {
bail!("Sign in before checking this connection.");
}
let mut command = if let Some(exe) = &c.command {
- let mut command = Command::new(exe);
+ // Found and started as `mcp::serve_local` does for a bot, so what passes here is what runs:
+ // the agent starts it in its bot's folder, which a relative path in the command line means.
+ let mut command = Command::new(crate::shell::program(exe));
command.args(&c.args);
for (name, value) in &c.env {
command.env(name, super::passwords::resolve(store, value).await?);
}
+ let mut folders = super::bots_using(store, &c.id)?.into_iter().map(|row| row.config.cwd);
+ if let Some(folder) = folders.find(|cwd| Path::new(cwd).is_dir()) {
+ command.current_dir(folder);
+ }
command
} else {
let mut command = Command::new(std::env::current_exe()?);
- command.args(["mcp", "remote", "--connector", id, "--port", &port.to_string()]);
+ command.args(["mcp", "remote", "--connector", &c.id, "--port", &port.to_string()]);
command
};
let mut child = command
diff --git a/host/tests/agent_checks_e2e.rs b/host/tests/agent_checks_e2e.rs
index c053c4b3..0dc61856 100644
--- a/host/tests/agent_checks_e2e.rs
+++ b/host/tests/agent_checks_e2e.rs
@@ -80,7 +80,11 @@ async fn a_test_host_never_runs_the_agent_clis() {
let (mut host, base) = common::serve_with(&home, &[("PATH", path.as_os_str())]).await;
for method in ["refreshBackends", "usage", "agentAuth"] {
let response = call(&base, &home, method).send().await.unwrap();
- assert!(response.status().is_success(), "{method}: {}", response.status());
+ let status = response.status();
+ let body = response.text().await.unwrap();
+ // `agentAuth` opens the vault first: a computer with no keyring, like Linux CI, refuses it there, before any agent.
+ let no_keyring = method == "agentAuth" && body.contains("Secure credential storage");
+ assert!(status.is_success() || no_keyring, "{method}: {status} {body}");
}
tokio::time::sleep(Duration::from_secs(1)).await;
assert_eq!(std::fs::read_to_string(&log).unwrap_or_default(), "");
diff --git a/tools/check-connectors.py b/tools/check-connectors.py
index 202305e2..ff64083d 100644
--- a/tools/check-connectors.py
+++ b/tools/check-connectors.py
@@ -231,6 +231,18 @@ def main():
local = install({"name": "Credential fixture", "command": "python3", "args": [str(ROOT / "host/tests/fixtures/credential_mcp.py")], "env": {"API_KEY": "wrong"}})
check("wrong local credential is rejected", lambda: api("connectorVerify", {"id": local}, ok=False))
check("credential correction verifies without reinstall", lambda: api("credentialUpdateConnector", {"id": local, "fields": {"API_KEY": "test-private-key"}}))
+ def edit_in_place():
+ edited = api("updateConnector", {"id": local, "args": ["-u", str(ROOT / "host/tests/fixtures/credential_mcp.py")]})
+ assert edited["connector"]["id"] == local, "an update keeps the id bots point at"
+ assert edited["verify"]["status"] == "ready", edited
+ assert api("connectorRuntime", {"id": local})["args"][0] == "-u", "the new command line is what runs"
+ assert [c["id"] for c in api("connectors")["items"]] == [local], "an update adds nothing"
+ check("updateConnector edits the command line in place and verifies it", edit_in_place)
+ def failed_edit():
+ before = api("connectorRuntime", {"id": local})
+ api("updateConnector", {"id": local, "command": "/nonexistent/codync-connector-check"}, ok=False)
+ assert api("connectorRuntime", {"id": local}) == before, "a connector that won't start isn't saved"
+ check("a failed updateConnector leaves the connector as it was", failed_edit)
def local_proxy():
with proxy(env, port, local, "local") as rpc:
assert rpc("tools/list")["tools"] == []
diff --git a/web/content/docs/connectors-and-skills.mdx b/web/content/docs/connectors-and-skills.mdx
index 4ddb8774..b5a5b48f 100644
--- a/web/content/docs/connectors-and-skills.mdx
+++ b/web/content/docs/connectors-and-skills.mdx
@@ -48,7 +48,7 @@ In the **Connectors** section, choose **Custom connector**, above the registry l
- **Command:** a command line that starts an MCP server. It runs on the computer in the bot's project folder, and quotes work like in a shell. Put keys under **Environment**, one `KEY=value` per line.
- **URL:** a hosted MCP server. Add headers under **Headers**, one `Name: value` per line, or leave them empty if the service has you sign in.
-- **Config:** paste an MCP config from a README or another app (Claude, Cursor, VS Code), such as an `mcpServers` block. Every server in it is added.
+- **Config:** paste an MCP config from a README or another app (Claude, Cursor, VS Code), such as an `mcpServers` block. Every server in it is added. If one isn't valid, for example its `args` aren't all text, none are, and the error names that server.
Everything you enter is saved on that computer only.