Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(pipedream_mcp): list Connect apps Pipedream doesn't have (#9496)

Eric Hayes02a2c36a94ba
diff --git a/crates/pipedream_mcp/AGENTS.md b/crates/pipedream_mcp/AGENTS.md
index 4024caff35..798452e1cb 100644
--- a/crates/pipedream_mcp/AGENTS.md
+++ b/crates/pipedream_mcp/AGENTS.md
@@ -29,7 +29,8 @@ listings, and calls all go through Connect, with no Pipedream fallback.
- `src/outbound/connect.rs`: the Macro Connect adapter over
`connect_client` (a pinned copy of Connect's client): tools through Connect's
MCP gateway, app API calls with an exported access token, catalog apps
- addressed by the Pipedream slugs they replace.
+ addressed by the Pipedream slugs they replace, or by their Connect id when
+ Pipedream has no such app.
- `src/outbound/dispatch.rs`: `ConnectorBackends`, the one type hosts wire:
it holds the host's `ConnectRollout` (the `macro-connect` PostHog flag,
read by `ai_tools::macro_connect_rollout`). A user on Connect alone gets
diff --git a/crates/pipedream_mcp/src/outbound/connect.rs b/crates/pipedream_mcp/src/outbound/connect.rs
index 7b00c21bb4..99dd9e214f 100644
--- a/crates/pipedream_mcp/src/outbound/connect.rs
+++ b/crates/pipedream_mcp/src/outbound/connect.rs
@@ -52,7 +52,8 @@ impl std::fmt::Debug for ConnectConfig {
/// Serves records with [`ConnectionProvider::Connect`]: tools through
/// Connect's MCP gateway (Connect attaches the vendor token), app API calls
/// with an exported access token, and the connect flow. Catalog apps are
-/// addressed by the Pipedream slugs they replace.
+/// addressed by the Pipedream slugs they replace, or by their Connect id when
+/// Pipedream has no such app.
///
/// [`ConnectionProvider::Connect`]: crate::domain::models::ConnectionProvider::Connect
pub struct ConnectAdapter {
@@ -111,6 +112,16 @@ impl ConnectAdapter {
}
}
+/// The slugs Macro addresses a Connect app by: the Pipedream slugs it
+/// replaces, or its Connect id when Pipedream has no such app.
+fn macro_slugs(app: &wire::CatalogEntry) -> &[String] {
+ if app.pipedream_app_slugs.is_empty() {
+ std::slice::from_ref(&app.id)
+ } else {
+ &app.pipedream_app_slugs
+ }
+}
+
/// The catalog entry Macro shows for a Connect app under `app_slug`. Icon
/// paths are relative to the Connect origin.
fn catalog_entry(app: &wire::CatalogEntry, app_slug: &str, api_url: &Url) -> CatalogEntry {
@@ -139,7 +150,7 @@ impl MacroConnect for ConnectAdapter {
.catalog()
.await?
.iter()
- .find(|app| app.pipedream_app_slugs.iter().any(|slug| slug == app_slug))
+ .find(|app| macro_slugs(app).iter().any(|slug| slug == app_slug))
.map(|app| ConnectApp {
app_id: app.id.clone(),
app_slug: app_slug.to_owned(),
@@ -273,7 +284,7 @@ impl ConnectorCapabilities for ConnectAdapter {
}
impl ConnectorDirectory for ConnectAdapter {
- /// Connect's catalog under each app's first Pipedream slug, in catalog
+ /// Connect's catalog under each app's first Macro slug, in catalog
/// order. `cursor` is an offset.
#[tracing::instrument(skip(self), err)]
async fn search(
@@ -294,7 +305,7 @@ impl ConnectorDirectory for ConnectAdapter {
.is_none_or(|needle| app.name.to_lowercase().contains(needle))
})
.filter_map(|app| {
- let slug = app.pipedream_app_slugs.first()?;
+ let slug = macro_slugs(app).first()?;
Some(catalog_entry(app, slug, &self.api_url))
})
.collect();
@@ -316,7 +327,7 @@ impl ConnectorDirectory for ConnectAdapter {
.catalog()
.await?
.iter()
- .find(|app| app.pipedream_app_slugs.iter().any(|slug| slug == app_slug))
+ .find(|app| macro_slugs(app).iter().any(|slug| slug == app_slug))
.map(|app| catalog_entry(app, app_slug, &self.api_url)))
}
}
diff --git a/crates/pipedream_mcp/src/outbound/connect/test.rs b/crates/pipedream_mcp/src/outbound/connect/test.rs
index b3b6a78f82..529041937f 100644
--- a/crates/pipedream_mcp/src/outbound/connect/test.rs
+++ b/crates/pipedream_mcp/src/outbound/connect/test.rs
@@ -54,6 +54,11 @@ async fn mount_catalog(server: &MockServer) {
"id": "slack", "name": "Slack", "description": "Messages",
"access": ["mcp"], "mcp_url": "https://mcp.slack.com/mcp", "icon_url": null,
"pipedream_app_slugs": ["slack", "slack_v2"]
+ },
+ {
+ "id": "mercury", "name": "Mercury", "description": "Bank accounts",
+ "access": ["mcp"], "mcp_url": "https://mcp.mercury.com/mcp", "icon_url": null,
+ "pipedream_app_slugs": []
}
])))
.expect(1)
@@ -97,6 +102,22 @@ async fn maps_pipedream_slugs_to_connect_apps_from_one_cached_catalog() {
.unwrap();
assert_eq!(page.entries.len(), 1);
assert_eq!(page.entries[0].app_slug, "slack");
+
+ // An app Pipedream doesn't have goes by its Connect id.
+ let mercury = connect.app_for_slug("mercury").await.unwrap().unwrap();
+ assert_eq!(mercury.app_id, "mercury");
+ assert!(
+ connect
+ .retrieve(&user(), "mercury")
+ .await
+ .unwrap()
+ .is_some()
+ );
+ let page = connect
+ .search(&user(), Some("merc"), None, 10)
+ .await
+ .unwrap();
+ assert_eq!(page.entries[0].app_slug, "mercury");
// `expect(1)` on the catalog mock checks the cache on drop.
}