fix(tools): use relative path for tool .mcp.json files
All checks were successful
BotServer CI / build (push) Successful in 8m37s
All checks were successful
BotServer CI / build (push) Successful in 8m37s
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 <noreply@anthropic.com>
This commit is contained in:
parent
de017241f2
commit
febfa2e708
2 changed files with 10 additions and 6 deletions
|
|
@ -3,7 +3,7 @@ use crate::core::shared::state::AppState;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use log::{error, info, trace, warn};
|
use log::{error, info, trace, warn};
|
||||||
use rhai::{Dynamic, Engine};
|
use rhai::{Dynamic, Engine};
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
pub fn use_tool_keyword(state: Arc<AppState>, user: UserSession, engine: &mut Engine) {
|
pub fn use_tool_keyword(state: Arc<AppState>, user: UserSession, engine: &mut Engine) {
|
||||||
|
|
@ -200,8 +200,10 @@ fn associate_tool_with_session(
|
||||||
use crate::core::shared::models::schema::session_tool_associations;
|
use crate::core::shared::models::schema::session_tool_associations;
|
||||||
|
|
||||||
// Check if tool's .mcp.json file exists in work directory
|
// Check if tool's .mcp.json file exists in work directory
|
||||||
let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
|
// Use relative path from botserver binary location
|
||||||
let gb_dir = format!("{}/gb", home_dir);
|
let gb_dir = std::env::current_dir()
|
||||||
|
.unwrap_or_else(|_| PathBuf::from("."))
|
||||||
|
.join("botserver-stack/data/system");
|
||||||
|
|
||||||
// Get bot name to construct the path
|
// Get bot name to construct the path
|
||||||
let bot_name = get_bot_name_from_id(state, &user.bot_id)?;
|
let bot_name = get_bot_name_from_id(state, &user.bot_id)?;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::core::shared::utils::DbPool;
|
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
|
// Build path to work/{bot_name}.gbai/{bot_name}.gbdialog directory
|
||||||
let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
|
// Use relative path from botserver binary location
|
||||||
let gb_dir = format!("{}/gb", home_dir);
|
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));
|
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);
|
info!("Loading {} tools for session {} from {:?}", tool_names.len(), session_id, work_path);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue