-
Notifications
You must be signed in to change notification settings - Fork 40
Add HTTP Transport Support with Host/Port Configuration and Dockerfile #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shemreader
wants to merge
5
commits into
acryldata:main
Choose a base branch
from
shemreader:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fa1bb65
Add HTTP transport support with host/port options and Dockerfile
fa0804b
Update package name for fork PyPI publishing
shemreader cf958e2
Add sniffio dependency to fix ModuleNotFoundError with uvx
shemreader 23ba000
Revert pyproject.toml changes
shemreader d813bb6
Fix: Pass host and port options to SSE transport and warn for stdio
shemreader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| FROM python:3.10-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install uv | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv | ||
|
|
||
| # Copy dependency files and source code (needed for setuptools-scm version generation) | ||
| COPY pyproject.toml uv.lock README.md ./ | ||
| COPY src/ ./src/ | ||
|
|
||
| # Install dependencies and build the package | ||
| RUN uv sync --frozen --no-dev | ||
|
|
||
| # Expose port | ||
| EXPOSE 8000 | ||
|
|
||
| # Set environment variables | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| # Run the MCP server with HTTP transport | ||
| CMD ["uv", "run", "mcp-server-datahub", "--transport", "http", "--host", "0.0.0.0", "--port", "8000"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,74 @@ | ||
| import logging | ||
|
|
||
| import click | ||
| from datahub.ingestion.graph.config import ClientMode | ||
| from datahub.sdk.main_client import DataHubClient | ||
| from datahub.telemetry import telemetry | ||
| from fastmcp.server.middleware.logging import LoggingMiddleware | ||
| from typing_extensions import Literal | ||
|
|
||
| from mcp_server_datahub._telemetry import TelemetryMiddleware | ||
| from mcp_server_datahub._version import __version__ | ||
| from mcp_server_datahub.mcp_server import mcp, register_all_tools, with_datahub_client | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
|
|
||
| # Register tools with OSS-compatible descriptions | ||
| register_all_tools(is_oss=True) | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.version_option(version=__version__) | ||
| @click.option( | ||
| "--transport", | ||
| type=click.Choice(["stdio", "sse", "http"]), | ||
| default="stdio", | ||
| ) | ||
| @click.option( | ||
| "--debug", | ||
| is_flag=True, | ||
| default=False, | ||
| ) | ||
| @telemetry.with_telemetry( | ||
| capture_kwargs=["transport"], | ||
| ) | ||
| def main(transport: Literal["stdio", "sse", "http"], debug: bool) -> None: | ||
| client = DataHubClient.from_env( | ||
| client_mode=ClientMode.SDK, | ||
| datahub_component=f"mcp-server-datahub/{__version__}", | ||
| ) | ||
|
|
||
| if debug: | ||
| # logging.getLogger("datahub").setLevel(logging.DEBUG) | ||
| mcp.add_middleware(LoggingMiddleware(include_payloads=True)) | ||
| mcp.add_middleware(TelemetryMiddleware()) | ||
|
|
||
| with with_datahub_client(client): | ||
| if transport == "http": | ||
| mcp.run(transport=transport, show_banner=False, stateless_http=True) | ||
| else: | ||
| mcp.run(transport=transport, show_banner=False) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| import logging | ||
|
|
||
| import click | ||
| from datahub.ingestion.graph.config import ClientMode | ||
| from datahub.sdk.main_client import DataHubClient | ||
| from datahub.telemetry import telemetry | ||
| from fastmcp.server.middleware.logging import LoggingMiddleware | ||
| from typing_extensions import Literal | ||
|
|
||
| from mcp_server_datahub._telemetry import TelemetryMiddleware | ||
| from mcp_server_datahub._version import __version__ | ||
| from mcp_server_datahub.mcp_server import mcp, register_all_tools, with_datahub_client | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
|
|
||
| # Register tools with OSS-compatible descriptions | ||
| register_all_tools(is_oss=True) | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.version_option(version=__version__) | ||
| @click.option( | ||
| "--transport", | ||
| type=click.Choice(["stdio", "sse", "http"]), | ||
| default="stdio", | ||
| ) | ||
| @click.option( | ||
| "--debug", | ||
| is_flag=True, | ||
| default=False, | ||
| ) | ||
| @click.option( | ||
| "--host", | ||
| type=str, | ||
| default="0.0.0.0", | ||
| help="Host to bind the server to (default: 0.0.0.0 for all interfaces)", | ||
| ) | ||
| @click.option( | ||
| "--port", | ||
| type=int, | ||
| default=8000, | ||
| help="Port to bind the server to (default: 8000)", | ||
| ) | ||
| @telemetry.with_telemetry( | ||
| capture_kwargs=["transport"], | ||
| ) | ||
| def main( | ||
| transport: Literal["stdio", "sse", "http"], debug: bool, host: str, port: int | ||
| ) -> None: | ||
| client = DataHubClient.from_env( | ||
| client_mode=ClientMode.SDK, | ||
| datahub_component=f"mcp-server-datahub/{__version__}", | ||
| ) | ||
|
|
||
| if debug: | ||
| # logging.getLogger("datahub").setLevel(logging.DEBUG) | ||
| mcp.add_middleware(LoggingMiddleware(include_payloads=True)) | ||
| mcp.add_middleware(TelemetryMiddleware()) | ||
|
|
||
| with with_datahub_client(client): | ||
| if transport == "http": | ||
| mcp.run( | ||
| transport=transport, | ||
| show_banner=False, | ||
| stateless_http=True, | ||
| host=host, | ||
| port=port, | ||
| ) | ||
| else: | ||
| mcp.run(transport=transport, show_banner=False) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.