Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(import): restore Notion and Linear tools in agent contexts (#7913)
teobe6bda5c00f6
diff --git a/Cargo.lock b/Cargo.lockindex edbeb59235..9042b51862 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -12032,6 +12032,7 @@ dependencies = ["futures","github_pull_requests","http 1.4.0",+ "import","lexical_client","macro_auth","macro_aws_config",@@ -12044,7 +12045,10 @@ dependencies = ["macro_service_urls","macro_user_id","mcp_auth_proxy",+ "mcp_client",+ "mcp_select","notification",+ "pipedream_mcp","prompt","readonly_pool","redis",diff --git a/crates/ai_tools/src/build_context.rs b/crates/ai_tools/src/build_context.rsindex e54ec9253f..4a08a356b7 100644--- a/crates/ai_tools/src/build_context.rs+++ b/crates/ai_tools/src/build_context.rs@@ -78,6 +78,7 @@ maybe_env_var! {EnableEmailScheduledQueue,EnableGmailOpsQueue,EnableNotificationQueue,+ McpCredentialsKeySecretName,}}@@ -120,6 +121,9 @@ pub fn build_image_generator_from_env() -> Arc<dyn ImageGenerator> {/// `INTERNAL_API_KEY` (presented to the lexical service and to the/// connection gateway for realtime channel side effects), `KAFKA_BROKERS`.///+/// `MCP_CREDENTIALS_KEY_SECRET_NAME` enables import tools on hosts with access+/// to the shared connector encryption key; hosts without it remain unwired.+////// Service URLs are resolved through the `macro_service_urls` crate, and queue/// names through the `macro_queues` crate (both using optional `OVERRIDE_*` env/// vars before environment defaults).@@ -516,10 +520,68 @@ pub async fn build_tool_service_context_from_env(},);+ let admission =+ ai_billing::composition::pg_admission_service(pool.clone(), enforcement, pricing);+ let pipedream_client = crate::mcp_app_catalog::pipedream_client_from_env()?;+ let import_tool_context = if let Some(secret_name) = maybe_env+ .mcp_credentials_key_secret_name+ .as_ref()+ .and_then(|key| key.value())+ {+ let mcp_credentials_key = secretsmanager_client+ .get_maybe_secret_value(environment, secret_name)+ .await+ .context("failed to load MCP credentials encryption key")?;+ let mcp_encryption_key =+ mcp_client::domain::models::AesKey::try_from(mcp_credentials_key.as_ref())+ .context("invalid MCP credentials encryption key")?;+ let mcp_selector = Arc::new(mcp_select::McpToolSelector::new(+ Arc::new(mcp_client::outbound::pg_server_repo::PgServerRepo::new(+ pool.clone(),+ mcp_encryption_key,+ )),+ Arc::new(+ pipedream_mcp::outbound::pg_connection_repo::PgConnectionRepo::new(pool.clone()),+ ),+ Arc::new(pipedream_client.clone()),+ ));+ let import_service = Arc::new(+ import::domain::service::ImportServiceImpl::new(+ import::outbound::pg_import_repo::PgImportRepo::new(pool.clone()),+ mcp_selector.clone(),+ Arc::new(crate::ToolEntityCreator {+ document_creator: document_tool_context.creator.clone(),+ entity_access_service: entity_access_service.clone(),+ channel_service: channel_tool_context.service.clone(),+ task_properties: document_tool_context+ .service+ .task_properties_service+ .clone(),+ document_properties:+ import::outbound::document_properties::DocumentPropertiesApplicator::new(+ properties_service.clone(),+ ),+ team_repository: crate::tool_context::build_team_repository(pool.clone()),+ }),+ recorder.clone(),+ )+ .with_slack_source(Arc::new(+ import::outbound::mcp_slack_source::McpSlackSource::new(mcp_selector),+ ))+ .with_admission(admission.clone())+ .with_notifier(import::outbound::gateway_notifier::gateway_import_notify(+ side_effect_clients.connection_gateway.clone(),+ )),+ );+ ToolImportToolContext::wired(import_service)+ } else {+ ToolImportToolContext::unwired()+ };+Ok(ToolServiceContext {connector_tool_context: crate::tool_context::build_connector_tool_context(pool.clone(),- crate::mcp_app_catalog::pipedream_client_from_env()?,+ pipedream_client.clone(),),search_service_client: search_client.clone(),email_service_client: email_ext_client,@@ -554,7 +616,7 @@ pub async fn build_tool_service_context_from_env(databases_tool_context,forms_tool_context,databases_sql_tool_context,- import_tool_context: ToolImportToolContext::unwired(),+ import_tool_context,chat_tool_context,channel_tool_context,bot_tool_context: crate::tool_context::build_bot_tool_context(@@ -562,7 +624,7 @@ pub async fn build_tool_service_context_from_env(crate::tool_context::MaybeToolEventBroker::Real(macro_event_broker.clone()),entity_access_service.clone(),document_storage_service_url,- crate::mcp_app_catalog::pipedream_client_from_env()?,+ pipedream_client,),coding_agent_tool_context: crate::build_coding_agent_tool_context(macro_service_urls::AgentHarnessServiceUrl::new()?,@@ -575,11 +637,7 @@ pub async fn build_tool_service_context_from_env(skill_tool_context,schedule_tool_context: crate::build_routine_tool_context()?,anthropic_tool_context,- admission: ai_billing::composition::pg_admission_service(- pool.clone(),- enforcement,- pricing,- ),+ admission,recorder,usage_context: ai_usage::UsageContext::system(ai_usage::AiFeature::Chat),})diff --git a/crates/ai_tools/src/tool_context.rs b/crates/ai_tools/src/tool_context.rsindex 5b9b709a89..4c421163b3 100644--- a/crates/ai_tools/src/tool_context.rs+++ b/crates/ai_tools/src/tool_context.rs@@ -1573,9 +1573,7 @@ pub type ToolImportService = import::domain::service::ImportServiceImpl<import::outbound::mcp_slack_source::McpSlackSource<ToolMcpSelector>,>;-/// Type alias for the import tool context. Built `unwired` by the shared-/// context builder; hosts that can run the import pipeline (DCS) replace it-/// with a wired one after constructing the import service.+/// Type alias for the import tool context, wired by hosts with connector access.pub type ToolImportToolContext = import::inbound::toolset::ImportToolContext<ToolImportService>;pub type ToolActivityToolContext = activity::inbound::toolset::ActivityToolContext<diff --git a/crates/import/src/domain/service/prompts.rs b/crates/import/src/domain/service/prompts.rsindex 8d0ba3e50d..c541ed1296 100644--- a/crates/import/src/domain/service/prompts.rs+++ b/crates/import/src/domain/service/prompts.rs@@ -90,8 +90,11 @@ pub const NOTION_IMPORT_SYSTEM: &str = "You are importing Notion pages the userWork through the listed pages ONE AT A TIME, in order. For each page:\n\1. Fetch its content by URL or page id with the canonical Notion `notion-fetch` tool (named \`fetch` on OpenAI-compatible MCP connections). Never use a search snippet or a generic \- `view` result as the page body. If neither `notion-fetch` nor `fetch` is available, skip the \- page.\n\+ `view` result as the page body. If neither `notion-fetch` nor `fetch` is available, use the \+ connector's page retrieval and block-children tools instead: retrieve the page metadata, \+ then list the page's child blocks, following pagination and recursively reading blocks \+ that have children. Page metadata alone is not body content. Convert only the retrieved \+ blocks into markdown; if no body content can be read, skip the page.\n\2. Treat the tool result as input data, not as page content. `content_markdown` must contain \ONLY body content that actually appears in the fetched page. Never include tool narration \such as `Here is the result of \"view\"...`, timestamps, serialized result wrappers such as \diff --git a/crates/import/src/domain/service/test.rs b/crates/import/src/domain/service/test.rsindex 9b71aa3815..63d691c751 100644--- a/crates/import/src/domain/service/test.rs+++ b/crates/import/src/domain/service/test.rs@@ -311,6 +311,9 @@ fn notion_prompt_imports_only_source_backed_body_content() {let prompt = prompts::NOTION_IMPORT_SYSTEM;assert!(prompt.contains("canonical Notion `notion-fetch` tool"));+ assert!(prompt.contains("connector's page retrieval and block-children tools instead"));+ assert!(prompt.contains("following pagination and recursively reading blocks"));+ assert!(prompt.contains("Page metadata alone is not body content"));assert!(prompt.contains("Never use a search snippet or a generic `view` result"));assert!(prompt.contains("ONLY body content that actually appears in the fetched page"));assert!(prompt.contains(r#"Here is the result of "view"..."#));diff --git a/crates/mcp_select/src/lib.rs b/crates/mcp_select/src/lib.rsindex 06218bc0f9..c11230e044 100644--- a/crates/mcp_select/src/lib.rs+++ b/crates/mcp_select/src/lib.rs@@ -7,8 +7,8 @@//! tables, and toolsets. The one place they must meet is deciding which//! tools a user's agent actually gets. This crate owns that rule://!-//! 1. Load both stacks' connectors.-//! 2. If the user has any Pipedream connectors, use only those.+//! 1. Load the configured stacks' connectors.+//! 2. If Pipedream is configured and the user has any of its connectors, use only those.//! 3. Otherwise, use the native connectors.use ai_toolset::{@@ -193,6 +193,9 @@ where&self,user: &MacroUserIdStr<'static>,) -> Vec<pipedream_mcp::domain::models::PipedreamConnection> {+ if !self.pipedream_connection.is_configured() {+ return Vec::new();+ }self.pipedream_store.list(user).awaitdiff --git a/crates/mcp_select/src/test.rs b/crates/mcp_select/src/test.rsindex 41aa19aae7..5ff0a41237 100644--- a/crates/mcp_select/src/test.rs+++ b/crates/mcp_select/src/test.rs@@ -12,7 +12,11 @@ fn user() -> MacroUserIdStr<'static> {MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap()}-struct FakeStore(Vec<PipedreamConnection>);+#[derive(Default)]+struct FakeStore {+ connections: Vec<PipedreamConnection>,+ native_records: Vec<McpServerRecord>,+}impl ConnectionStore for FakeStore {type Err = ();@@ -38,7 +42,7 @@ impl ConnectionStore for FakeStore {user: &MacroUserIdStr<'static>,) -> Result<Vec<PipedreamConnection>, Self::Err> {assert_eq!(user, &self::user());- Ok(self.0.clone())+ Ok(self.connections.clone())}}@@ -63,10 +67,10 @@ impl McpServerStore for FakeStore {async fn list(&self, _: &MacroUserIdStr<'static>) -> Result<Vec<McpServerRecord>, Self::Err> {assert!(- self.0.is_empty(),+ self.connections.is_empty() || !self.native_records.is_empty(),"Pipedream connections exclude the native stack");- Ok(vec![])+ Ok(self.native_records.clone())}}@@ -76,6 +80,10 @@ struct FakeConnection {}impl McpConnection for FakeConnection {+ fn is_configured(&self) -> bool {+ true+ }+async fn connect(&self, record: &PipedreamConnection) -> anyhow::Result<McpServer> {self.attempts.lock().unwrap().push(record.app_slug.clone());// Exercise selection without a live MCP transport. Failed sessions@@ -84,8 +92,8 @@ impl McpConnection for FakeConnection {}}-fn selector(slugs: &[&str]) -> McpToolSelector<FakeStore, FakeStore, FakeConnection> {- let records = slugs+fn connections(slugs: &[&str]) -> Vec<PipedreamConnection> {+ slugs.iter().map(|slug| PipedreamConnection {user_id: user(),@@ -94,11 +102,85 @@ fn selector(slugs: &[&str]) -> McpToolSelector<FakeStore, FakeStore, FakeConnectaccount_id: format!("apn_{slug}"),enabled: true,})- .collect();- let store = Arc::new(FakeStore(records));+ .collect()+}++fn selector(slugs: &[&str]) -> McpToolSelector<FakeStore, FakeStore, FakeConnection> {+ let store = Arc::new(FakeStore {+ connections: connections(slugs),+ ..Default::default()+ });McpToolSelector::new(store.clone(), store, Arc::new(FakeConnection::default()))}+#[tokio::test]+async fn unconfigured_pipedream_preserves_native_connector_selection() {+ let connectors = [+ SLACK,+ ConnectorRef {+ pipedream_app_slugs: &["notion"],+ native_server_url: "https://mcp.notion.com/mcp",+ },+ ConnectorRef {+ pipedream_app_slugs: &["linear"],+ native_server_url: "https://mcp.linear.app/mcp",+ },+ ];+ let store = Arc::new(FakeStore {+ connections: connections(&["slack", "notion", "linear"]),+ native_records: connectors+ .iter()+ .map(|connector| McpServerRecord {+ user_id: user(),+ url: connector.native_server_url.to_string(),+ server_name: connector.pipedream_app_slugs[0].to_string(),+ credentials: None,+ // Only exercise routing; no live server should be contacted.+ enabled: false,+ })+ .collect(),+ });+ let selector =+ McpToolSelector::new(store.clone(), store, Arc::new(None::<Arc<FakeConnection>>));++ assert!(matches!(+ selector.user_toolset(&user()).await,+ UserMcpTools::Native(_)+ ));+ for connector in connectors {+ assert!(matches!(+ selector+ .connector_toolset(&user(), connector)+ .await+ .unwrap(),+ Some(UserMcpTools::Native(_))+ ));+ assert!(+ !selector+ .connector_connected(&user(), connector)+ .await+ .unwrap(),+ "stored Pipedream accounts must not report a usable connection"+ );+ }+}++#[tokio::test]+async fn configured_optional_pipedream_keeps_precedence_over_native() {+ let configured = selector(&["slack"]);+ let selector = McpToolSelector::new(+ configured.native_store,+ configured.pipedream_store,+ Arc::new(Some(configured.pipedream_connection)),+ );++ assert!(matches!(+ selector.connector_toolset(&user(), SLACK).await.unwrap(),+ Some(UserMcpTools::Pipedream(_))+ ));+ assert!(selector.connector_connected(&user(), SLACK).await.unwrap());+}+#[test]fn matches_only_declared_slugs() {assert!(SLACK.matches_pipedream_slug("slack"));diff --git a/crates/pipedream_mcp/src/domain/ports.rs b/crates/pipedream_mcp/src/domain/ports.rsindex 3eaf0283e0..79115b9f2e 100644--- a/crates/pipedream_mcp/src/domain/ports.rs+++ b/crates/pipedream_mcp/src/domain/ports.rs@@ -41,6 +41,9 @@ pub trait ConnectionStore: Send + Sync + 'static {/// scoped to the record's user and app; Pipedream injects the account's/// credentials server-side, so no tokens ever pass through here.pub trait McpConnection: Send + Sync + 'static {+ /// Whether this deployment has the configuration needed to connect.+ fn is_configured(&self) -> bool;+/// Connect to the MCP server serving `record`'s app for `record.user_id`.fn connect(&self,@@ -52,6 +55,11 @@ pub trait McpConnection: Send + Sync + 'static {/// before Pipedream is configured degrade to empty instead of erroring at/// composition time.impl<P: McpConnection> McpConnection for Option<std::sync::Arc<P>> {+ fn is_configured(&self) -> bool {+ self.as_ref()+ .is_some_and(|connection| connection.is_configured())+ }+async fn connect(&self, record: &PipedreamConnection) -> anyhow::Result<McpServer> {match self {Some(connection) => connection.connect(record).await,diff --git a/crates/pipedream_mcp/src/outbound/api.rs b/crates/pipedream_mcp/src/outbound/api.rsindex 3281b67a85..66d7d3b4bf 100644--- a/crates/pipedream_mcp/src/outbound/api.rs+++ b/crates/pipedream_mcp/src/outbound/api.rs@@ -402,6 +402,10 @@ impl McpUpstream for PipedreamClient {}impl McpConnection for PipedreamClient {+ fn is_configured(&self) -> bool {+ true+ }+#[tracing::instrument(skip_all, err, fields(app = %record.app_slug, user_id = %record.user_id))]async fn connect(&self, record: &PipedreamConnection) -> anyhow::Result<McpServer> {let upstream = self.upstream(record).await?;diff --git a/deny.toml b/deny.tomlindex 5217537605..ffb8f5afaa 100644--- a/deny.toml+++ b/deny.toml@@ -74,6 +74,7 @@ ignore = [{ id = "RUSTSEC-2023-0089", reason = "Dependency from heapless 0.7, showing up in Cargo.lock but not used on std platforms. " },{ id = "RUSTSEC-2024-0384", reason = "Cannot yet switch to web-time, due to a 3rd party openai dependency" },{ id = "RUSTSEC-2024-0436", reason = "Paste is a 'finished' crate which is heavily depended on" },+ { id = "RUSTSEC-2024-0449", reason = "No patched release; serde_yaml is used only by local/CI YAML tooling, including docker-compose-types. Parser migration is separate from runtime changes." },{ id = "RUSTSEC-2025-0012", reason = "Cannot remove dep due to 3rd party openai dependency" },{ id = "RUSTSEC-2025-0057", reason = "We should switch to rustc-hash, but haven't got to that yet" },{ id = "RUSTSEC-2026-0098", reason = "rustls-webpki 0.101.7 pinned by AWS SDK via rustls 0.21" },@@ -215,6 +216,7 @@ deny = ["lambda_runtime_api_client", # External crate allowed to use tracing-subscriber"loom", # External concurrency testing dependency"macro_entrypoint",+ "macro_authorization", # Credential-redaction span tests only"macro_tower_layers", # OpenTelemetry layer tests"native_app_server", # Dev tooling only"notification_sandbox", # This is not production code its just toolingdiff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex dc6c40bab4..6faef3cf60 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -2578,6 +2578,17 @@ a separate section. Discover offers featured providers, a searchable catalog,and `Add custom MCP`. Slack discovery retains its development-only gate.Provider Back returns to the tab that opened it; navigation is local to eachConnections page and starts at Connected on a fresh visit.++Macro agents and external AI clients using Macro's MCP server can run+`ImportNotionPage` and the shared import ledger tools against the user's+connections saved in Macro.+Verify a Notion import returns a document and a repeated import returns the+existing document; Linear imports recorded with `CreateImportEntity` should+appear in `ListImportEntities`. These calls must not report that import tracking+is unavailable.+On hosts without Pipedream credentials, saved Pipedream accounts must not hide+native Notion, Linear, or Slack connections when selecting import tools.+Provider and custom-server More menus contain Disable, Reconnect, and Disconnect;custom servers also offer Rename. Disabled grants show Enable. Unauthenticatedcustom servers show Connect and Remove. Disconnect/Remove require confirmation.diff --git a/services/mcp_service/Cargo.toml b/services/mcp_service/Cargo.tomlindex 202631eeb4..ebfbc72a1b 100644--- a/services/mcp_service/Cargo.toml+++ b/services/mcp_service/Cargo.toml@@ -56,6 +56,7 @@ fusionauth = { path = "../../crates/fusionauth" }futures = { workspace = true }github_pull_requests = { path = "../../crates/github_pull_requests" }http = { workspace = true }+import = { path = "../../crates/import" }lexical_client = { path = "../../crates/lexical_client" }macro_auth = { path = "../../crates/macro_auth" }macro_aws_config = { path = "../../crates/macro_aws_config", features = ["s3"] }@@ -67,7 +68,10 @@ macro_event_broker = { path = "../../crates/macro_event_broker" }macro_queues = { path = "../../crates/macro_queues" }macro_user_id = { path = "../../crates/macro_user_id" }mcp_auth_proxy = { path = "../mcp_auth_proxy" }+mcp_client = { path = "../../crates/mcp_client" }+mcp_select = { path = "../../crates/mcp_select" }notification = { path = "../../crates/notification", features = ["ai_tool"] }+pipedream_mcp = { path = "../../crates/pipedream_mcp" }prompt = { path = "../../crates/prompt" }readonly_pool = { path = "../../crates/readonly_pool" }redis = { workspace = true, features = ["aio", "tokio-comp"] }diff --git a/services/mcp_service/src/config.rs b/services/mcp_service/src/config.rsindex 9789c6a959..15c84c7791 100644--- a/services/mcp_service/src/config.rs+++ b/services/mcp_service/src/config.rs@@ -75,6 +75,8 @@ env_vars! {pub struct DocumentPermissionJwt;/// Comma-separated Kafka bootstrap servers for the macro event broker.pub struct KafkaBrokers;+ /// Secrets Manager secret name for the shared MCP credential encryption key.+ pub struct McpCredentialsKeySecretName;}/// The configuration parameters for the MCP server.@@ -139,6 +141,7 @@ pub struct Config {pub internal_api_key: InternalApiKey,pub document_permission_jwt: DocumentPermissionJwt,pub kafka_brokers: KafkaBrokers,+ pub mcp_credentials_key_secret_name: McpCredentialsKeySecretName,}impl Config {diff --git a/services/mcp_service/src/context.rs b/services/mcp_service/src/context.rsindex ed97e9791f..84ed33aaed 100644--- a/services/mcp_service/src/context.rs+++ b/services/mcp_service/src/context.rs@@ -278,7 +278,7 @@ async fn build_tool_context(args: ToolContextBuildArgs<'_>) -> anyhow::Result<Tocloudfront_config,sync_service_client: sync_service_client.clone(),upload_url_service: s3_upload_adapter,- task_properties_service,+ task_properties_service: task_properties_service.clone(),connection_service: NoOpConnectionService,entity_access_management_service:entity_access_management::domain::service::EntityAccessManagementServiceImpl::new(@@ -467,6 +467,58 @@ async fn build_tool_context(args: ToolContextBuildArgs<'_>) -> anyhow::Result<Toconfig.ai_pricing(),config.settlement_route()?,);+ let admission = ai_billing::composition::pg_admission_service(+ db.clone(),+ config.enable_ai_usage_enforcement,+ config.ai_pricing(),+ );++ // Import tools need the same ledger, connector credentials and entity+ // creation services as chat; advertising an unwired context makes every+ // Notion import and Linear tracking call fail before it can do any work.+ let mcp_credentials_key = LocalOrRemoteSecret::new_from_secret_manager(+ config.mcp_credentials_key_secret_name.as_ref().to_owned(),+ secretsmanager_client,+ )+ .await+ .context("failed to load MCP credentials encryption key")?;+ let mcp_encryption_key =+ mcp_client::domain::models::AesKey::try_from(mcp_credentials_key.as_ref())+ .context("invalid MCP credentials encryption key")?;+ let pipedream_client = ai_tools::pipedream_client_from_env()?;+ let mcp_selector = Arc::new(mcp_select::McpToolSelector::new(+ Arc::new(mcp_client::outbound::pg_server_repo::PgServerRepo::new(+ db.clone(),+ mcp_encryption_key,+ )),+ Arc::new(pipedream_mcp::outbound::pg_connection_repo::PgConnectionRepo::new(db.clone())),+ Arc::new(pipedream_client.clone()),+ ));+ let import_service = Arc::new(+ import::domain::service::ImportServiceImpl::new(+ import::outbound::pg_import_repo::PgImportRepo::new(db.clone()),+ mcp_selector.clone(),+ Arc::new(ai_tools::ToolEntityCreator {+ document_creator: document_tool_context.creator.clone(),+ entity_access_service: entity_access_service.clone(),+ channel_service: channel_tool_context.service.clone(),+ task_properties: task_properties_service,+ document_properties:+ import::outbound::document_properties::DocumentPropertiesApplicator::new(+ properties_service.clone(),+ ),+ team_repository: ai_tools::build_team_repository(db.clone()),+ }),+ recorder.clone(),+ )+ .with_slack_source(Arc::new(+ import::outbound::mcp_slack_source::McpSlackSource::new(mcp_selector),+ ))+ .with_admission(admission.clone())+ .with_notifier(import::outbound::gateway_notifier::gateway_import_notify(+ side_effect_clients.connection_gateway.clone(),+ )),+ );let tool_context = ToolServiceContext {connector_tool_context: ai_tools::build_connector_tool_context(db.clone(), None),@@ -505,7 +557,7 @@ async fn build_tool_context(args: ToolContextBuildArgs<'_>) -> anyhow::Result<Todatabases_tool_context,forms_tool_context,databases_sql_tool_context,- import_tool_context: ToolImportToolContext::unwired(),+ import_tool_context: ToolImportToolContext::wired(import_service),chat_tool_context,channel_tool_context,bot_tool_context: ai_tools::build_bot_tool_context(@@ -513,7 +565,7 @@ async fn build_tool_context(args: ToolContextBuildArgs<'_>) -> anyhow::Result<Toai_tools::MaybeToolEventBroker::Real(macro_event_broker.clone()),entity_access_service.clone(),dss_url,- ai_tools::pipedream_client_from_env()?,+ pipedream_client,),coding_agent_tool_context: ai_tools::build_coding_agent_tool_context(macro_service_urls::AgentHarnessServiceUrl::new()?,@@ -526,11 +578,7 @@ async fn build_tool_context(args: ToolContextBuildArgs<'_>) -> anyhow::Result<Toskill_tool_context,schedule_tool_context: ai_tools::build_routine_tool_context()?,anthropic_tool_context: ai_tools::build_anthropic_tool_context(),- admission: ai_billing::composition::pg_admission_service(- db.clone(),- config.enable_ai_usage_enforcement,- config.ai_pricing(),- ),+ admission,recorder,usage_context: ai_usage::UsageContext::system(ai_usage::AiFeature::Chat),};