* fix(python): expose client capabilities to MCP servers
Add list_roots_callback support to Python connectors to properly
advertise the roots capability during MCP initialization handshake.
Previously, the Python library was not exposing any client capabilities
because the list_roots_callback was not being passed to ClientSession.
This fix ensures the roots capability is always advertised, bringing
the Python library in line with the TypeScript implementation.
Changes:
- Add roots and list_roots_callback params to BaseConnector
- Add get_roots() and set_roots() methods for managing roots
- Pass list_roots_callback to ClientSession in all connectors
- Export Root type from connectors module
- Update unit tests to expect list_roots_callback parameter
Closes MCP-1063
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(python): add roots and list_roots_callback params to connectors
- Add roots and list_roots_callback parameters to StdioConnector,
HttpConnector, and SandboxConnector constructors
- Add comprehensive unit tests for client capabilities exposure
- Tests verify roots capability, get_roots(), set_roots(), and
that all callbacks are correctly passed to ClientSession
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: fix import sorting and update API documentation
- Fix import sorting in test_client_capabilities.py (ruff)
- Regenerate API documentation for updated connector classes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(python): add list_roots() method to server Context
Allow MCP servers to request the list of roots from connected clients
via ctx.list_roots(). This follows the same pattern as ctx.sample()
and ctx.elicit() for server-to-client requests.
* feat(python): add roots params to MCPClient and config
- Add roots and list_roots_callback parameters to MCPClient.__init__,
from_dict(), and from_config_file() methods
- Update create_connector_from_config() to pass roots params to all
connector types (Stdio, HTTP, Sandbox)
- Allows clients to configure roots at the MCPClient level and have
them propagate to all sessions
* test(python): add get_client_roots tool to primitive server
Add a tool that demonstrates the roots capability by requesting and
returning the list of roots from the connected client. Used for
integration testing of the roots feature.
* test(python): add integration tests for roots capability
Add comprehensive integration tests for the roots feature:
- test_roots_capability: Verify server can request/receive roots
- test_roots_empty_by_default: Verify empty roots when not provided
- test_roots_with_custom_callback: Verify custom callback precedence
- test_set_roots_updates_server_view: Verify dynamic root updates
* test(python): update unit tests for roots parameters
Update mock assertions in test_client.py to expect the new roots
and list_roots_callback parameters in create_connector_from_config
calls.
* ci(python): add roots to primitive tests and README badge
- Add roots to CI workflow primitive test matrix
- Add roots to PR comment report primitives list
- Add Roots badge to README Primitives row
* feat(docs): enhance MCP client and server documentation for roots feature
- Added `roots` and `list_roots_callback` parameters to MCP client initialization documentation.
- Updated `create_connector_from_config` documentation to include new parameters.
- Introduced `list_roots` method documentation in server context, detailing its usage and return values.
- Improved overall clarity and completeness of API reference for better developer guidance.
* feat(python): add get_client_roots tool to context example
- Introduced a new tool, `get_client_roots`, to the context example, demonstrating how to retrieve and display the list of roots exposed by the client.
- Updated documentation to include the new tool and its functionality, enhancing the example's coverage of context features.
* feat(docs): add roots documentation for client and server
- Introduced new documentation for the `roots` feature, detailing how clients can expose file system roots to MCP servers and how servers can access these roots.
- Added examples for configuring roots in the MCP client and using the `list_roots()` method in the server context.
- Enhanced overall clarity and usability of the documentation to support developers in implementing the roots functionality.
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
* chore: add example server pretty print JSON RPC for transparency
* updated telemetry module
* chore: agent side tel - langchain adapter - client tel
* server side tel:
* update API reference
* python transports and primitive reports are publishes only if not skipped
* remove wrongly generate files
* properly typed middleware
* remove examples
* feat(docs): add middleware and session management documentation
- Introduced new documentation for middleware, detailing hooks, minimal examples, and best practices for integrating middleware in MCP servers.
- Added a session management guide explaining session ID handling, usage patterns, and examples for managing per-client state in MCP servers.
- Updated to include links to the new middleware and session management pages.
* generate docs
* remove few events
* adapter tel
* adapter tel
* api ref docs update
* google adapter fix
* fix version
* fix event naming
* server example is streamable and echo tool fix
* removed initialize middleware hook, initialize requests are not passed thorugh normal handlers
* api ref
* beta on middleware
* removed useless anyio and aiohttp dependency
* version matrix in unit tests
* change test names
* fix weird import from langchain
* new deps
* bump fastembed minimal
* bump uvicorn, remove unused config for pytest
* add pre commit to dev deps
* remove transitive deps starlette and uvicorn
* test fix
* feat: add verify parameter to MCPClient and connectors
- Introduced a new optional `verify` parameter in `MCPClient`, `HttpConnector`, and configuration functions to control SSL certificate verification.
- Updated relevant methods to utilize the `verify` parameter, ensuring consistent handling of SSL verification across the client and connectors.
- Enhanced the SSE and Streamable HTTP connection managers to accept a custom HTTPX client factory for improved flexibility in connection handling.
* fix: linting and docs
* fix: http connector test
* Update docs/python/api-reference/mcp_use_client_config.mdx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
* fix: docs
---------
Signed-off-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
Co-authored-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* 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>
* Auth 1.0
* Defualt to DCR
* Fix client list server names
* Fix oauth problems with no oauth servers, enhance documentation and comments
* Add OAuth metadata provider and specific fixes
- Remove auth field to reduce API verbosity
- Add "auth" support for MCPClient's config
- Add "oauth_provider" key to MCPClient's config to provide metadata
- Fix no OAuth servers' errors
* Relocate authentication doc
* Fix ruff formatting as usual
* Fix http connectors tests with oauth support
* Fix test_config unit tests
* Final fix for tests
* Add integration for auth
- Add auth server for testing
- Add test for complete auth flow with mock on OAuth callback
- Add test for custom client auth
- Add test for bearer auth token
* Add further test and update README
- Add OAuth metadata provider (no discovery)
- Update README with new auth badge
* Format fixes
* Remove redefined exception
* Add auth test on GH action
* Update docs with correct example
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
* Update mcp_use/auth/oauth.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
* Add custom callback port feature
- Add customizable port for callback
- Remove dynamic port
- Fix bug of registration before checking port
* Add GitHub MCP support
* Update docs
* chore: highlight hack
* chore: change wording in docs
* Add authlib on project dependencies
* Remove useless example
* Fix formatting as usual
---------
Signed-off-by: Vincenzo Reina <vincenzoreinaa05@gmail.com>
Signed-off-by: Pietro Zullo <62951181+pietrozullo@users.noreply.github.com>
Co-authored-by: renvins <vincenzoreinaa05@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* 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
* Extend HTTP connector to support newer streamable http transport
* Fix timeout since they should be timedelta objects
* Refactor http connector to use streamable http by default
This will fallback to SSE if there are any issues with the test
ping send.
* Added transport integration tests
* Fail fast removed
* add fastmcp deps
* system install
* Fixed tests
* Remove python 3.12 from tests
---------
Co-authored-by: pietrozullo <pietro.zullo@gmail.com>
* Add connector hooks to resources and propts
* Adapter implementation for resources and tools, treated them as tools
* Move unpacking responsibility to adapters
* Update unittests
* Separate unit and integration
* Fix initialization logic
* Fixed tests with capability check
* Removed tool reference from session