Add MCP_HOST and MCP_PORT environment variables for MCP server configuration (Vibe Kanban) (#2063)
* Done. Here's a summary of the fix: ## Summary **Issue #1937** is legitimate - Windows users cannot connect MCP tools when `HOST=0.0.0.0` because Windows doesn't allow client connections to that address. **Fix applied** in `crates/server/src/bin/mcp_task_server.rs`: Added `MCP_HOST` and `MCP_PORT` environment variables that override `HOST` and `BACKEND_PORT`/`PORT` for MCP client connections. **Priority order:** - Host: `VIBE_BACKEND_URL` > `MCP_HOST` > `HOST` > `127.0.0.1` - Port: `VIBE_BACKEND_URL` > `MCP_PORT` > `BACKEND_PORT` > `PORT` > port file **Usage for Windows users with LAN access:** ```bash HOST=0.0.0.0 MCP_HOST=127.0.0.1 pnpm run dev ``` The change is minimal (4 lines modified) and backwards compatible - existing setups without `MCP_HOST`/`MCP_PORT` work exactly as before. * Done. I've added `MCP_HOST` and `MCP_PORT` to the Environment Variables table in the README with descriptions explaining their purpose and the Windows use case.
This commit is contained in:
committed by
GitHub
parent
9106c8223a
commit
a2ccc49ca4
@@ -108,6 +108,8 @@ The following environment variables can be configured at build time or runtime:
|
||||
| `BACKEND_PORT` | Runtime | `0` (auto-assign) | Backend server port (dev mode only, overrides PORT+1) |
|
||||
| `FRONTEND_PORT` | Runtime | `3000` | Frontend dev server port (dev mode only, overrides PORT) |
|
||||
| `HOST` | Runtime | `127.0.0.1` | Backend server host |
|
||||
| `MCP_HOST` | Runtime | Value of `HOST` | MCP server connection host (use `127.0.0.1` when `HOST=0.0.0.0` on Windows) |
|
||||
| `MCP_PORT` | Runtime | Value of `BACKEND_PORT` | MCP server connection port |
|
||||
| `DISABLE_WORKTREE_ORPHAN_CLEANUP` | Runtime | Not set | Disable git worktree cleanup (for debugging) |
|
||||
|
||||
**Build-time variables** must be set when running `pnpm run build`. **Runtime variables** are read when the application starts.
|
||||
|
||||
@@ -35,10 +35,15 @@ fn main() -> anyhow::Result<()> {
|
||||
tracing::info!("[MCP] Using backend URL from VIBE_BACKEND_URL: {}", url);
|
||||
url
|
||||
} else {
|
||||
let host = std::env::var("HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||
let host = std::env::var("MCP_HOST")
|
||||
.or_else(|_| std::env::var("HOST"))
|
||||
.unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||
|
||||
// Get port from environment variables or fall back to port file
|
||||
let port = match std::env::var("BACKEND_PORT").or_else(|_| std::env::var("PORT")) {
|
||||
let port = match std::env::var("MCP_PORT")
|
||||
.or_else(|_| std::env::var("BACKEND_PORT"))
|
||||
.or_else(|_| std::env::var("PORT"))
|
||||
{
|
||||
Ok(port_str) => {
|
||||
tracing::info!("[MCP] Using port from environment: {}", port_str);
|
||||
port_str.parse::<u16>().map_err(|e| {
|
||||
|
||||
Reference in New Issue
Block a user