feat: Added transport and endpoint options to API server command#430
Open
Jaid wants to merge 1 commit intodeedy5:mainfrom
Open
feat: Added transport and endpoint options to API server command#430Jaid wants to merge 1 commit intodeedy5:mainfrom
Jaid wants to merge 1 commit intodeedy5:mainfrom
Conversation
Signed-off-by: Jaid <6216144+Jaid@users.noreply.github.com>
There was a problem hiding this comment.
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_transporthelpers/constants for MCP transport + endpoint normalization. - Extends
ddgs apiCLI command with--transportand--endpoint, and wires these into uvicorn app creation. - Refactors
ddgs.api_serverinitialization 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.""" |
Author
|
Oh, sorry for the clanker spam. I wasn’t aware of such feature and opted out of it now. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
--transportcan 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.--endpointcan overwrite the default path the MCP server middleware listens to (which is'/mcp'for Streamable HTTP and'/sse'for SSE).