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.

feat: streamable http exa default search mcp (#7428)

Louise2c2a5caee69
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index 600e365ec..000000000
--- a/.dockerignore
+++ /dev/null
@@ -1 +0,0 @@
-**/node_modules
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 71725531c..000000000
--- a/Dockerfile
+++ /dev/null
@@ -1,49 +0,0 @@
-# Stage 1: Build stage with Node.js and Yarn v4
-FROM node:20-alpine AS builder
-
-ARG JAN_BASE_URL=https://api-dev.jan.ai/v1
-ENV JAN_BASE_URL=$JAN_BASE_URL
-
-# Install build dependencies
-RUN apk add --no-cache \
- make \
- g++ \
- python3 \
- py3-pip \
- git
-
-# Enable corepack and install Yarn 4
-RUN corepack enable && corepack prepare [email protected] --activate
-
-# Verify Yarn version
-RUN yarn --version
-
-# Set working directory
-WORKDIR /app
-
-# Copy source code
-COPY ./web-app ./web-app
-COPY ./Makefile ./Makefile
-COPY ./.* /
-COPY ./package.json ./package.json
-COPY ./yarn.lock ./yarn.lock
-COPY ./pre-install ./pre-install
-COPY ./core ./core
-
-# Build web application
-RUN yarn install && yarn build:core && make build-web-app
-
-# Stage 2: Production stage with Nginx
-FROM nginx:alpine
-
-# Copy static files from build stage
-COPY --from=builder /app/web-app/dist-web /usr/share/nginx/html
-
-# Copy custom nginx config
-COPY nginx.conf /etc/nginx/conf.d/default.conf
-
-# Expose port 80
-EXPOSE 80
-
-# Start nginx
-CMD ["nginx", "-g", "daemon off;"]
diff --git a/nginx.conf b/nginx.conf
deleted file mode 100644
index 58d44f67e..000000000
--- a/nginx.conf
+++ /dev/null
@@ -1,22 +0,0 @@
-server {
- listen 80;
- server_name localhost;
- root /usr/share/nginx/html;
- index index.html;
-
- # Handle routes with or without trailing slash
- location / {
- try_files $uri $uri/ $uri.html $uri/index.html /index.html;
- }
-
- # Security headers
- add_header X-Frame-Options "SAMEORIGIN" always;
- add_header X-Content-Type-Options "nosniff" always;
- add_header X-XSS-Protection "1; mode=block" always;
-
- # Cache static assets
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
- expires 1y;
- add_header Cache-Control "public, immutable";
- }
-}
\ No newline at end of file
diff --git a/src-tauri/src/core/mcp/constants.rs b/src-tauri/src/core/mcp/constants.rs
index 965c35bdb..49091d3ea 100644
--- a/src-tauri/src/core/mcp/constants.rs
+++ b/src-tauri/src/core/mcp/constants.rs
@@ -17,10 +17,12 @@ pub const DEFAULT_MCP_CONFIG: &str = r#"{
"official": true
},
"exa": {
- "command": "npx",
- "args": ["-y", "exa-mcp-server"],
- "env": { "EXA_API_KEY": "YOUR_EXA_API_KEY_HERE" },
- "active": false
+ "type": "http",
+ "url": "https://mcp.exa.ai/mcp",
+ "command": "",
+ "args": [],
+ "env": {},
+ "active": true
},
"browsermcp": {
"command": "npx",
diff --git a/src-tauri/src/core/mcp/mod.rs b/src-tauri/src/core/mcp/mod.rs
index 6f6378667..aa49f1860 100644
--- a/src-tauri/src/core/mcp/mod.rs
+++ b/src-tauri/src/core/mcp/mod.rs
@@ -1,5 +1,5 @@
pub mod commands;
-mod constants;
+pub mod constants;
pub mod helpers;
pub mod lockfile;
pub mod models;
diff --git a/src-tauri/src/core/setup.rs b/src-tauri/src/core/setup.rs
index ddc403e00..e536299e1 100644
--- a/src-tauri/src/core/setup.rs
+++ b/src-tauri/src/core/setup.rs
@@ -17,7 +17,9 @@ use tauri::{
};
use tauri_plugin_store::Store;
+use crate::core::mcp::constants::DEFAULT_MCP_CONFIG;
use crate::core::mcp::helpers::add_server_config;
+use crate::core::app::commands::get_jan_data_folder_path;
use super::{
extensions::commands::get_jan_extensions_path, mcp::helpers::run_mcp_commands, state::AppState,
@@ -181,7 +183,7 @@ pub fn migrate_mcp_servers(
if mcp_version < 2 {
log::info!("Migrating MCP schema version 2: Adding Jan Browser MCP");
let result = add_server_config(
- app_handle,
+ app_handle.clone(),
"Jan Browser MCP".to_string(),
serde_json::json!({
"command": "npx",
@@ -198,11 +200,53 @@ pub fn migrate_mcp_servers(
log::error!("Failed to add Jan Browser MCP server config: {e}");
}
}
- store.set("mcp_version", 2);
+ if mcp_version < 3 {
+ log::info!("Migrating MCP schema version 3: Updating Exa to streamable HTTP");
+ if let Err(e) = migrate_exa_to_http(app_handle) {
+ log::error!("Failed to migrate Exa to HTTP: {e}");
+ }
+ }
+ store.set("mcp_version", 3);
store.save().expect("Failed to save store");
Ok(())
}
+fn migrate_exa_to_http(app_handle: tauri::AppHandle) -> Result<(), String> {
+ let config_path = get_jan_data_folder_path(app_handle).join("mcp_config.json");
+
+ let config_str = fs::read_to_string(&config_path)
+ .map_err(|e| format!("Failed to read MCP config: {e}"))?;
+
+ let mut config: serde_json::Value = serde_json::from_str(&config_str)
+ .map_err(|e| format!("Failed to parse MCP config: {e}"))?;
+
+ if let Some(servers) = config
+ .get_mut("mcpServers")
+ .and_then(|s| s.as_object_mut())
+ {
+ servers.insert(
+ "exa".to_string(),
+ serde_json::json!({
+ "type": "http",
+ "url": "https://mcp.exa.ai/mcp".to_string(),
+ "command": "",
+ "args": [],
+ "env": {},
+ "active": true
+ }),
+ );
+ }
+
+ fs::write(
+ &config_path,
+ serde_json::to_string_pretty(&config)
+ .map_err(|e| format!("Failed to serialize MCP config: {e}"))?,
+ )
+ .map_err(|e| format!("Failed to write MCP config: {e}"))?;
+
+ Ok(())
+}
+
pub fn extract_extension_manifest<R: Read>(
archive: &mut Archive<R>,
) -> Result<Option<serde_json::Value>, String> {
@@ -240,6 +284,15 @@ pub fn setup_mcp<R: Runtime>(app: &App<R>) {
tauri::async_runtime::spawn(async move {
use crate::core::mcp::lockfile::cleanup_all_stale_locks;
+ // Create default mcp_config.json if it doesn't exist
+ let config_path = get_jan_data_folder_path(app_handle.clone()).join("mcp_config.json");
+ if !config_path.exists() {
+ log::info!("mcp_config.json not found, creating default config");
+ if let Err(e) = fs::write(&config_path, DEFAULT_MCP_CONFIG) {
+ log::error!("Failed to create default MCP config: {e}");
+ }
+ }
+
if let Err(e) = cleanup_all_stale_locks(&app_handle).await {
log::debug!("Lock file cleanup error: {}", e);
}