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): overlays hide Pipedream grants, not Connect's (#9500)

Eric Hayes5c8c1bfcac3f
diff --git a/.sqlx/query-b8954cc95877b61dd1046a100e6314b5f8df7a490af3e598a452cd2f7d4f7c31.json b/.sqlx/query-2586dbc8ee1e6271c0479e672c84e69c394e70d7d8318f369a4803c0d3da20d5.json
similarity index 82%
rename from .sqlx/query-b8954cc95877b61dd1046a100e6314b5f8df7a490af3e598a452cd2f7d4f7c31.json
rename to .sqlx/query-2586dbc8ee1e6271c0479e672c84e69c394e70d7d8318f369a4803c0d3da20d5.json
index 40a8004329..7fb6c7cc5c 100644
--- a/.sqlx/query-b8954cc95877b61dd1046a100e6314b5f8df7a490af3e598a452cd2f7d4f7c31.json
+++ b/.sqlx/query-2586dbc8ee1e6271c0479e672c84e69c394e70d7d8318f369a4803c0d3da20d5.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT user_id, app_slug, server_name, account_id, enabled, provider\n FROM pipedream_mcp_connections\n WHERE app_slug = $1 AND enabled\n AND NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $1)\n ",
+ "query": "\n SELECT user_id, app_slug, server_name, account_id, enabled, provider\n FROM pipedream_mcp_connections\n WHERE app_slug = $1 AND enabled\n AND (provider = 'connect'\n OR NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $1))\n ",
"describe": {
"columns": [
{
@@ -48,5 +48,5 @@
false
]
},
- "hash": "b8954cc95877b61dd1046a100e6314b5f8df7a490af3e598a452cd2f7d4f7c31"
+ "hash": "2586dbc8ee1e6271c0479e672c84e69c394e70d7d8318f369a4803c0d3da20d5"
}
diff --git a/.sqlx/query-1b4ba52ab6f25493e9435de63c974e819c4d1e7b3023c05c2ee7639f865ed52a.json b/.sqlx/query-5c770383b05fea77d04238a17ec1586574473163aff7d0a42855429f8982620e.json
similarity index 80%
rename from .sqlx/query-1b4ba52ab6f25493e9435de63c974e819c4d1e7b3023c05c2ee7639f865ed52a.json
rename to .sqlx/query-5c770383b05fea77d04238a17ec1586574473163aff7d0a42855429f8982620e.json
index 3034799862..48ba8f0eb9 100644
--- a/.sqlx/query-1b4ba52ab6f25493e9435de63c974e819c4d1e7b3023c05c2ee7639f865ed52a.json
+++ b/.sqlx/query-5c770383b05fea77d04238a17ec1586574473163aff7d0a42855429f8982620e.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT user_id, app_slug, server_name, account_id, enabled, provider\n FROM pipedream_mcp_connections c\n WHERE user_id = $1\n AND NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = c.app_slug)\n ORDER BY server_name\n ",
+ "query": "\n SELECT user_id, app_slug, server_name, account_id, enabled, provider\n FROM pipedream_mcp_connections c\n WHERE user_id = $1\n AND (c.provider = 'connect'\n OR NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = c.app_slug))\n ORDER BY server_name\n ",
"describe": {
"columns": [
{
@@ -48,5 +48,5 @@
false
]
},
- "hash": "1b4ba52ab6f25493e9435de63c974e819c4d1e7b3023c05c2ee7639f865ed52a"
+ "hash": "5c770383b05fea77d04238a17ec1586574473163aff7d0a42855429f8982620e"
}
diff --git a/.sqlx/query-5059c329fd5116f716830e3a47e7a2b30d592fa6aa9a732915efd93e42dd7f64.json b/.sqlx/query-d2f47c99f95dafb57b6796e2c08e586db8eee0f899581fb930d52a2479121681.json
similarity index 82%
rename from .sqlx/query-5059c329fd5116f716830e3a47e7a2b30d592fa6aa9a732915efd93e42dd7f64.json
rename to .sqlx/query-d2f47c99f95dafb57b6796e2c08e586db8eee0f899581fb930d52a2479121681.json
index 3d1ae89223..1997ea1060 100644
--- a/.sqlx/query-5059c329fd5116f716830e3a47e7a2b30d592fa6aa9a732915efd93e42dd7f64.json
+++ b/.sqlx/query-d2f47c99f95dafb57b6796e2c08e586db8eee0f899581fb930d52a2479121681.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT user_id, app_slug, server_name, account_id, enabled, provider\n FROM pipedream_mcp_connections\n WHERE user_id = $1 AND app_slug = $2\n AND NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $2)\n ",
+ "query": "\n SELECT user_id, app_slug, server_name, account_id, enabled, provider\n FROM pipedream_mcp_connections\n WHERE user_id = $1 AND app_slug = $2\n AND (provider = 'connect'\n OR NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $2))\n ",
"describe": {
"columns": [
{
@@ -49,5 +49,5 @@
false
]
},
- "hash": "5059c329fd5116f716830e3a47e7a2b30d592fa6aa9a732915efd93e42dd7f64"
+ "hash": "d2f47c99f95dafb57b6796e2c08e586db8eee0f899581fb930d52a2479121681"
}
diff --git a/crates/agent_harness/src/outbound/connected_apps.rs b/crates/agent_harness/src/outbound/connected_apps.rs
index 6b95d38698..fb384744c5 100644
--- a/crates/agent_harness/src/outbound/connected_apps.rs
+++ b/crates/agent_harness/src/outbound/connected_apps.rs
@@ -4,6 +4,7 @@
use std::sync::Arc;
use macro_user_id::user_id::MacroUserIdStr;
+use pipedream_mcp::domain::models::ConnectionProvider;
use pipedream_mcp::domain::ports::{ConnectionStore, ConnectorOverlays, OverlayConnections};
use crate::domain::app_connections::ConnectedApps;
@@ -47,6 +48,18 @@ where
app_slug: &str,
) -> Result<Option<String>, ConnectionLookupError> {
let lookup = |error: &dyn std::fmt::Debug| ConnectionLookupError(format!("{error:?}"));
+ let connection = self
+ .connections
+ .load(user, app_slug)
+ .await
+ .map_err(|error| lookup(&error))?;
+ // A Macro Connect grant outranks an overlay; a Pipedream grant doesn't.
+ if let Some(connection) = connection
+ .as_ref()
+ .filter(|connection| connection.provider == ConnectionProvider::Connect)
+ {
+ return Ok(connection.enabled.then(|| connection.server_name.clone()));
+ }
if let Some(overlay) = self
.connections
.overlay(app_slug)
@@ -59,11 +72,6 @@ where
.await
.map_err(|error| lookup(&error));
}
- let connection = self
- .connections
- .load(user, app_slug)
- .await
- .map_err(|error| lookup(&error))?;
Ok(connection
.filter(|connection| connection.enabled)
.map(|connection| connection.server_name))
diff --git a/crates/agent_harness/src/outbound/connected_apps/test.rs b/crates/agent_harness/src/outbound/connected_apps/test.rs
index d7f5230613..1f4ad43a61 100644
--- a/crates/agent_harness/src/outbound/connected_apps/test.rs
+++ b/crates/agent_harness/src/outbound/connected_apps/test.rs
@@ -65,6 +65,35 @@ fn pipedream(app_slug: &str, enabled: bool) -> PipedreamConnection {
}
}
+#[tokio::test]
+async fn a_connect_grant_outranks_an_overlay() {
+ let connect = |enabled| PipedreamConnection {
+ provider: pipedream_mcp::domain::models::ConnectionProvider::Connect,
+ server_name: "Sentry (Connect)".into(),
+ ..pipedream("sentry", enabled)
+ };
+ let apps = PipedreamConnectedApps::new(
+ Arc::new(Connections(vec![connect(true)])),
+ Arc::new(Native(None)),
+ );
+ assert_eq!(
+ apps.connected_app_name(&user(), "sentry").await.unwrap(),
+ Some("Sentry (Connect)".into())
+ );
+
+ let disabled = PipedreamConnectedApps::new(
+ Arc::new(Connections(vec![connect(false)])),
+ Arc::new(Native(Some("Sentry"))),
+ );
+ assert_eq!(
+ disabled
+ .connected_app_name(&user(), "sentry")
+ .await
+ .unwrap(),
+ None
+ );
+}
+
#[tokio::test]
async fn overlaid_apps_are_connected_through_their_native_server_only() {
let apps = PipedreamConnectedApps::new(
diff --git a/crates/pipedream_mcp/AGENTS.md b/crates/pipedream_mcp/AGENTS.md
index 798452e1cb..d4030fcc8c 100644
--- a/crates/pipedream_mcp/AGENTS.md
+++ b/crates/pipedream_mcp/AGENTS.md
@@ -69,6 +69,8 @@ listings, and calls all go through Connect, with no Pipedream fallback.
and records nothing; the app polls `/pipedream/mcp/connect/complete`, which
trusts only Connect's own connection list.
+- A Macro Connect grant outranks an overlay: the store returns it, and
+ status checks read it before the overlay's native connection.
- Overlaying an app hides its Pipedream grant from every reader, including
imports (Linear, Jira, Notion) and Granola sync, which use the Pipedream
proxy. Keep those slugs out of `mcp_overlays` until their readers have a
diff --git a/crates/pipedream_mcp/src/domain/service/discovery.rs b/crates/pipedream_mcp/src/domain/service/discovery.rs
index f931dfff22..6b41ddc741 100644
--- a/crates/pipedream_mcp/src/domain/service/discovery.rs
+++ b/crates/pipedream_mcp/src/domain/service/discovery.rs
@@ -1,7 +1,7 @@
//! Read-only discovery of apps and their actual MCP capabilities.
use crate::domain::{
- models::MacroUserIdStr,
+ models::{ConnectionProvider, MacroUserIdStr},
ports::{
ConnectionStore, ConnectorCapabilities, ConnectorDirectory, ConnectorOverlays,
OverlayConnections,
@@ -156,6 +156,18 @@ where
user_id: &MacroUserIdStr<'static>,
app_slug: &str,
) -> anyhow::Result<bool> {
+ let connection = self
+ .connections
+ .load(user_id, app_slug)
+ .await
+ .map_err(|error| anyhow::anyhow!("Could not check connector status: {error:?}"))?;
+ // A Macro Connect grant outranks an overlay; a Pipedream grant doesn't.
+ if let Some(connection) = connection
+ .as_ref()
+ .filter(|connection| connection.provider == ConnectionProvider::Connect)
+ {
+ return Ok(connection.enabled);
+ }
if let Some(overlay) = self.connections.overlay(app_slug).await? {
return Ok(self
.overlay_connections
@@ -163,12 +175,7 @@ where
.await?
.is_some());
}
- Ok(self
- .connections
- .load(user_id, app_slug)
- .await
- .map_err(|error| anyhow::anyhow!("Could not check connector status: {error:?}"))?
- .is_some_and(|connection| connection.enabled))
+ Ok(connection.is_some_and(|connection| connection.enabled))
}
}
diff --git a/crates/pipedream_mcp/src/domain/service/discovery/test.rs b/crates/pipedream_mcp/src/domain/service/discovery/test.rs
index e66749d4cd..a5f6990680 100644
--- a/crates/pipedream_mcp/src/domain/service/discovery/test.rs
+++ b/crates/pipedream_mcp/src/domain/service/discovery/test.rs
@@ -64,6 +64,7 @@ impl ConnectorCapabilities for Directory {
struct Store {
enabled: Option<bool>,
+ provider: crate::domain::models::ConnectionProvider,
overlaid: bool,
seen: Mutex<Vec<String>>,
}
@@ -120,7 +121,7 @@ impl ConnectionStore for Store {
server_name: "Linear".into(),
account_id: "account".into(),
enabled,
- provider: crate::domain::models::ConnectionProvider::Pipedream,
+ provider: self.provider,
}))
}
}
@@ -138,6 +139,7 @@ fn service(
})),
Arc::new(Store {
enabled,
+ provider: crate::domain::models::ConnectionProvider::Pipedream,
overlaid: false,
seen: Mutex::default(),
}),
@@ -271,6 +273,7 @@ async fn overlaid_apps_report_their_native_connection_not_pipedream() {
})),
Arc::new(Store {
enabled: Some(true),
+ provider: crate::domain::models::ConnectionProvider::Pipedream,
overlaid: true,
seen: Mutex::default(),
}),
@@ -282,6 +285,31 @@ async fn overlaid_apps_report_their_native_connection_not_pipedream() {
panic!("inspection expected")
};
assert_eq!(connected, native.is_some());
- assert!(svc.connections.seen.lock().unwrap().is_empty());
+ }
+}
+
+#[tokio::test]
+async fn a_connect_grant_outranks_an_overlay() {
+ for enabled in [true, false] {
+ let svc = ConnectorDiscovery::new(
+ Some(Arc::new(Directory {
+ fail_tools: false,
+ tool_count: 1,
+ seen: Mutex::default(),
+ })),
+ Arc::new(Store {
+ enabled: Some(enabled),
+ provider: crate::domain::models::ConnectionProvider::Connect,
+ overlaid: true,
+ seen: Mutex::default(),
+ }),
+ Arc::new(Native(Some("Linear".to_owned()))),
+ );
+ let DiscoveryResult::Inspect { connected, .. } =
+ svc.discover(&user(), &inspect("linear")).await.unwrap()
+ else {
+ panic!("inspection expected")
+ };
+ assert_eq!(connected, enabled);
}
}
diff --git a/crates/pipedream_mcp/src/outbound/pg_connection_repo.rs b/crates/pipedream_mcp/src/outbound/pg_connection_repo.rs
index 45fecfe386..522643765c 100644
--- a/crates/pipedream_mcp/src/outbound/pg_connection_repo.rs
+++ b/crates/pipedream_mcp/src/outbound/pg_connection_repo.rs
@@ -61,7 +61,8 @@ impl ConnectionStore for PgConnectionRepo {
SELECT user_id, app_slug, server_name, account_id, enabled, provider
FROM pipedream_mcp_connections
WHERE user_id = $1 AND app_slug = $2
- AND NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $2)
+ AND (provider = 'connect'
+ OR NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $2))
"#,
user_id.as_ref(),
app_slug,
@@ -108,7 +109,8 @@ impl ConnectionStore for PgConnectionRepo {
SELECT user_id, app_slug, server_name, account_id, enabled, provider
FROM pipedream_mcp_connections c
WHERE user_id = $1
- AND NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = c.app_slug)
+ AND (c.provider = 'connect'
+ OR NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = c.app_slug))
ORDER BY server_name
"#,
user_id.as_ref(),
@@ -142,7 +144,8 @@ impl AppConnections for PgConnectionRepo {
SELECT user_id, app_slug, server_name, account_id, enabled, provider
FROM pipedream_mcp_connections
WHERE app_slug = $1 AND enabled
- AND NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $1)
+ AND (provider = 'connect'
+ OR NOT EXISTS (SELECT 1 FROM mcp_overlays o WHERE o.app_slug = $1))
"#,
app_slug,
)
diff --git a/crates/pipedream_mcp/src/outbound/pg_connection_repo/test.rs b/crates/pipedream_mcp/src/outbound/pg_connection_repo/test.rs
index 9b091f4ff2..4a63d6087f 100644
--- a/crates/pipedream_mcp/src/outbound/pg_connection_repo/test.rs
+++ b/crates/pipedream_mcp/src/outbound/pg_connection_repo/test.rs
@@ -58,6 +58,27 @@ async fn reads_never_return_connections_to_overlaid_apps(pool: PgPool) {
);
}
+/// Overlays hide Pipedream grants, not Connect's: a user on Connect alone
+/// gets `sentry` through their Connect row.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("users"))
+)]
+async fn reads_return_connect_connections_to_overlaid_apps(pool: PgPool) {
+ let repo = PgConnectionRepo::new(pool);
+ let user = connection("sentry").user_id;
+ repo.save(&PipedreamConnection {
+ provider: crate::domain::models::ConnectionProvider::Connect,
+ ..connection("sentry")
+ })
+ .await
+ .unwrap();
+
+ assert_eq!(repo.list(&user).await.unwrap().len(), 1);
+ assert!(repo.load(&user, "sentry").await.unwrap().is_some());
+ assert_eq!(repo.list_enabled_for_app("sentry").await.unwrap().len(), 1);
+}
+
#[sqlx::test(
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../../fixtures", scripts("users"))