Skip to content

feat: Added transport and endpoint options to API server command#430

Open
Jaid wants to merge 1 commit intodeedy5:mainfrom
Jaid:mcp-server-options
Open

feat: Added transport and endpoint options to API server command#430
Jaid wants to merge 1 commit intodeedy5:mainfrom
Jaid:mcp-server-options

Conversation

@Jaid
Copy link

@Jaid Jaid commented Mar 15, 2026

This adds two new options to make the MCP integration of the API server more modern and useful. Comes with some unit tests and mentions in the readme.

Now --transport can either be 'sse' (default, current behavior) or 'http' (Streamable HTTP). The SSE protocol is deprecated and no longer a part of the latest MCP server spec, but I still kept SSE as default to be as undisruptive toward your existing users as possible.

--endpoint can overwrite the default path the MCP server middleware listens to (which is '/mcp' for Streamable HTTP and '/sse' for SSE).

Signed-off-by: Jaid <6216144+Jaid@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 15, 2026 06:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable MCP transport and endpoint selection to the ddgs api command so the API server can expose either the legacy SSE transport (default) or Streamable HTTP, with an overridable MCP endpoint path.

Changes:

  • Introduces ddgs.mcp_transport helpers/constants for MCP transport + endpoint normalization.
  • Extends ddgs api CLI command with --transport and --endpoint, and wires these into uvicorn app creation.
  • Refactors ddgs.api_server initialization to support mounting Streamable HTTP and updates README + CLI tests accordingly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/cli_test.py Adds unit tests for transport/endpoint normalization and verifies CLI passes normalized values through to uvicorn/app creation.
ddgs/mcp_transport.py New module defining supported transports, defaults, and normalization + error types.
ddgs/cli.py Adds --transport/--endpoint options, normalizes values, and selects import-string vs app-factory uvicorn startup.
ddgs/api_server/__init__.py Adds transport-aware mounting (SSE vs Streamable HTTP) and a factory for creating configured FastAPI apps.
README.md Documents new CLI flags and the available MCP endpoints for both transports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +638 to +642
normalized_transport = normalize_mcp_transport(transport)
normalized_endpoint = normalize_mcp_endpoint(endpoint, normalized_transport)
uses_default_api_server_config = _uses_default_api_server_config(normalized_transport, normalized_endpoint)
expanded_proxy = (_expand_proxy_tb_alias(proxy) or proxy) if proxy else None

Comment on lines +38 to +40
api_module = importlib.reload(importlib.import_module("ddgs.api_server.api"))
mcp_module = importlib.reload(importlib.import_module("ddgs.api_server.mcp"))

expanded_proxy = (_expand_proxy_tb_alias(proxy) or proxy) if proxy else None

if reload and not uses_default_api_server_config:
click.echo("Error: --reload is only supported with the default SSE endpoint /sse", err=True)


def _uses_default_api_server_config(transport: str, endpoint: str) -> bool:
"""Return whether the requested API server config matches the default import path."""
@Jaid
Copy link
Author

Jaid commented Mar 15, 2026

Oh, sorry for the clanker spam. I wasn’t aware of such feature and opted out of it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants