Skip to content
Open
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from condor.persistence import SafePicklePersistence
from handlers import cancel_command, clear_all_input_states
from utils.auth import restricted
from utils.config import TELEGRAM_TOKEN, WEB_PORT, WEB_URL
from utils.config import TELEGRAM_TOKEN, BIND_HOST, BIND_PORT, WEB_URL, WEB_PORT

# Enable logging
logging.basicConfig(
Expand Down Expand Up @@ -777,8 +777,8 @@ async def _run_dual(application: Application) -> None:
web_app = create_app()
config = uvicorn.Config(
web_app,
host="0.0.0.0",
port=WEB_PORT,
host=BIND_HOST,
port=BIND_PORT,
log_level="info",
access_log=False,
)
Expand Down
14 changes: 11 additions & 3 deletions mcp_servers/condor/condor_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""HTTP client for calling the Condor main-process web API."""

import re

import aiohttp
import ipaddress

from mcp_servers.condor.exceptions import APIError
from mcp_servers.condor.settings import settings
Expand All @@ -24,11 +24,19 @@ async def call_main_api(
"""
from condor.runtime.timeouts import TIMEOUTS
from condor.web.auth import create_jwt
from utils.config import WEB_PORT
from utils.config import BIND_HOST, BIND_PORT

if timeout is None:
timeout = TIMEOUTS.mcp_call
url = f"http://127.0.0.1:{WEB_PORT}/api/v1{path}"

try:
ip = ipaddress.ip_address(host)
if ip.version == 6:
host = f"[{host}]"
except ValueError:
pass

url = f"http://{BIND_HOST}:{BIND_PORT}/api/v1{path}"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
token = create_jwt(settings.user_id, role="user")
headers = {"Authorization": f"Bearer {token}"}

Expand Down
6 changes: 6 additions & 0 deletions utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")

_bind_host_raw = os.environ.get("BIND_HOST", "").strip()
_bind_port_raw = os.environ.get("BIND_PORT", "").strip()

BIND_HOST = str(_bind_host_raw) if _bind_host_raw else "0.0.0.0"
BIND_PORT = int(_bind_port_raw) if _bind_port_raw else 8088
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated

# Single WEB_URL param: full URL including port if needed (e.g. http://myserver.com:8088)
# Falls back to WEB_PORT for backward compat, then default 8088
_web_url_raw = os.environ.get("WEB_URL", "").strip()
Expand Down