Fix workload discovery broken after toolhive removed tool_type field#172
Conversation
Code ReviewSummaryGood fix addressing the breaking change from toolhive API. The approach of removing tool_type filtering and switching to the remote field is correct. Issues Found1. Inconsistent null handling (Critical) In ingestion.py:1450-1451 and 1509-1510, the expression w.remote or False means remote=None is treated as container workload. But in the Workload model (core.py:40-43), the field description says Remote indicates whether this is a remote workload (true) or a container workload (false) - no mention of None. Risk: If toolhive returns remote=None, workloads are silently categorized as containers. This could mask data quality issues. Fix: Be explicit about None handling (w.remote is False or w.remote is None) or add validation/logging when remote=None. 2. Overly broad filtering removed (Moderate) All three files removed filtering for non-MCP workloads. Now all running workloads are processed, regardless of type. Question: Does toolhive return non-MCP workloads? If yes, removing this filter means mcp-optimizer will try to process them. Recommendation: Verify toolhive only returns MCP workloads, or add a comment explaining why filtering is no longer needed. 3. Missing field validation (Low) The tool_type field still exists in the Workload model (core.py:51-54) marked as Optional. Consider: Is this field deprecated? Should we log a warning if it is unexpectedly present? Positive Points
Minor Suggestions
|
6f99cfe to
09baa9b
Compare
|
@claude check if your feedback was addressed. For 2. The answer is that ToolHive does not return workloads that are not MCP servers |
|
Claude finished @aponcedeleonch's task —— View job Verification Complete ✓I've reviewed the current code to check if the previous feedback was addressed. Here's my assessment:
AssessmentIssue #1: Inconsistent null handling - ✅ RESOLVED The code now explicitly handles if workload.remote is None:
logger.error(
"Workload has remote=None, skipping (data quality issue)",
workload_name=workload.name,
...
)
continueThis is much better! Instead of silently treating
The previous Issue #2: Overly broad filtering - ✅ RESOLVED Confirmed by user that ToolHive does not return non-MCP workloads, so removing the tool_type filter is safe. The code correctly processes all workloads returned by ToolHive. Issue #3: Missing field validation - The SummaryAll critical and moderate issues have been properly addressed:
The PR is in good shape. The fix properly addresses the breaking change from toolhive while adding better data validation. Great work! 🎉 Job Run | Branch: |
Fixes #167 After toolhive PR #2932 removed the tool_type field from the Workload API response, mcp-optimizer could not discover any MCP servers. All workloads were filtered out because the tool_type field was null. Changes: - Remove tool_type filtering from workload discovery in ingestion.py (Docker and K8s modes) - Remove tool_type filtering from toolhive_client.py and k8s_client.py - Update logging to use remote field instead of tool_type for workload classification - Update workload counting logic to use remote boolean field The remote field now indicates workload type: remote=true for remote workloads, remote=false or null for container workloads. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
09baa9b to
26fa730
Compare
Fixes #167
After toolhive PR #2932 removed the tool_type field from the Workload API response, mcp-optimizer could not discover any MCP servers. All workloads were filtered out because the tool_type field was null.
Changes
The remote field now indicates workload type: remote=true for remote workloads, remote=false or null for container workloads.
Testing
🤖 Generated with Claude Code