Merge pull request #75 from a-akimov/fix-module-not-found

Fix the "module not found" error
This commit is contained in:
Jonathan Hefner 2025-11-17 07:57:20 -06:00 • committed by GitHub
commit 1604073254
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,7 @@ from mcp.client.stdio import stdio_client
from anthropic import Anthropic from anthropic import Anthropic
from dotenv import load_dotenv from dotenv import load_dotenv
from pathlib import Path
load_dotenv() # load environment variables from .env load_dotenv() # load environment variables from .env
@ -31,11 +32,16 @@ class MCPClient:
if not (is_python or is_js): if not (is_python or is_js):
raise ValueError("Server script must be a .py or .js file") raise ValueError("Server script must be a .py or .js file")
command = "python" if is_python else "node" if is_python:
path = Path(server_script_path).resolve()
server_params = StdioServerParameters( server_params = StdioServerParameters(
command=command, command="uv",
args=[server_script_path], args=["--directory", str(path.parent), "run", path.name],
env=None env=None,
)
else:
server_params = StdioServerParameters(
command="node", args=[server_script_path], env=None
) )
stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params)) stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params))