From febfa2e708d2d37fa5156a82f158341caab670d7 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sun, 22 Feb 2026 11:21:07 -0300 Subject: [PATCH] fix(tools): use relative path for tool .mcp.json files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed tool loading to use relative path from current directory instead of hardcoded HOME/gb path. This makes the code portable across different deployment environments. - Updated use_tool.rs to use std::env::current_dir() - Updated tool_context.rs to use std::env::current_dir() - Added PathBuf import to both files - Tools now load from botserver-stack/data/system/work/ Fixes issue where tools weren't being loaded because .mcp.json files were in a different location than expected. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/basic/keywords/use_tool.rs | 8 +++++--- src/core/bot/tool_context.rs | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/basic/keywords/use_tool.rs b/src/basic/keywords/use_tool.rs index c8073f0d6..c65c9d29f 100644 --- a/src/basic/keywords/use_tool.rs +++ b/src/basic/keywords/use_tool.rs @@ -3,7 +3,7 @@ use crate::core::shared::state::AppState; use diesel::prelude::*; use log::{error, info, trace, warn}; use rhai::{Dynamic, Engine}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::sync::Arc; use uuid::Uuid; pub fn use_tool_keyword(state: Arc, user: UserSession, engine: &mut Engine) { @@ -200,8 +200,10 @@ fn associate_tool_with_session( use crate::core::shared::models::schema::session_tool_associations; // Check if tool's .mcp.json file exists in work directory - let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string()); - let gb_dir = format!("{}/gb", home_dir); + // Use relative path from botserver binary location + let gb_dir = std::env::current_dir() + .unwrap_or_else(|_| PathBuf::from(".")) + .join("botserver-stack/data/system"); // Get bot name to construct the path let bot_name = get_bot_name_from_id(state, &user.bot_id)?; diff --git a/src/core/bot/tool_context.rs b/src/core/bot/tool_context.rs index 25a7bf107..2e668817a 100644 --- a/src/core/bot/tool_context.rs +++ b/src/core/bot/tool_context.rs @@ -1,7 +1,7 @@ use diesel::prelude::*; use log::{debug, info, warn}; use serde_json::{json, Value}; -use std::path::Path; +use std::path::{Path, PathBuf}; use uuid::Uuid; use crate::core::shared::utils::DbPool; @@ -36,8 +36,10 @@ pub fn get_session_tools( } // Build path to work/{bot_name}.gbai/{bot_name}.gbdialog directory - let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string()); - let gb_dir = format!("{}/gb", home_dir); + // Use relative path from botserver binary location + let gb_dir = std::env::current_dir() + .unwrap_or_else(|_| PathBuf::from(".")) + .join("botserver-stack/data/system"); let work_path = Path::new(&gb_dir).join("work").join(format!("{}.gbai/{}.gbdialog", bot_name, bot_name)); info!("Loading {} tools for session {} from {:?}", tool_names.len(), session_id, work_path);