Commit Graph

13 Commits

Author SHA1 Message Date
Arya Soni 3c564e285c Bug: Deprecation Version Mismatch (#613) 2025-12-03 14:56:13 +01:00
Pietro Zullo 18f51eddb8 Feat: python/restructure (#318)
* move: session

* move: client

* move:config

* move: exceptions

* move: connectors -> client.connectors

* move: task_managers -> client.task_managers

* move: observability -> agents.observability

* move: middleware -> client.middleware

* move: managers -> agents.managers

* move: auth -> client.auth

* move: adapters -> agents.adapters

* test: bc test

* test: bc test

* chore: remove relative imports

* fix tests

* chore: update docs

* chore: deprecation warnings

* chore: fix dangerous non absolute import

* fix: remove legacy imports

* telemetry
2025-10-17 20:09:19 +02:00
Vincenzo Reina 822b0b72fc feat: Middleware (#269)
* Middlware first commit
* Add context to middleware
- Add context to middleware with mcp types
- Update logging middleware with new implementation
- Add hooks for every type of action
* Update example and metrics
* Adapt tests to middleware
* Fix metrics and example
* Update docs and new add_middleware function
* Fix metrics property
* Fix on add_middleware function
* Fix formatting
* chore: nicer example
* chore: remove global exports for middleware
* chore: middleware blog

---------

Signed-off-by: Vincenzo Reina <vincenzoreinaa05@gmail.com>
Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
2025-10-07 11:37:08 +02:00
Pietro Zullo 2a165e7379 feat: notification & logging (#223)
* Add message handler function

* Notification test

* feat: logging callback

* Separate logging tests

* Documentation

* Remove duplicate

* rename notidfication test

* Discovery - client reacts to tools,resources,prompts update notifications

* integration test

* unit tests

* Fix, remove asyncio task creation, if we do not cache the tools it is not necessary to refresh. I wonder if it caching them tools (etc) is any important for somebody

* Fix type names in the docs
2025-08-10 10:27:20 -07:00
Vincenzo Reina e0face5986 feat: Improve error handling (#215)
* Add error helper function

* Update error formatting for adapters

* Add custom args for error and add formatted in tools

* Add docs in error formatting and improve observability

* Fix and add more properties on adapters

* Fix on folder name, conflict with utils file

* Final fix for the utils problem

* Try to sort imports in correct order

* Add line at end of the error formatting file

* Fix with imports with ruff

* Fix also ruff formatting error
2025-08-07 12:50:14 -07:00
Pietro Zullo 1736e31388 Feat: elicitation (#175)
* Elicitation Client Implementation

* Elicitation test

* Elicitation Documentation

* Docs elictiation fn params

* Bump fastmcp

* Add elicitation to constructors of client

* fix tests
2025-07-17 23:59:38 -07:00
Pietro Zullo 7250b77c5b feat: Sampling (#170)
* Removed unused _setup_client

* Implement sampling in client and connectors

* Tests

* Nicer names in action

* Update previous tests

* Docstrings

* Fixed naming and created other primitives tests

* Supported features table

* docs
2025-07-12 15:00:34 -07:00
Pietro Zullo e6295ab1f3 fix: Renamed client to client session, fixed bug (#160)
* Renamed client to client session, fixed bug

* Fixed resource access typing
2025-07-06 17:53:26 -07:00
Luigi Pederzani 5e7ab23b89 Fix: search tools tuple unpacking error (#138) (#142)
* 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>
2025-06-21 23:03:04 -07:00
Pietro Zullo 8a32d3c23c fix: pre commit run all files (#135)
* Set line lenght to 120

* Run pre commit all files
2025-06-18 10:12:58 +02:00
Pietro Zullo cb7c2bcbd6 Feat/telemetry (#124)
* Telemetry base

* Fix debug level

* Singleton pattern in utils for metric server

* Added public identifier to transports

* Update telemetry

* Add telemetry to mcpagent

* telemetry docs
2025-06-13 21:12:34 +02:00
Pietro Zullo f13f9a8930 feat: remove client options for easier usage (#105)
* Remove clientoptions in favor of simpler, is sandbox argument and sandbox argument optional

* Tests and examples

* Remove tool from session

* Nice error message

* Update docs

* Update readme
2025-06-03 10:03:18 +02:00
Luigi Pederzani e8e958c565 Feature: Support for running MCP servers in a sandboxed cloud environment using E2B (#97)
* Add E2B optional dependency for sandboxed mcp servers

* Add types for sandbox options

* Add util to check if stdio server config

* Ignore B017

* Add sandbox connector to run MCP servers on e2b sandbox

* Add client options to set sandbox and sandbox options + use sandbox connector

* Add sandbox connector test + fix

* Add sandboxed stdio server example

* Add docs

* Set logger info

* Set debug in example

* Add install new optional dep
2025-05-19 14:50:38 +02:00