* fix: resolve tuple unpacking error in search_tools when using server manager
Fixes#138 - ValueError: not enough values to unpack (expected 3, got 1)
**Problem:**
When using MCPAgent with use_server_manager=True, users encountered a tuple
unpacking error in search_tools.py. The issue occurred because:
1. ToolSearchEngine.search_tools() sometimes returned a string (when no results)
and sometimes returned a list of tuples (when results found)
2. SearchToolsTool._arun() expected search_tools() to return a list of tuples
to pass to format_search_results()
3. When search_tools() returned a string, format_search_results() tried to
iterate over the string characters, causing the unpacking error
**Solution:**
- Modified ToolSearchEngine.search_tools() to consistently return formatted
strings by calling a new _format_search_results() method
- Added _format_search_results() method to ToolSearchEngine class
- Updated SearchToolsTool._arun() to return the already-formatted results
directly instead of calling format_search_results() again
- Updated CLAUDE.md to include virtual environment activation instructions
**Testing:**
- Successfully reproduced the original error
- Verified the fix resolves the issue
- All unit tests pass (113/113)
- Applied code formatting and linting
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* test: add comprehensive test suite for issue #138 tuple unpacking bug
- test_tool_search_engine_consistent_return_type_with_results: ensures search_tools
returns string when results are found (not list of tuples as in the bug)
- test_tool_search_engine_consistent_return_type_no_results: ensures search_tools
returns string when no results found
- test_tool_search_engine_not_indexed_scenario: tests the 'still preparing' scenario
- test_search_tools_tool_arun_with_string_result: tests SearchToolsTool._arun()
correctly handles string results from search_tools
- test_search_tools_tool_integration_scenario: integration test simulating the
exact scenario from issue #138 that was causing the tuple unpacking error
- test_format_search_results_method_exists: validates the new _format_search_results method
- test_server_manager_active_server_marking: tests active server marking functionality
- test_search_tools_input_validation: validates ToolSearchInput model
These tests ensure the tuple unpacking bug (ValueError: not enough values to unpack
expected 3, got 1) will not regress in the future and verify the fix works correctly.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: resolve logger mock issues in search_tools tests
Added @patch decorators to mock the logger in tests that call _format_search_results
to avoid TypeError with logging level comparisons during testing.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Update documentation to use session-based API instead of deprecated client methods
- Replace all references to non-existent client.connect_all() with client.create_all_sessions()
- Replace all references to non-existent client.disconnect_all() with client.close_all_sessions()
- Replace all references to client.list_tools() with session.list_tools()
- Replace all references to client.call_tool() with session.call_tool()
- Update API documentation to reflect actual MCPClient implementation
- Fix code examples to use proper session-based architecture
- Ensure all documentation matches the real codebase API
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Improve docs
* remove unused
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Add support for langfuse and laminar observaility layers
* Example env file
* fix: improve observability transparency and documentation
- Add debug logging for package import failures and missing API keys
- Fix documentation to correctly state LANGFUSE_HOST is supported
- Centralize dotenv loading to avoid multiple calls
Co-authored-by: Pietro Zullo <pietrozullo@users.noreply.github.com>
* Ruff fix
---------
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Pietro Zullo <pietrozullo@users.noreply.github.com>