-
Notifications
You must be signed in to change notification settings - Fork 0
Skip registry ingestion in k8s mode and add Kubernetes deployment examples #98
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
Conversation
Signed-off-by: nigel brown <nigel@stacklok.com>
Signed-off-by: nigel brown <nigel@stacklok.com>
Signed-off-by: nigel brown <nigel@stacklok.com>
For streamable-http: Strips URL fragments (#github → removed) Converts /sse paths to /mcp Ensures path ends with /mcp if missing For SSE: preserves original URL (fragments needed for container identification) Signed-off-by: nigel brown <nigel@stacklok.com>
Automated update of ToolHive API models from OpenAPI specification. Co-authored-by: aponcedeleonch <7890853+aponcedeleonch@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…81) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
PR Review - Skip registry ingestion in k8s mode and enable OpenTelemetrySummaryOverall solid PR addressing two distinct issues. The code quality is good, with clear separation of concerns. A few minor improvements recommended. Key Changes Reviewed
Issues Found1. URL Normalization Logic - Redundancy (mcp_client.py:68-73) elif not path.endswith("/mcp"):
if path.endswith("/"):
path = path + "mcp"
else:
path = path + "/mcp"Can be simplified to: elif not path.endswith("/mcp"):
path = path.rstrip("/") + "/mcp"2. Shell Script - Missing Quotes (create-github-secrets.sh:49) 3. Inconsistent f-string Usage (mcp_client.py:145, 154, 178, 185) # Current
logger.debug(f"Determining proxy mode from proxy_mode field: {proxy_mode_lower}", ...)
# Better
logger.debug("Determining proxy mode from proxy_mode field", proxy_mode=proxy_mode_lower, ...)4. Potential Breaking Change - URL Modification
Positive Observations
Performance & Security
Recommendations
Estimated Fix Time: 10-15 minutes |
ec3eacd to
a6c87eb
Compare
- Updated normalization logic to check if /mcp already exists in path before adding it - Updated test expectations to account for URL normalization behavior - Fixes failing tests where URLs like /mcp/test-server were getting /mcp appended
aponcedeleonch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only major comment I have is the _normalize_url logic. I believe we should not mangle with the URL coming from ToolHive
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these updates coming from a rebase? not sure why they're showing in the diff..
| if proxy_mode == ToolHiveProxyMode.STREAMABLE: | ||
| # Strip fragments for streamable-http | ||
| # (fragments not supported by streamable-http client) | ||
| parsed = urlparse(url) | ||
|
|
||
| # Fix path: streamable-http uses /mcp endpoint, not /sse | ||
| path = parsed.path | ||
| if path.endswith("/sse"): | ||
| path = path.replace("/sse", "/mcp") | ||
| elif not path.endswith("/mcp"): | ||
| # Only add /mcp if the path doesn't already contain /mcp | ||
| # This prevents double-adding /mcp to URLs like /mcp/test-server | ||
| if "/mcp" not in path: | ||
| # If path doesn't end with /mcp or /sse, and doesn't contain /mcp, | ||
| # ensure it ends with /mcp | ||
| if path.endswith("/"): | ||
| path = path + "mcp" | ||
| else: | ||
| path = path + "/mcp" | ||
|
|
||
| # Reconstruct URL without fragment and with corrected path | ||
| normalized_tuple = ( | ||
| parsed.scheme, | ||
| parsed.netloc, | ||
| path, | ||
| parsed.params, | ||
| parsed.query, | ||
| "", # Empty fragment | ||
| ) | ||
| normalized = str(urlunparse(normalized_tuple)) | ||
| if normalized != url: | ||
| logger.debug( | ||
| "Normalized URL for streamable-http", | ||
| original_url=url, | ||
| normalized_url=normalized, | ||
| workload=self.workload.name, | ||
| ) | ||
| return normalized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure we need this logic? I remember we had problems in the past when trying to enforce the URL to follow a pattern. I did a quick search on the specification and there's no mention that the URL of streamable-http transport need to finish in /mcp. I think we need to trust ToolHive and that it gives us the correct URL. If it doesn't then probably it's a bug in ToolHive. Maybe instead of trying to assume and enforce the URL we should log a warning that it doesn't follow the convention of ending in /mcp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If toolhive gives us the right URLs, then this is a NOP. I'm inclined to leave it in there for now. It was needed to get it working with github. I'll raise a toolhive issue to consider it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created stacklok/toolhive#2890
| @@ -1,6 +1,6 @@ | |||
| # generated by datamodel-codegen: | |||
| # filename: http://127.0.0.1:8080/api/openapi.json | |||
| # timestamp: 2025-11-02T00:37:46+00:00 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these changes in toolhive/api_models also rebase leftovers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to ask you about that. There's no actual change, just timestamps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They come from #92
Summary
This PR addresses issue #89 by skipping registry ingestion when running in k8s mode, and adds comprehensive Kubernetes deployment examples.
Changes
Issue #89: Skip registry ingestion in k8s mode
ingest_registry()to skip registry ingestion whenruntime_mode == "k8s"Additional Changes
Related Issues