Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions airbyte/mcp/http_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

Environment variables:

- `MCP_SERVER_URL`: Public base URL (for OIDC redirect callbacks)
- `MCP_SERVER_URL`: Public base URL. Used for OIDC redirect callbacks and to
derive the MCP endpoint mount path (serves at `/` when the URL has a path
prefix, otherwise defaults to `/mcp`).
- `OIDC_CONFIG_URL`: Keycloak OIDC discovery URL (enables auth with all three OIDC vars)
- `OIDC_CLIENT_ID`: OIDC client identifier
- `OIDC_CLIENT_SECRET`: OIDC client secret
Expand All @@ -16,8 +18,15 @@
from __future__ import annotations

import logging
import os
from urllib.parse import urlparse

from airbyte.mcp.server import DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT, app
from airbyte.mcp.server import (
DEFAULT_HTTP_HOST,
DEFAULT_HTTP_PORT,
MCP_SERVER_URL_ENV,
app,
)
Comment thread
aaronsteers marked this conversation as resolved.


logger = logging.getLogger(__name__)
Expand All @@ -26,16 +35,28 @@
def main() -> None:
"""Start the Airbyte MCP server with HTTP transport."""
logging.basicConfig(level=logging.INFO)

# When deployed behind a path-stripping LB (MCP_SERVER_URL has a path
# component like /cloud-mcp), serve the MCP endpoint at root so the
# public URL is just the base path. Otherwise keep the FastMCP default.
server_url = os.getenv(
MCP_SERVER_URL_ENV,
f"http://localhost:{DEFAULT_HTTP_PORT}",
)
mcp_path = "/" if urlparse(server_url).path.strip("/") else "/mcp"

logger.info(
"Starting Airbyte MCP HTTP server on %s:%d",
"Starting Airbyte MCP HTTP server on %s:%d (mcp_path=%r)",
DEFAULT_HTTP_HOST,
DEFAULT_HTTP_PORT,
mcp_path,
)

app.run(
transport="streamable-http",
host=DEFAULT_HTTP_HOST,
port=DEFAULT_HTTP_PORT,
path=mcp_path,
stateless_http=True,
)

Expand Down
Loading