Skip to content

Commit e2ec055

Browse files
authored
feat: per-workspace routing via X-Mcpmux-Workspace header + guided folder setup (#182)
Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent 6ac98ef commit e2ec055

29 files changed

Lines changed: 2518 additions & 83 deletions

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src-tauri/src/commands/gateway.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,23 @@ pub async fn start_gateway(
920920
let grant_service = server.grant_service();
921921
let session_roots = server.session_roots();
922922

923+
// Seed the system-wide inbound-auth toggle into the running gateway from
924+
// persisted settings (default: auth required). Live changes go through
925+
// `set_gateway_auth_disabled`.
926+
{
927+
let disabled = app_state
928+
.settings_repository
929+
.get(GATEWAY_AUTH_DISABLED_KEY)
930+
.await
931+
.ok()
932+
.flatten()
933+
.map(|v| v == "true")
934+
.unwrap_or(false);
935+
if disabled {
936+
gw_state.write().await.set_auth_disabled(true);
937+
}
938+
}
939+
923940
// Subscribe to OAuth completions BEFORE spawn so we don't miss early
924941
// events emitted during initial auto-connect.
925942
let oauth_completion_rx = pool_service.oauth_manager().subscribe();
@@ -1105,6 +1122,47 @@ pub async fn reset_gateway_port(app_state: State<'_, AppState>) -> Result<(), St
11051122
Ok(())
11061123
}
11071124

1125+
/// App-settings key for the system-wide inbound-auth toggle. Stored as
1126+
/// `"true"`/`"false"`; missing means auth is required (the secure default).
1127+
pub const GATEWAY_AUTH_DISABLED_KEY: &str = "gateway.auth_disabled";
1128+
1129+
/// Whether inbound MCP authentication is disabled — connections are accepted
1130+
/// without an access key (localhost-only convenience). Default **false** (auth
1131+
/// required).
1132+
#[tauri::command]
1133+
pub async fn get_gateway_auth_disabled(app_state: State<'_, AppState>) -> Result<bool, String> {
1134+
let stored = app_state
1135+
.settings_repository
1136+
.get(GATEWAY_AUTH_DISABLED_KEY)
1137+
.await
1138+
.map_err(|e| e.to_string())?;
1139+
Ok(stored.map(|v| v == "true").unwrap_or(false))
1140+
}
1141+
1142+
/// Enable/disable system-wide inbound auth. Persists the setting AND mirrors it
1143+
/// into the running gateway so the change takes effect immediately (no
1144+
/// restart). When the gateway isn't running it's a no-op beyond persistence —
1145+
/// `start_gateway` seeds the value on launch.
1146+
#[tauri::command]
1147+
pub async fn set_gateway_auth_disabled(
1148+
disabled: bool,
1149+
app_state: State<'_, AppState>,
1150+
gateway_state: State<'_, Arc<RwLock<GatewayAppState>>>,
1151+
) -> Result<bool, String> {
1152+
app_state
1153+
.settings_repository
1154+
.set(GATEWAY_AUTH_DISABLED_KEY, &disabled.to_string())
1155+
.await
1156+
.map_err(|e| e.to_string())?;
1157+
1158+
let state = gateway_state.read().await;
1159+
if let Some(ref gw) = state.gateway_state {
1160+
gw.write().await.set_auth_disabled(disabled);
1161+
}
1162+
info!("[Gateway] Inbound auth disabled set to {}", disabled);
1163+
Ok(disabled)
1164+
}
1165+
11081166
/// Which port source a startup attempt would use.
11091167
///
11101168
/// Kept as a string-valued enum for clean JSON serialization to the UI.

apps/desktop/src-tauri/src/commands/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod server_manager;
2121
pub mod settings;
2222
pub mod space;
2323
pub mod workspace_binding;
24+
pub mod workspace_install;
2425

2526
// Re-export commands for convenience
2627
pub use builtin_servers::*;
@@ -40,3 +41,4 @@ pub use server_manager::*;
4041
pub use settings::*;
4142
pub use space::*;
4243
pub use workspace_binding::*;
44+
pub use workspace_install::*;

0 commit comments

Comments
 (0)