Skip to content

Commit 36385c5

Browse files
committed
Refactor restart script: replace old script with a new version supporting ListenHost parameter for improved network access control
1 parent b97f33d commit 36385c5

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

restart.ps1 renamed to restart0.0.0.0.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# One-shot restart script for AgentChatBus.
33
# Usage (from project root): .\restart.ps1
44
# Usage (custom port): .\restart.ps1 -Port 8080
5-
# Usage (network access): .\restart.ps1 -Host 0.0.0.0 # Exposes to network (USE WITH CAUTION!)
5+
# Usage (network access): .\restart.ps1 -ListenHost 0.0.0.0 # Exposes to network (USE WITH CAUTION!)
66

77
param(
8-
[string]$Host = "0.0.0.0", # Default: 0.0.0.0 binds to all network interfaces (CAUTION: security risk!)
8+
[string]$ListenHost = "0.0.0.0", # Default: 0.0.0.0 binds to all network interfaces (CAUTION: security risk!)
99
[int]$Port = 39765
1010
)
1111

@@ -30,12 +30,12 @@ Get-NetTCPConnection -LocalPort $Port -ErrorAction SilentlyContinue |
3030

3131
Start-Sleep -Milliseconds 800
3232

33-
Write-Host "🚀 Starting AgentChatBus on $Host:$Port..." -ForegroundColor Green
34-
if ($Host -eq "0.0.0.0") {
33+
Write-Host "🚀 Starting AgentChatBus on ${ListenHost}:${Port}..." -ForegroundColor Green
34+
if ($ListenHost -eq "0.0.0.0") {
3535
Write-Host "⚠️ WARNING: Binding to 0.0.0.0 exposes the API to all network interfaces!" -ForegroundColor Red
3636
Write-Host " This may allow unauthorized access from other machines on your network." -ForegroundColor Red
37-
Write-Host " For local-only access, use -Host 127.0.0.1" -ForegroundColor Red
37+
Write-Host " For local-only access, use -ListenHost 127.0.0.1" -ForegroundColor Red
3838
}
39-
$env:AGENTCHATBUS_HOST = $Host
39+
$env:AGENTCHATBUS_HOST = $ListenHost
4040
$env:AGENTCHATBUS_PORT = $Port
4141
.venv\Scripts\python -m src.main

src/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@
5050
THREAD_TIMEOUT_ENABLED = THREAD_TIMEOUT_MINUTES > 0
5151
# How often the timeout sweep runs (seconds)
5252
THREAD_TIMEOUT_SWEEP_INTERVAL = int(os.getenv("AGENTCHATBUS_TIMEOUT_SWEEP_INTERVAL", "60"))
53+
# Expose per-thread resources in MCP server (default: false for cleaner MCP client UI)
54+
EXPOSE_THREAD_RESOURCES = os.getenv("AGENTCHATBUS_EXPOSE_THREAD_RESOURCES", "false").lower() in {"1", "true", "yes"}
5355

5456
def get_config_dict():
5557
return {
5658
"HOST": HOST,
5759
"PORT": PORT,
5860
"AGENT_HEARTBEAT_TIMEOUT": AGENT_HEARTBEAT_TIMEOUT,
5961
"MSG_WAIT_TIMEOUT": MSG_WAIT_TIMEOUT,
62+
"EXPOSE_THREAD_RESOURCES": EXPOSE_THREAD_RESOURCES,
6063
}
6164

6265
def save_config_dict(new_data: dict):

0 commit comments

Comments
 (0)