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 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 21:59:12 +01:00
parent c529ab617a
commit a1cd9f2821

View File

@@ -35,6 +35,12 @@ from contextlib import asynccontextmanager
from pathlib import Path from pathlib import Path
from typing import Any, AsyncIterator, Dict 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.server.fastmcp import FastMCP
from mcp_config import MCPConfig from mcp_config import MCPConfig