Refactor transport type handling and remove URL normalization#214
Refactor transport type handling and remove URL normalization#214aponcedeleonch merged 1 commit intomainfrom
Conversation
PR Review: Refactor transport type handling and remove URL normalizationSummaryThis PR successfully refactors transport type handling by renaming ✅ Positives
🐛 Issues Found1. Duplicate code in
|
|
@claude check if your comments were addressed |
|
Claude finished @aponcedeleonch's task —— View job Review Comments Status CheckI've reviewed the current state of the code to see if the issues from my previous review were addressed. Issue #1: Duplicate code in
|
- Renamed determine_proxy_mode to determine_transport_type with runtime_mode parameter - Docker mode: checks proxy_mode field (how proxy connects to container) - K8s mode: checks transport_type field (direct connection to pod) - Both modes fall back to URL detection if primary field not set - Added runtime_mode parameter to MCPServerClient constructor (defaults to "docker") - Updated call sites in ingestion.py and server.py to pass runtime_mode - Added explanatory comments about runtime-specific transport determination - Renamed ToolHiveProxyMode to ToolHiveTransportMode for consistency - Updated function name from url_to_toolhive_proxy_mode to url_to_toolhive_transport_mode - Added 7 new tests for k8s mode and cross-mode validation - All 300 tests passing with proper runtime mode separation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
66a87eb to
2afec38
Compare
|
@claude check my most recent changes. Look carefully for breaking changes |
|
Claude finished @aponcedeleonch's task —— View job Breaking Changes ReviewI've reviewed the most recent changes in this PR with a focus on identifying breaking changes. ✅ GOOD NEWS: No Breaking Changes for External UsersThe changes in this PR are internal refactorings that don't break the public API:
|
| Change Type | Old Name | New Name | Impact |
|---|---|---|---|
| Class rename | ToolHiveProxyMode |
ToolHiveTransportMode |
Internal only - no external usage found |
| Function rename | url_to_toolhive_proxy_mode() |
url_to_toolhive_transport_mode() |
Internal only - not imported externally |
| Private method removed | _map_transport_type() |
determine_transport_type() |
Private method - moved to module level |
Why this is OK:
- All imports within the codebase have been updated
- No external code in
examples/uses these - No public API documented in README uses these
🔍 Detailed Review
1. MCPServerClient Constructor Change ✅ SAFE
# OLD (origin/main)
def __init__(self, workload: Workload, timeout: float):
# NEW (this PR)
def __init__(self, workload: Workload, timeout: float, runtime_mode: str = "docker"):Why it's safe:
- New parameter has a default value (
"docker") - All internal call sites updated (ingestion.py:980, server.py:549)
- Tests updated to pass the parameter
- External code can continue calling without the parameter
2. Enum Rename ⚠️ INTERNAL BREAKING
# OLD: ToolHiveProxyMode
# NEW: ToolHiveTransportModeAnalysis:
- Checked all Python files with
grep -r "ToolHiveProxyMode" - Only found in
toolhive/enums.pyandmcp_client.py - No external usage found
- All internal imports updated correctly
3. Function Rename ⚠️ INTERNAL BREAKING
# OLD: url_to_toolhive_proxy_mode()
# NEW: url_to_toolhive_transport_mode()Analysis:
- Checked all files with
grep -r "url_to_toolhive_proxy_mode" - No matches found - function not called anywhere now
- Only used internally within
determine_transport_type()
4. Removed Method ⚠️ INTERNAL BREAKING
# REMOVED: IngestionService._map_transport_type()
# REPLACED WITH: determine_transport_type() (module-level function)Why it's safe:
- Method was private (underscore prefix)
- Replaced with better module-level function
- All call sites updated (ingestion.py:677)
✅ Summary
For external users: ✨ NO BREAKING CHANGES
- The MCP Optimizer server API is unchanged
- Example code will continue to work
- CLI interface unchanged
For internal code: Changes are intentional refactoring
- All internal imports have been updated
- Tests updated and passing
- Better separation of concerns with
determine_transport_type()as a standalone function
Recommendation: 👍 Safe to merge - This is a clean refactoring with no external API breakage.
Closes: #210
Summary
🤖 Generated with Claude Code