Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

Merge pull request #6929 from janhq/feat/official_jan_browser_mcp

Nghia Doane56d80da3b9b
diff --git a/src-tauri/src/core/mcp/commands.rs b/src-tauri/src/core/mcp/commands.rs
index f28dd56f4..d298c217f 100644
--- a/src-tauri/src/core/mcp/commands.rs
+++ b/src-tauri/src/core/mcp/commands.rs
@@ -353,6 +353,30 @@ pub async fn get_mcp_configs<R: Runtime>(app: AppHandle<R>) -> Result<String, St
mutated = true;
}
+ // Migration: Add Jan Browser MCP if not present
+ let mcp_servers = config_object
+ .get_mut("mcpServers")
+ .and_then(|v| v.as_object_mut())
+ .ok_or("mcpServers is not an object")?;
+
+ if !mcp_servers.contains_key("Jan Browser MCP") {
+ log::info!("Migrating config: Adding 'Jan Browser MCP' server");
+ mcp_servers.insert(
+ "Jan Browser MCP".to_string(),
+ json!({
+ "command": "npx",
+ "args": ["-y", "[email protected]"],
+ "env": {
+ "BRIDGE_HOST": "127.0.0.1",
+ "BRIDGE_PORT": "17389"
+ },
+ "active": false,
+ "official": true
+ }),
+ );
+ mutated = true;
+ }
+
// Persist any mutations back to disk
if mutated {
fs::write(
diff --git a/src-tauri/src/core/mcp/constants.rs b/src-tauri/src/core/mcp/constants.rs
index a0e029268..2d2c38cf5 100644
--- a/src-tauri/src/core/mcp/constants.rs
+++ b/src-tauri/src/core/mcp/constants.rs
@@ -6,6 +6,16 @@ pub const DEFAULT_MCP_BACKOFF_MULTIPLIER: f64 = 2.0; // Double the delay each ti
pub const DEFAULT_MCP_CONFIG: &str = r#"{
"mcpServers": {
+ "Jan Browser MCP": {
+ "command": "npx",
+ "args": ["-y", "[email protected]"],
+ "env": {
+ "BRIDGE_HOST": "127.0.0.1",
+ "BRIDGE_PORT": "17389"
+ },
+ "active": false,
+ "official": true
+ },
"exa": {
"command": "npx",
"args": ["-y", "exa-mcp-server"],
diff --git a/src-tauri/src/core/setup.rs b/src-tauri/src/core/setup.rs
index 21fbf7895..51c7bb658 100644
--- a/src-tauri/src/core/setup.rs
+++ b/src-tauri/src/core/setup.rs
@@ -165,7 +165,7 @@ pub fn migrate_mcp_servers(
if mcp_version < 1 {
log::info!("Migrating MCP schema version 1");
let result = add_server_config(
- app_handle,
+ app_handle.clone(),
"exa".to_string(),
serde_json::json!({
"command": "npx",
@@ -178,7 +178,27 @@ pub fn migrate_mcp_servers(
log::error!("Failed to add server config: {e}");
}
}
- store.set("mcp_version", 1);
+ if mcp_version < 2 {
+ log::info!("Migrating MCP schema version 2: Adding Jan Browser MCP");
+ let result = add_server_config(
+ app_handle,
+ "Jan Browser MCP".to_string(),
+ serde_json::json!({
+ "command": "npx",
+ "args": ["-y", "[email protected]"],
+ "env": {
+ "BRIDGE_HOST": "127.0.0.1",
+ "BRIDGE_PORT": "17389"
+ },
+ "active": false,
+ "official": true
+ }),
+ );
+ if let Err(e) = result {
+ log::error!("Failed to add Jan Browser MCP server config: {e}");
+ }
+ }
+ store.set("mcp_version", 2);
store.save().expect("Failed to save store");
Ok(())
}
diff --git a/web-app/src/hooks/useMCPServers.ts b/web-app/src/hooks/useMCPServers.ts
index e82820026..9c6d197f4 100644
--- a/web-app/src/hooks/useMCPServers.ts
+++ b/web-app/src/hooks/useMCPServers.ts
@@ -11,6 +11,7 @@ export type MCPServerConfig = {
url?: string
headers?: Record<string, string>
timeout?: number
+ official?: boolean
}
// Define the structure of all MCP servers
diff --git a/web-app/src/routes/settings/mcp-servers.tsx b/web-app/src/routes/settings/mcp-servers.tsx
index 91069c1e7..8ae49dfd8 100644
--- a/web-app/src/routes/settings/mcp-servers.tsx
+++ b/web-app/src/routes/settings/mcp-servers.tsx
@@ -480,6 +480,16 @@ function MCPServersDesktop() {
<h1 className="text-main-view-fg text-base capitalize">
{key}
</h1>
+ {config.official && (
+ <div className="flex items-center gap-1.5 px-2 py-0.5 text-xs bg-blue-500/10 text-blue-500 rounded">
+ <img
+ src="/images/jan-logo.png"
+ alt="Jan"
+ className="w-3 h-3 object-contain"
+ />
+ <span>Official</span>
+ </div>
+ )}
</div>
}
descriptionOutside={
@@ -512,6 +522,22 @@ function MCPServersDesktop() {
.join(', ')}
</div>
)}
+ {config.official && (
+ <div className="mt-2 text-xs text-main-view-fg/60 border-t border-main-view-fg/10 pt-2">
+ <p className="mb-1">
+ Requires Jan Browser Extension to be installed
+ in your Chrome-based browser.
+ </p>
+ <a
+ href="https://github.com/menloresearch/jan-browser-extension"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-500 hover:underline"
+ >
+ Install Extension →
+ </a>
+ </div>
+ )}
</>
) : (
<>