From a1cd9f2821cd7960529d0a5bd03e0511c7af41e8 Mon Sep 17 00:00:00 2001 From: David Blanc Brioir Date: Sat, 31 Jan 2026 21:59:12 +0100 Subject: [PATCH] Fix sys.path for MCP server when run from different directory Add library_rag directory to sys.path at startup so that imports like 'utils.pdf_pipeline' and 'mcp_tools' work correctly when the server is spawned by Ikario from a different working directory. Co-Authored-By: Claude Opus 4.5 --- generations/library_rag/mcp_server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generations/library_rag/mcp_server.py b/generations/library_rag/mcp_server.py index a023329..515626e 100644 --- a/generations/library_rag/mcp_server.py +++ b/generations/library_rag/mcp_server.py @@ -35,6 +35,12 @@ from contextlib import asynccontextmanager from pathlib import Path from typing import Any, AsyncIterator, Dict +# Add the library_rag directory to sys.path for proper imports +# This is needed when the script is run from a different working directory +_script_dir = Path(__file__).parent.resolve() +if str(_script_dir) not in sys.path: + sys.path.insert(0, str(_script_dir)) + from mcp.server.fastmcp import FastMCP from mcp_config import MCPConfig