fix(claude): MCP tools silently excluded from API requests#42
Merged
Conversation
Change truthiness check in _convert_mcp_tools_to_claude so that tool_filter=[] (the default when no workflow tools are defined) is treated as "no filter" rather than "filter to nothing". Fixes #37 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
_execute_with_parse_recovery treated MCP tool_use responses (e.g. filesystem__read_file) as failed structured-output extraction and entered a futile parse-recovery cycle instead of returning the response to the agentic loop for tool execution. Add _has_mcp_tool_use() helper and early-return checks in both the initial response path and the recovery loop so non-emit_output tool_use blocks pass through to the agentic loop. Fixes #38 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused imports (Mock, patch), unused variable (original_agentic_loop), fix import sorting, and use specific ProviderError instead of bare Exception in pytest.raises. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes two coupled bugs that completely prevented MCP tools from working with the Claude provider:
Claude provider: empty tool_filter silently excludes all MCP tools #37 — Empty
tool_filterexcludes all MCP tools:_convert_mcp_tools_to_claudeusedtool_filter is not Noneto check for filtering, but the default code path passestool_filter=[](notNone). Since[] is not NoneisTrue, every MCP tool was silently dropped. Fixed by changing to a truthiness check (if tool_filter).Claude provider: _execute_with_parse_recovery blocks MCP tool calls in agentic loop #38 —
_execute_with_parse_recoveryblocks MCP tool calls: Even with Claude provider: empty tool_filter silently excludes all MCP tools #37 fixed, agents with output schemas couldn't use MCP tools. When Claude responded with atool_useblock for an MCP tool (e.g.,filesystem__read_file),_execute_with_parse_recoverydidn't recognize it — onlyemit_outputwas treated as valid — so it entered a futile parse recovery loop and crashed. Fixed by adding a_has_mcp_tool_use()helper that detects non-emit_outputtool_use blocks and returns the response immediately to the agentic loop for execution.Before
After
{"content": "test file contents for issue 37 repro"}Test plan
_convert_mcp_tools_to_claudefilter behavior (7 tests)_has_mcp_tool_usehelper (5 tests)_execute_with_parse_recoveryMCP passthrough (3 tests)WorkflowEngine→AgentExecutor→ClaudeProviderpipeline (4 tests)/tmp/test.txtsuccessfullyFixes #37
Fixes #38
🤖 Generated with Claude Code