checkpoint
This commit is contained in:
@@ -7,8 +7,9 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
try:
|
||||
import mcp_client
|
||||
import shell_runner
|
||||
except ImportError:
|
||||
print(json.dumps({"error": "Failed to import mcp_client"}))
|
||||
print(json.dumps({"error": "Failed to import required modules"}))
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
@@ -30,14 +31,15 @@ def main():
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
# Note: mcp_client.configure() is usually called by the GUI before each session,
|
||||
# but for direct CLI calls, we might need a basic configuration.
|
||||
# However, mcp_client tools generally resolve paths relative to CWD if not configured.
|
||||
result = mcp_client.dispatch(tool_name, tool_input)
|
||||
if tool_name == "run_powershell":
|
||||
script = tool_input.get("script", "")
|
||||
# We use the current directory as base_dir for CLI calls
|
||||
result = shell_runner.run_powershell(script, os.getcwd())
|
||||
else:
|
||||
# mcp_client tools generally resolve paths relative to CWD if not configured.
|
||||
result = mcp_client.dispatch(tool_name, tool_input)
|
||||
|
||||
# We wrap the result in a JSON object for consistency if needed,
|
||||
# but the CLI often expects just the string result from stdout.
|
||||
# Actually, let's just print the raw result string as that's what mcp_client returns.
|
||||
# We print the raw result string as that's what gemini-cli expects.
|
||||
print(result)
|
||||
except Exception as e:
|
||||
print(f"ERROR executing tool {tool_name}: {e}")
|
||||
|
||||
Reference in New Issue
Block a user