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
refactor(agent-harness): resolve public URLs from service definitions (#8560)
Wolf Mermelstein423ff827f2f2
diff --git a/.agents/rules/config-and-service-urls.md b/.agents/rules/config-and-service-urls.mdindex f04e94a562..c72e70958a 100644--- a/.agents/rules/config-and-service-urls.md+++ b/.agents/rules/config-and-service-urls.md@@ -32,8 +32,8 @@ startup loudly.## Service URLs-- Service-to-service URLs are typed in `crates/macro_service_urls`- (`service_url!` with `local`/`dev`/`prod`), chosen by `ENVIRONMENT`. Call+- Stable service URLs and public OAuth/callback/app origins are typed in+ `crates/macro_service_urls` (`service_url!` with `local`/`dev`/`prod`), chosen by `ENVIRONMENT`. Call`XServiceUrl::new()`. Never declare a `FOO_SERVICE_URL` env var or match on`Environment` to build a URL. Queue names follow the same pattern in`crates/macro_queues`.@@ -42,9 +42,16 @@ startup loudly.`xtask_local`'s `local_env.rs`; `local` defaults are host ports and do notwork inside Docker.- The URL table is hand-copied. A new or changed service URL updates every copy:- `macro_service_urls`, `infra/packages/shared/src/service_urls.ts`,- `apps/web/src/lib/core/constant/servers.ts`, `packages/sdk/src/config.ts`, and- any `wrangler` `[env.*.vars]` that call it.+ `macro_service_urls` and `infra/packages/shared/src/service_urls.ts`, plus each+ consuming runtime (`apps/web/src/lib/core/constant/servers.ts`,+ `packages/sdk/src/config.ts`, and worker `[env.*.vars]`). Do not add unused+ public OAuth identities to API transport maps.+- Keep registered public OAuth identities separate from internal gateway API+ routes. Do not store stable URLs in Doppler; reserve it for secrets and+ infrastructure-generated addresses (such as preview DNS and SSH hosts).+- When removing required Doppler URL fields, retain their existing values until+ the deployed rollback baseline no longer requires them; migrate consumers to+ typed URLs before deleting compatibility resources.## Other runtimesdiff --git a/crates/macro_service_urls/AGENTS.md b/crates/macro_service_urls/AGENTS.mdindex 486c251c4b..16cdd708c6 100644--- a/crates/macro_service_urls/AGENTS.md+++ b/crates/macro_service_urls/AGENTS.md@@ -39,7 +39,9 @@ service and gateway, resolved from `macro_env::Environment` with an## Agent service URLsCognition, scheduling, preview control, and public MCP have distinct API base-paths but share the agent harness process. Their direct local defaults use+paths but share the agent harness process. `McpPublicUrl` and+`CognitionPublicUrl` separately preserve the registered public OAuth identities;+do not substitute the internal API routes when building callbacks. Their direct local defaults useport 8101 with `/cognition`, `/scheduled-action`, `/preview`, and the MCP baseat the root. Gateway paths remain unchanged.diff --git a/crates/macro_service_urls/src/lib.rs b/crates/macro_service_urls/src/lib.rsindex 4d3c8caca5..e409015d87 100644--- a/crates/macro_service_urls/src/lib.rs+++ b/crates/macro_service_urls/src/lib.rs@@ -590,6 +590,18 @@ service_url! {dev: "https://dev-gateway.macro.com/mcp",prod: "https://gateway.macro.com/mcp",},+ /// Public MCP OAuth issuer and callback base, distinct from gateway transport routing.+ pub McpPublicUrl {+ local: "http://localhost:8101",+ dev: "https://mcp-server-dev.macro.com",+ prod: "https://mcp-server.macro.com",+ },+ /// Public integration callback base, preserving registered OAuth redirect URIs.+ pub CognitionPublicUrl {+ local: "http://localhost:8101/cognition",+ dev: "https://document-cognition-dev.macro.com",+ prod: "https://document-cognition.macro.com",+ },/// Link unfurl service API URL.pub UnfurlServiceUrl {local: "http://localhost:8095",diff --git a/docs/agent-guide/calls.md b/docs/agent-guide/calls.mdindex 66091b73fc..6ffc0d3cb8 100644--- a/docs/agent-guide/calls.md+++ b/docs/agent-guide/calls.md@@ -48,7 +48,7 @@ Soup lists without a refresh; history is not backfilled. Imported calls appearin `All` and `Attended`, never in a channel's `Calls` tab, and open in thenormal call detail with title, summary, attendees(shown as guests), and transcript but no recording. Rename and delete do not-apply to imported calls yet. Webhooks require a public HTTPS `MCP_PUBLIC_URL`;+apply to imported calls yet. Webhooks require a public HTTPS cognition callback origin (`CognitionPublicUrl`);on a laptop stack, expose the webhook path with a tunnel such as Tailscale Funnel.A channel's `Calls` tab lists that channel's recordings with the same rows, filtereddiff --git a/docs/guides/consolidate-agent-services.md b/docs/guides/consolidate-agent-services.mdindex 3a0592dd93..fb97f57cb3 100644--- a/docs/guides/consolidate-agent-services.md+++ b/docs/guides/consolidate-agent-services.md@@ -46,19 +46,28 @@ The cognition CloudFront signer setting must retain its Secrets Managerreference, replacing any obsolete inline harness value under that name. TheAI tool context uses the separate `_SECRET_NAME` setting for the same key.-`MCP_PUBLIC_URL` is the original `https://mcp-server[-dev].macro.com` server-base. `MCP_CLIENT_PUBLIC_URL` is the original-`https://document-cognition[-dev].macro.com` outbound integration callback base.-The former services used `MCP_PUBLIC_URL` for both meanings. The gateway keeps-its existing feature-prefix routes as well. Host rules on the shared gateway-forward the original MCP paths unchanged and prepend `/cognition` internally-for the original cognition host. The browser URL and OAuth redirect URI remain-unchanged. The shared wildcard certificate already covers both hostnames.-Local instance generation sets both values separately and sets `APP_BASE_URL`-to the instance's frontend origin. Its FusionAuth configuration permits callbacks-through both loopback and the machine hostname; the default harness API is-published on port 8101, matching the SDK port map. The `local/lcl_personal` Doppler config also-contains the renamed client setting.+Stable public origins now come from `macro_service_urls`: `McpPublicUrl` is the+original `https://mcp-server[-dev].macro.com` server base and `CognitionPublicUrl`+is the original `https://document-cognition[-dev].macro.com` integration callback+base. Keep these distinct from internal gateway API routes. The shared gateway+forwards MCP paths unchanged and prepends `/cognition` for the cognition host;+registered OAuth redirects and browser URLs are unchanged.++`AppServiceUrl` supplies browser links and preview form origins. Preview control+uses the host of `PreviewGatewayUrl`; local instances also accept their app and+loopback hosts. Local instance generation supplies process-level+`OVERRIDE_MCP_PUBLIC_URL`, `OVERRIDE_COGNITION_PUBLIC_URL`, and+`OVERRIDE_APP_SERVICE_URL`. `PREVIEW_DOMAIN` and `PREVIEW_SSH_HOST` remain in+Doppler because infrastructure generates them.++The Pulumi stack temporarily retains the old `MCP_PUBLIC_URL`,+`MCP_CLIENT_PUBLIC_URL`, `PREVIEW_APP_ORIGIN`, and `PREVIEW_CONTROL_HOSTS`+resources with frozen values and `retainOnDelete`. This allows automatic ECS+rollback to the previous image, which still requires these keys. New binaries+ignore them. After the new version is the rollback baseline in both environments,+remove those compatibility resource declarations; do not delete the retained+Doppler values while historical-image rollback is still needed. `APP_BASE_URL`+is also ignored by the new harness; other services may still consume it.`POSTHOG_API_KEY` and `POSTHOG_HOST` are already typed harness fields. Theyremain available for existing feature flags and future analytics. No MCPdiff --git a/infra/packages/shared/src/service_urls.ts b/infra/packages/shared/src/service_urls.tsindex 6b7d444f43..842362e16b 100644--- a/infra/packages/shared/src/service_urls.ts+++ b/infra/packages/shared/src/service_urls.ts@@ -10,6 +10,8 @@ export const AGENT_PUBLIC_URLS = {* Service url for all macro services*/export enum ServiceUrl {+ APP_SERVICE_URL = 'APP_SERVICE_URL',+ PREVIEW_GATEWAY_URL = 'PREVIEW_GATEWAY_URL',SYNC_SERVICE_URL = 'SYNC_SERVICE_URL',EMAIL_SERVICE_URL = 'EMAIL_SERVICE_URL',STATIC_FILE_SERVICE_URL = 'STATIC_FILE_SERVICE_URL',@@ -36,6 +38,8 @@ type ServiceUrlMap = {* Dev Service URLs*/const DEV_SERVICE_URLS: ServiceUrlMap = {+ [ServiceUrl.APP_SERVICE_URL]: 'https://dev.macro.com',+ [ServiceUrl.PREVIEW_GATEWAY_URL]: 'https://dev-gateway.macro.com/preview',[ServiceUrl.SYNC_SERVICE_URL]:'https://sync-service-dev3.macroverse.workers.dev',[ServiceUrl.EMAIL_SERVICE_URL]: 'https://dev-gateway.macro.com/email',@@ -63,6 +67,8 @@ const DEV_SERVICE_URLS: ServiceUrlMap = {* Prod Service URLs*/const PROD_SERVICE_URLS: ServiceUrlMap = {+ [ServiceUrl.APP_SERVICE_URL]: 'https://macro.com',+ [ServiceUrl.PREVIEW_GATEWAY_URL]: 'https://gateway.macro.com/preview',[ServiceUrl.SYNC_SERVICE_URL]:'https://sync-service-prod2.macroverse.workers.dev',[ServiceUrl.EMAIL_SERVICE_URL]: 'https://gateway.macro.com/email',diff --git a/infra/stacks/agent-harness-service/index.ts b/infra/stacks/agent-harness-service/index.tsindex 2b12c1bf7f..c7bc0c604a 100644--- a/infra/stacks/agent-harness-service/index.ts+++ b/infra/stacks/agent-harness-service/index.ts@@ -131,16 +131,10 @@ const fusionauthSecretArns = [(name) => aws.secretsmanager.getSecretOutput({ name: `${name}-${stack}` }).arn);-// Public addresses must publish before ECS reads APP_SECRETS_JSON.+// Only infrastructure-generated preview addresses are runtime configuration.const configurationSecrets = Object.entries({PREVIEW_DOMAIN: preview.requireOutput('previewDomain'),PREVIEW_SSH_HOST: preview.requireOutput('previewSshHost'),- PREVIEW_APP_ORIGIN:- stack === 'prod' ? 'https://macro.com' : 'https://dev.macro.com',- PREVIEW_CONTROL_HOSTS:- stack === 'prod' ? 'gateway.macro.com' : 'dev-gateway.macro.com',- MCP_PUBLIC_URL: AGENT_PUBLIC_URLS.mcp,- MCP_CLIENT_PUBLIC_URL: AGENT_PUBLIC_URLS.cognition,}).map(([key, value]) =>new doppler.Secret(`harness-${key}-${stack}`, {@@ -151,6 +145,31 @@ const configurationSecrets = Object.entries({}));+// Retain the previous binary's required keys through this rolling deployment+// and automatic rollback. The harness no longer reads these mirrors. After this+// version is the rollback baseline, remove these resources; retainOnDelete keeps+// that later removal from deleting values still needed by historical images.+const legacyUrlSecrets = Object.entries({+ PREVIEW_APP_ORIGIN: getServiceUrl(ServiceUrl.APP_SERVICE_URL),+ PREVIEW_CONTROL_HOSTS: new URL(getServiceUrl(ServiceUrl.PREVIEW_GATEWAY_URL))+ .hostname,+ MCP_PUBLIC_URL: AGENT_PUBLIC_URLS.mcp,+ MCP_CLIENT_PUBLIC_URL: AGENT_PUBLIC_URLS.cognition,+}).map(+ ([key, value]) =>+ new doppler.Secret(+ `harness-${key}-${stack}`,+ {+ project: 'agent-harness-service',+ config: stack === 'prod' ? 'prd' : 'dev',+ name: key,+ value,+ },+ { retainOnDelete: true, ignoreChanges: ['value'] }+ )+);+configurationSecrets.push(...legacyUrlSecrets);+const service = new AgentHarnessService(`agent-harness-service-${stack}`,{diff --git a/services/agent_harness_service/AGENTS.md b/services/agent_harness_service/AGENTS.mdindex 13febb1776..5f708d393a 100644--- a/services/agent_harness_service/AGENTS.md+++ b/services/agent_harness_service/AGENTS.md@@ -80,10 +80,18 @@ message attribution after owner approval, while retaining user authentication.## Configuration and lifecycleAll feature configs read the same harness `APP_SECRETS_JSON`; the harness-Doppler validation binary validates each config. `MCP_PUBLIC_URL` is the public-server origin (`mcp-server[-dev].macro.com`); `MCP_CLIENT_PUBLIC_URL` is the-integrations callback origin (`document-cognition[-dev].macro.com`). The shared-gateway preserves these hostnames and internally rewrites cognition paths. Both settings are required; keep them separate. `POSTHOG_API_KEY` and `POSTHOG_HOST` remain+Doppler validation binary validates each config. Stable public origins resolve+once at startup through `macro_service_urls`: `McpPublicUrl` preserves the+`mcp-server[-dev].macro.com` OAuth identity, `CognitionPublicUrl` preserves+`document-cognition[-dev].macro.com` integration callbacks, and `AppServiceUrl`+supplies browser links and preview form origin. Preview control accepts the+`PreviewGatewayUrl` host (plus app/loopback hosts locally). Use process-level+`OVERRIDE_*` values for local instances. The shared gateway preserves the public+hostnames and internally rewrites cognition paths. `PREVIEW_DOMAIN` and+`PREVIEW_SSH_HOST` remain infrastructure-generated Doppler settings. Legacy+`MCP_PUBLIC_URL`, `MCP_CLIENT_PUBLIC_URL`, `PREVIEW_APP_ORIGIN`, and+`PREVIEW_CONTROL_HOSTS` values are retained only for old-image rollback; new+code does not read them. `POSTHOG_API_KEY` and `POSTHOG_HOST` remainavailable for feature flags and future analytics; MCP emits no analytics events.In deployed configs, `DOCUMENT_STORAGE_SERVICE_CLOUDFRONT_SIGNER_PRIVATE_KEY`is cognition's Secrets Manager reference; AI tools resolve the separatediff --git a/services/agent_harness_service/src/cognition/config.rs b/services/agent_harness_service/src/cognition/config.rsindex 964f06d177..6ed0601940 100644--- a/services/agent_harness_service/src/cognition/config.rs+++ b/services/agent_harness_service/src/cognition/config.rs@@ -149,8 +149,6 @@ pub struct Config {/// AI editing worker URL#[macro_config_default(AiEditingWorkerUrl::unwrap_new().to_string())]pub ai_editing_worker_url: String,- /// Browser-facing base URL used for MCP OAuth redirects and client metadata.- pub mcp_client_public_url: String,/// JWT secret for minting document permission tokens for the editing worker.pub document_permission_jwt: DocumentPermissionJwt,/// Comma-separated Kafka bootstrap servers for the macro event broker.@@ -249,7 +247,6 @@ impl Config {pipedream_webhook_secret: PipedreamWebhookSecret::Unset,internal_api_key: InternalApiKey::Comptime(""),ai_editing_worker_url: AiEditingWorkerUrl::unwrap_new().to_string(),- mcp_client_public_url: "http://localhost:8101/cognition".to_string(),document_permission_jwt: DocumentPermissionJwt::Comptime("DOCUMENT_PERMISSION_JWT"),kafka_brokers: KafkaBrokers::Comptime("localhost:9092"),enable_non_user_owners: EnableNonUserOwners::Unset,diff --git a/services/agent_harness_service/src/cognition/config/test.rs b/services/agent_harness_service/src/cognition/config/test.rsindex ae1af4473b..a0fd948400 100644--- a/services/agent_harness_service/src/cognition/config/test.rs+++ b/services/agent_harness_service/src/cognition/config/test.rs@@ -1,7 +1,7 @@use super::*;#[test]-fn gateway_mcp_client_callback_is_in_the_slack_manifest() {+fn public_mcp_client_callback_is_in_the_slack_manifest() {let manifest: serde_json::Value = serde_json::from_str(include_str!("../../../../../crates/mcp_client/src/domain/provider_registry/slack/manifest.json"))@@ -16,7 +16,7 @@ fn gateway_mcp_client_callback_is_in_the_slack_manifest() {for environment in [Environment::Production, Environment::Develop] {let callback = format!("{}/mcp/servers/auth/callback",- macro_service_urls::DocumentCognitionServiceUrl::default_for_environment(environment)+ macro_service_urls::CognitionPublicUrl::default_for_environment(environment));assert!(registered.contains(&callback.as_str()),diff --git a/services/agent_harness_service/src/cognition/server.rs b/services/agent_harness_service/src/cognition/server.rsindex ffbc718e7f..290152d0ca 100644--- a/services/agent_harness_service/src/cognition/server.rs+++ b/services/agent_harness_service/src/cognition/server.rs@@ -95,6 +95,7 @@ pub async fn build(db: sqlx::PgPool,event_broker_tracker: TaskTracker,) -> anyhow::Result<CognitionRuntime> {+ let public_url = macro_service_urls::CognitionPublicUrl::new()?;let aws_config = macro_aws_config::get_macro_aws_config().await;let secretsmanager_client = secretsmanager_client::SecretsManager::new(aws_sdk_secretsmanager::Client::new(&aws_config),@@ -668,7 +669,7 @@ pub async fn build(),macro_event_broker.clone(),)),- public_url: config.mcp_client_public_url.clone(),+ public_url: public_url.to_string(),}) as Arc<dyn granola_sync::domain::service::SyncService>});let granola_worker = granola_sync@@ -951,7 +952,7 @@ pub async fn build(tracing::info!("initialized onboarding service");- let mcp_client_public_url = &config.mcp_client_public_url;+ let mcp_client_public_url = &public_url;let mcp_client_metadata = mcp_client::domain::models::OAuthClientMetadata::new(format!("{mcp_client_public_url}/mcp/servers/auth/client-metadata"),format!("{mcp_client_public_url}/mcp/servers/auth/callback"),diff --git a/services/agent_harness_service/src/config.rs b/services/agent_harness_service/src/config.rsindex aaddfc6a96..6ba1dfac71 100644--- a/services/agent_harness_service/src/config.rs+++ b/services/agent_harness_service/src/config.rs@@ -74,8 +74,6 @@ pub struct Config {/// Shared pool for sessions, chat, integrations, and routine workers.#[macro_config_default(30)]pub database_max_connections: u32,- /// Public workspace MCP base, including its gateway prefix.- pub mcp_public_url: McpPublicUrl,/// FusionAuth API origin used by the public MCP OAuth broker.pub fusionauth_base_url: FusionauthBaseUrl,/// FusionAuth application used for MCP sign-in.@@ -88,8 +86,6 @@ pub struct Config {pub google_client_id: GoogleClientId,/// Secret name of the Google OAuth client credential.pub google_client_secret_key: GoogleClientSecretKey,- /// Frontend origin used to link items in MCP responses.- pub app_base_url: AppBaseUrl,/// Browser-reachable FusionAuth origin, when different from the API.pub fusionauth_public_url: FusionauthPublicUrl,/// Additional trusted client callback hosts, overriding the built-in list.@@ -329,8 +325,6 @@ impl Config {}macro_env_var::env_vars! {- /// Public MCP OAuth configuration.- pub struct McpPublicUrl;/// Public MCP OAuth configuration.pub struct FusionauthBaseUrl;/// Public MCP OAuth configuration.@@ -343,8 +337,6 @@ macro_env_var::env_vars! {pub struct GoogleClientId;/// Public MCP OAuth configuration.pub struct GoogleClientSecretKey;- /// Public MCP OAuth configuration.- pub struct AppBaseUrl;}macro_env_var::maybe_env_vars! {/// Optional public MCP OAuth configuration.diff --git a/services/agent_harness_service/src/preview.rs b/services/agent_harness_service/src/preview.rsindex 58fb35557f..cb1f49eef3 100644--- a/services/agent_harness_service/src/preview.rs+++ b/services/agent_harness_service/src/preview.rs@@ -34,6 +34,22 @@ pub async fn build(shutdown: tokio_util::sync::CancellationToken,tasks: tokio_util::task::TaskTracker,) -> Result<Router, rootcause::Report> {+ let app_url = macro_service_urls::AppServiceUrl::new()?;+ let control_url = macro_service_urls::PreviewGatewayUrl::new()?;+ let mut allowed_hosts = Vec::new();+ let mut control_urls = vec![control_url.parse_url()?];+ if matches!(config.environment, macro_env::Environment::Local) {+ control_urls.push(app_url.parse_url()?);+ }+ for url in control_urls {+ let host = url+ .host_str()+ .ok_or_else(|| rootcause::report!("preview control URL requires a host"))?;+ allowed_hosts.push(host.to_owned());+ }+ if matches!(config.environment, macro_env::Environment::Local) {+ allowed_hosts.extend(["localhost".to_owned(), "127.0.0.1".to_owned()]);+ }let aws = macro_aws_config::get_macro_aws_config().await;let secrets =secretsmanager_client::SecretsManager::new(aws_sdk_secretsmanager::Client::new(&aws));@@ -76,7 +92,7 @@ pub async fn build(.preview_ssh_proxy_host.filter(|host| !host.is_empty()),host_key: public_key,- app_origin: config.preview_app_origin,+ app_origin: app_url.to_string(),},Arc::new(adapters::MacroAuthority {sessions: agent_session::outbound::postgres::PgAgentSessionRepo::new(@@ -105,12 +121,6 @@ pub async fn build(access,MacroAuthorizationState::new(Arc::new(auth)),));- let allowed_hosts: Vec<String> = config- .preview_control_hosts- .split(',')- .map(|s| s.trim().to_owned())- .filter(|host| !host.is_empty())- .collect();tracing::info!(hosts = ?allowed_hosts,"preview control listener ready"diff --git a/services/agent_harness_service/src/preview/config.rs b/services/agent_harness_service/src/preview/config.rsindex bdf79567c3..134a855ba0 100644--- a/services/agent_harness_service/src/preview/config.rs+++ b/services/agent_harness_service/src/preview/config.rs@@ -18,10 +18,6 @@ pub struct Config {pub preview_ssh_public_port: u16,#[macro_config_default(443)]pub preview_https_port: u16,- /// Exact origin allowed to submit the browser authentication form.- pub preview_app_origin: String,- /// Comma separated DNS hostnames accepted on the internal MCP listener.- pub preview_control_hosts: String,#[macro_config_default(8111)]pub preview_http_port: u16,#[macro_config_default(2222)]diff --git a/services/agent_harness_service/src/public_mcp.rs b/services/agent_harness_service/src/public_mcp.rsindex 10480a9c82..a8eb5fc439 100644--- a/services/agent_harness_service/src/public_mcp.rs+++ b/services/agent_harness_service/src/public_mcp.rs@@ -42,13 +42,15 @@ pub async fn router(background_tasks: tokio_util::task::TaskTracker,cancellation: tokio_util::sync::CancellationToken,) -> anyhow::Result<axum::Router> {- let auth_proxy = build_auth_proxy(config, secrets).await?;- let item_base_url = config.app_base_url.to_string();+ let public_url = macro_service_urls::McpPublicUrl::new()?;+ let auth_proxy = build_auth_proxy(config, secrets, &public_url).await?;+ let item_base_url = macro_service_urls::AppServiceUrl::new()?.to_string();let static_file_base_url =url::Url::parse(macro_service_urls::StaticFileServiceUrl::new()?.as_ref())?;- let mcp_public_host = url::Url::parse(config.mcp_public_url.as_ref())?+ let mcp_public_host = public_url+ .parse_url()?.host_str()- .context("MCP_PUBLIC_URL has no host")?+ .context("public MCP URL has no host")?.to_owned();// Create the MCP service with authenticated tool handlerlet mcp_service = StreamableHttpService::new(@@ -106,8 +108,9 @@ pub async fn router(async fn build_auth_proxy(config: &Config,secretsmanager_client: &secretsmanager_client::SecretsManager,+ public_url: ¯o_service_urls::McpPublicUrl,) -> anyhow::Result<McpAuthProxyServiceImpl<RedisInflightAuth>> {- let mcp_public_url: String = config.mcp_public_url.as_ref().to_owned();+ let mcp_public_url = public_url.to_string();let mcp_oauth_redirect_uri = format!("{mcp_public_url}/oauth/callback");let fusionauth_api_key = LocalOrRemoteSecret::new_from_secret_manager(diff --git a/services/agent_harness_service/src/public_mcp/tool_service.rs b/services/agent_harness_service/src/public_mcp/tool_service.rsindex cc631ebd40..29d8b6c9f3 100644--- a/services/agent_harness_service/src/public_mcp/tool_service.rs+++ b/services/agent_harness_service/src/public_mcp/tool_service.rs@@ -34,8 +34,7 @@ pub struct AuthenticatedToolService<Context> {toolset: Arc<AsyncToolCollection<Context>>,context: Context,/// Base URL of the Macro web app used to build links to Macro items in MCP- /// responses (e.g. `https://macro.com`). Comes from the `APP_BASE_URL`- /// environment variable.+ /// responses (e.g. `https://macro.com`). Resolved at startup from `AppServiceUrl`.item_base_url: String,/// Static file CDN used for attachments returned by authorized channel reads.static_file_base_url: url::Url,diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env.rs b/tooling/xtask/crates/xtask_local/src/local/local_env.rsindex a8754773f2..326b230a7d 100644--- a/tooling/xtask/crates/xtask_local/src/local/local_env.rs+++ b/tooling/xtask/crates/xtask_local/src/local/local_env.rs@@ -47,7 +47,6 @@ pub struct LocalEnv {preview_ssh_proxy_host: Option<String>,preview_ssh_port: u16,preview_https_port: u16,- preview_control_hosts: String,/// Browser-facing origin for post-login redirects and Pipedream CORS./// Both attached and headless frontends are exposed through HTTPS.frontend_origin: String,@@ -107,10 +106,6 @@ impl LocalEnv {mcp_client_public_url: format!("{frontend_origin}/cognition"),static_file_public_url: format!("{frontend_origin}/static-file"),frontend_origin,- preview_control_hosts: format!(- "localhost,127.0.0.1,agent-harness-service,{}",- super::tls::hostname()?- ),external_egress_url: tunnels.egress.map(str::to_owned).unwrap_or_else(|| {format!("http://localhost:{}",@@ -141,11 +136,11 @@ impl LocalEnv {env.insert("FRONTEND_ORIGIN".into(), self.frontend_origin.clone());env.insert("APP_BASE_URL".into(), self.frontend_origin.clone());env.insert(- "MCP_CLIENT_PUBLIC_URL".into(),+ "OVERRIDE_COGNITION_PUBLIC_URL".into(),self.mcp_client_public_url.clone(),);env.insert(- "MCP_PUBLIC_URL".into(),+ "OVERRIDE_MCP_PUBLIC_URL".into(),self.mcp_client_public_url.trim_end_matches("/cognition").to_owned()@@ -194,10 +189,9 @@ impl LocalEnv {"PREVIEW_HTTPS_PORT".into(),self.preview_https_port.to_string(),);- env.insert("PREVIEW_APP_ORIGIN".into(), self.frontend_origin.clone());env.insert(- "PREVIEW_CONTROL_HOSTS".into(),- self.preview_control_hosts.clone(),+ "OVERRIDE_APP_SERVICE_URL".into(),+ self.frontend_origin.clone(),);self.infra.write(&mut env);self.storage.write(&mut env);diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs b/tooling/xtask/crates/xtask_local/src/local/local_env/test.rsindex b777162b54..36f2c4b968 100644--- a/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs+++ b/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs@@ -93,7 +93,7 @@ fn emits_required_keys() {"FUSIONAUTH_API_KEY_SECRET_KEY","FUSIONAUTH_PUBLIC_URL","FUSIONAUTH_OAUTH_REDIRECT_URI",- "MCP_CLIENT_PUBLIC_URL",+ "OVERRIDE_COGNITION_PUBLIC_URL","JWT_SECRET_KEY",// Boot-blocking stubs — service config loaders require these even in a// no-doppler stack (see `BootStubEnv`).@@ -483,11 +483,15 @@ fn mcp_client_public_url_uses_the_proxy_cognition_route() {let named_public_url = format!("https://localhost:{}/cognition", named.port(Port::Proxy));assert_eq!(- default_env.get("MCP_CLIENT_PUBLIC_URL").map(String::as_str),+ default_env+ .get("OVERRIDE_COGNITION_PUBLIC_URL")+ .map(String::as_str),Some("https://localhost:8090/cognition"));assert_eq!(- named_env.get("MCP_CLIENT_PUBLIC_URL").map(String::as_str),+ named_env+ .get("OVERRIDE_COGNITION_PUBLIC_URL")+ .map(String::as_str),Some(named_public_url.as_str()));}@@ -511,20 +515,18 @@ fn frontend_origin_tracks_how_the_app_is_served() {for key in ["FRONTEND_ORIGIN","PIPEDREAM_ALLOWED_ORIGINS",- "PREVIEW_APP_ORIGIN",+ "OVERRIDE_APP_SERVICE_URL",] {assert_eq!(env[key], origin, "{key}");}- assert_eq!(env["MCP_CLIENT_PUBLIC_URL"], format!("{origin}/cognition"));+ assert_eq!(+ env["OVERRIDE_COGNITION_PUBLIC_URL"],+ format!("{origin}/cognition")+ );assert_eq!(env["OVERRIDE_STATIC_FILE_PUBLIC_URL"],format!("{origin}/static-file"));- assert!(- env["PREVIEW_CONTROL_HOSTS"]- .split(',')- .any(|host| host == super::super::tls::hostname().unwrap())- );}}}