mcp-use 1.3.13__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mcp-use might be problematic. Click here for more details.

Files changed (179) hide show
  1. {mcp_use-1.3.13 → mcp_use-1.4.0}/PKG-INFO +18 -18
  2. {mcp_use-1.3.13 → mcp_use-1.4.0}/README.md +15 -15
  3. mcp_use-1.4.0/examples/anthropic_integration_example.py +114 -0
  4. mcp_use-1.4.0/examples/google_integration_example.py +138 -0
  5. mcp_use-1.4.0/examples/openai_integration_example.py +92 -0
  6. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/stream_example.py +14 -5
  7. mcp_use-1.4.0/mcp_use/agents/adapters/__init__.py +17 -0
  8. mcp_use-1.4.0/mcp_use/agents/adapters/anthropic.py +93 -0
  9. mcp_use-1.4.0/mcp_use/agents/adapters/base.py +316 -0
  10. mcp_use-1.4.0/mcp_use/agents/adapters/google.py +103 -0
  11. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/adapters/langchain_adapter.py +6 -22
  12. mcp_use-1.4.0/mcp_use/agents/adapters/openai.py +111 -0
  13. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/mcpagent.py +371 -472
  14. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/prompts/system_prompt_builder.py +1 -1
  15. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/remote.py +1 -1
  16. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/auth/oauth_callback.py +3 -2
  17. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/logging.py +1 -1
  18. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/telemetry/utils.py +1 -1
  19. {mcp_use-1.3.13 → mcp_use-1.4.0}/pyproject.toml +3 -3
  20. mcp_use-1.4.0/tests/integration/agent/test_agent_run.py +47 -0
  21. mcp_use-1.4.0/tests/integration/agent/test_agent_stream.py +84 -0
  22. mcp_use-1.4.0/tests/integration/agent/test_agent_structured_output.py +63 -0
  23. mcp_use-1.4.0/tests/integration/agent/test_server_manager.py +118 -0
  24. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_agent.py +20 -19
  25. mcp_use-1.3.13/mcp_use/agents/adapters/__init__.py +0 -10
  26. mcp_use-1.3.13/mcp_use/agents/adapters/base.py +0 -193
  27. mcp_use-1.3.13/mcp_use/cli.py +0 -581
  28. {mcp_use-1.3.13 → mcp_use-1.4.0}/.env.example +0 -0
  29. {mcp_use-1.3.13 → mcp_use-1.4.0}/.gitignore +0 -0
  30. {mcp_use-1.3.13 → mcp_use-1.4.0}/.pre-commit-config.yaml +0 -0
  31. {mcp_use-1.3.13 → mcp_use-1.4.0}/CLAUDE.md +0 -0
  32. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/airbnb_mcp.json +0 -0
  33. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/airbnb_use.py +0 -0
  34. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/blender_use.py +0 -0
  35. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/browser_use.py +0 -0
  36. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/chat_example.py +0 -0
  37. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/direct_tool_call.py +0 -0
  38. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/example_middleware.py +0 -0
  39. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/filesystem_use.py +0 -0
  40. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/http_example.py +0 -0
  41. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/limited_memory_chat.py +0 -0
  42. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/mcp_everything.py +0 -0
  43. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/multi_server_example.py +0 -0
  44. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/sandbox_everything.py +0 -0
  45. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/simple_oauth_example.py +0 -0
  46. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/simple_server_manager_use.py +0 -0
  47. {mcp_use-1.3.13 → mcp_use-1.4.0}/examples/structured_output.py +0 -0
  48. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/__init__.py +0 -0
  49. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/adapters/.deprecated +0 -0
  50. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/adapters/__init__.py +0 -0
  51. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/adapters/base.py +0 -0
  52. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/adapters/langchain_adapter.py +0 -0
  53. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/__init__.py +0 -0
  54. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/base.py +0 -0
  55. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/__init__.py +0 -0
  56. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/base.py +0 -0
  57. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/server_manager.py +0 -0
  58. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/__init__.py +0 -0
  59. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/base_tool.py +0 -0
  60. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/connect_server.py +0 -0
  61. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/disconnect_server.py +0 -0
  62. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/get_active_server.py +0 -0
  63. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/list_servers_tool.py +0 -0
  64. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/managers/tools/search_tools.py +0 -0
  65. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/observability/__init__.py +0 -0
  66. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/observability/callbacks_manager.py +0 -0
  67. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/observability/laminar.py +0 -0
  68. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/observability/langfuse.py +0 -0
  69. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/agents/prompts/templates.py +0 -0
  70. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/auth/.deprecated +0 -0
  71. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/auth/__init__.py +0 -0
  72. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/auth/bearer.py +0 -0
  73. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/auth/oauth.py +0 -0
  74. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/auth/oauth_callback.py +0 -0
  75. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/__init__.py +0 -0
  76. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/auth/__init__.py +0 -0
  77. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/auth/bearer.py +0 -0
  78. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/auth/oauth.py +0 -0
  79. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/client.py +0 -0
  80. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/config.py +0 -0
  81. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/__init__.py +0 -0
  82. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/base.py +0 -0
  83. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/http.py +0 -0
  84. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/sandbox.py +0 -0
  85. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/stdio.py +0 -0
  86. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/utils.py +0 -0
  87. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/connectors/websocket.py +0 -0
  88. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/exceptions.py +0 -0
  89. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/middleware/__init__.py +0 -0
  90. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/middleware/logging.py +0 -0
  91. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/middleware/metrics.py +0 -0
  92. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/middleware/middleware.py +0 -0
  93. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/session.py +0 -0
  94. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/task_managers/__init__.py +0 -0
  95. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/task_managers/base.py +0 -0
  96. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/task_managers/sse.py +0 -0
  97. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/task_managers/stdio.py +0 -0
  98. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/task_managers/streamable_http.py +0 -0
  99. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client/task_managers/websocket.py +0 -0
  100. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/client.py +0 -0
  101. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/config.py +0 -0
  102. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/.deprecated +0 -0
  103. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/__init__.py +0 -0
  104. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/base.py +0 -0
  105. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/http.py +0 -0
  106. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/sandbox.py +0 -0
  107. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/stdio.py +0 -0
  108. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/utils.py +0 -0
  109. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/connectors/websocket.py +0 -0
  110. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/errors/__init__.py +0 -0
  111. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/errors/error_formatting.py +0 -0
  112. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/exceptions.py +0 -0
  113. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/.deprecated +0 -0
  114. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/__init__.py +0 -0
  115. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/base.py +0 -0
  116. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/server_manager.py +0 -0
  117. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/__init__.py +0 -0
  118. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/base_tool.py +0 -0
  119. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/connect_server.py +0 -0
  120. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/disconnect_server.py +0 -0
  121. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/get_active_server.py +0 -0
  122. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/list_servers_tool.py +0 -0
  123. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/managers/tools/search_tools.py +0 -0
  124. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/middleware/.deprecated +0 -0
  125. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/middleware/__init__.py +0 -0
  126. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/middleware/logging.py +0 -0
  127. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/middleware/metrics.py +0 -0
  128. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/middleware/middleware.py +0 -0
  129. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/session.py +0 -0
  130. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/.deprecated +0 -0
  131. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/__init__.py +0 -0
  132. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/base.py +0 -0
  133. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/sse.py +0 -0
  134. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/stdio.py +0 -0
  135. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/streamable_http.py +0 -0
  136. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/task_managers/websocket.py +0 -0
  137. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/telemetry/__init__.py +0 -0
  138. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/telemetry/events.py +0 -0
  139. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/telemetry/telemetry.py +0 -0
  140. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/types/.deprecated +0 -0
  141. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/types/sandbox.py +0 -0
  142. {mcp_use-1.3.13 → mcp_use-1.4.0}/mcp_use/utils.py +0 -0
  143. {mcp_use-1.3.13 → mcp_use-1.4.0}/pytest.ini +0 -0
  144. {mcp_use-1.3.13 → mcp_use-1.4.0}/ruff.toml +0 -0
  145. {mcp_use-1.3.13 → mcp_use-1.4.0}/static/logo-gh.jpg +0 -0
  146. {mcp_use-1.3.13 → mcp_use-1.4.0}/static/logo_black.svg +0 -0
  147. {mcp_use-1.3.13 → mcp_use-1.4.0}/static/logo_white.svg +0 -0
  148. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/conftest.py +0 -0
  149. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/__init__.py +0 -0
  150. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/conftest.py +0 -0
  151. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/others/test_custom_streaming_integration.py +0 -0
  152. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_auth.py +0 -0
  153. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_discovery.py +0 -0
  154. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_elicitation.py +0 -0
  155. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_logging.py +0 -0
  156. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_notifications.py +0 -0
  157. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_prompts.py +0 -0
  158. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_resources.py +0 -0
  159. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_sampling.py +0 -0
  160. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/primitives/test_tools.py +0 -0
  161. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/servers_for_testing/__init__.py +0 -0
  162. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/servers_for_testing/auth_server.py +0 -0
  163. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/servers_for_testing/custom_streaming_server.py +0 -0
  164. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/servers_for_testing/primitive_server.py +0 -0
  165. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/servers_for_testing/simple_server.py +0 -0
  166. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/servers_for_testing/timeout_test_server.py +0 -0
  167. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/transports/test_sse.py +0 -0
  168. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/transports/test_stdio.py +0 -0
  169. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/integration/transports/test_streamable_http.py +0 -0
  170. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/backward_compatibility.py +0 -0
  171. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_client.py +0 -0
  172. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_config.py +0 -0
  173. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_enum_handling.py +0 -0
  174. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_http_connector.py +0 -0
  175. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_sandbox_connector.py +0 -0
  176. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_search_tools_issue_138.py +0 -0
  177. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_session.py +0 -0
  178. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_stdio_connector.py +0 -0
  179. {mcp_use-1.3.13 → mcp_use-1.4.0}/tests/unit/test_websocket_connection_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-use
3
- Version: 1.3.13
3
+ Version: 1.4.0
4
4
  Summary: MCP Library for LLMs
5
5
  Author-email: "mcp-use, Inc." <dev@mcp-use.io>, Pietro Zullo <pietro.zullo@gmail.com>
6
6
  License: MIT
@@ -16,8 +16,8 @@ Requires-Python: >=3.11
16
16
  Requires-Dist: aiohttp>=3.9.0
17
17
  Requires-Dist: authlib>=1.6.3
18
18
  Requires-Dist: jsonschema-pydantic>=0.1.0
19
- Requires-Dist: langchain-core==0.3.79
20
- Requires-Dist: langchain==0.3.27
19
+ Requires-Dist: langchain-core>=1.0.0
20
+ Requires-Dist: langchain>=1.0.0
21
21
  Requires-Dist: mcp>=1.10.0
22
22
  Requires-Dist: posthog>=4.8.0
23
23
  Requires-Dist: pydantic-core==2.33.2
@@ -54,7 +54,7 @@ Description-Content-Type: text/markdown
54
54
  </picture>
55
55
  </div>
56
56
 
57
- <h1 align="center">🚀 MCP-Use for Python</h1>
57
+ <h1 align="center">🚀 mcp-use for Python</h1>
58
58
  <p align="center">
59
59
  <a href="https://github.com/pietrozullo/mcp-use/stargazers" alt="GitHub stars">
60
60
  <img src="https://img.shields.io/github/stars/pietrozullo/mcp-use?style=social" /></a>
@@ -71,15 +71,15 @@ Description-Content-Type: text/markdown
71
71
  </p>
72
72
  </div>
73
73
 
74
- > **📦 Part of the [MCP-Use Monorepo](../../README.md)** - This is the Python implementation. Also available in [TypeScript](../typescript/README.md).
74
+ > **📦 Part of the [mcp-use Monorepo](../../README.md)** - This is the Python implementation. Also available in [TypeScript](../typescript/README.md).
75
75
 
76
- 🌐 **MCP-Use for Python** is the complete way to connect **any LLM to any MCP server** and build custom MCP agents with tool access.
76
+ 🌐 **mcp-use for Python** is the complete way to connect **any LLM to any MCP server** and build custom MCP agents with tool access.
77
77
 
78
78
  💡 Let your Python applications leverage the power of the Model Context Protocol with support for agents, clients, and advanced features.
79
79
 
80
80
  ## 🏗️ What's Included
81
81
 
82
- MCP-Use for Python provides three main capabilities:
82
+ mcp-use for Python provides three main capabilities:
83
83
 
84
84
  - **🤖 MCP Agent** - Build AI agents that can use tools and reason across multiple steps
85
85
  - **🔌 MCP Client** - Connect directly to MCP servers for programmatic tool access
@@ -89,15 +89,15 @@ MCP-Use for Python provides three main capabilities:
89
89
 
90
90
  ## 📖 Quick Links
91
91
 
92
- - **[Main Repository](../../README.md)** - Overview of the entire MCP-Use ecosystem
92
+ - **[Main Repository](../../README.md)** - Overview of the entire mcp-use ecosystem
93
93
  - **[TypeScript Version](../typescript/README.md)** - TypeScript implementation with server framework
94
94
  - **[Documentation](https://docs.mcp-use.com)** - Complete online documentation
95
95
  - **[Examples](./examples/)** - Python code examples
96
96
 
97
97
  | Supports | |
98
98
  | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
99
- | **Primitives** | [![Tools](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-tools&label=Tools&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Resources](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-resources&label=Resources&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Prompts](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-prompts&label=Prompts&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Sampling](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-sampling&label=Sampling&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Elicitation](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-elicitation&label=Elicitation&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Authentication](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-authentication&label=Authentication&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) |
100
- | **Transports** | [![Stdio](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=transport-stdio&label=Stdio&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![SSE](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=transport-sse&label=SSE&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Streamable HTTP](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=transport-streamableHttp&label=Streamable%20HTTP&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) |
99
+ | **Primitives** | [![Tools](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/tools&label=Tools&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Resources](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/resources&label=Resources&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Prompts](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/prompts&label=Prompts&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Sampling](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/sampling&label=Sampling&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Elicitation](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/elicitation&label=Elicitation&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Authentication](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/authentication&label=Authentication&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) |
100
+ | **Transports** | [![Stdio](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-transport/stdio&label=Stdio&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![SSE](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-transport/sse&label=SSE&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Streamable HTTP](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-transport/streamable_http&label=Streamable%20HTTP&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) |
101
101
 
102
102
  ## Features
103
103
 
@@ -260,7 +260,7 @@ For other settings, models, and more, check out the documentation.
260
260
 
261
261
  ## Streaming Agent Output
262
262
 
263
- MCP-Use supports asynchronous streaming of agent output using the `stream` method on `MCPAgent`. This allows you to receive incremental results, tool actions, and intermediate steps as they are generated by the agent, enabling real-time feedback and progress reporting.
263
+ mcp-use supports asynchronous streaming of agent output using the `stream` method on `MCPAgent`. This allows you to receive incremental results, tool actions, and intermediate steps as they are generated by the agent, enabling real-time feedback and progress reporting.
264
264
 
265
265
  ### How to use
266
266
 
@@ -433,7 +433,7 @@ if __name__ == "__main__":
433
433
 
434
434
  ## HTTP Connection Example
435
435
 
436
- MCP-Use supports HTTP connections, allowing you to connect to MCP servers running on specific HTTP ports. This feature is particularly useful for integrating with web-based MCP servers.
436
+ mcp-use supports HTTP connections, allowing you to connect to MCP servers running on specific HTTP ports. This feature is particularly useful for integrating with web-based MCP servers.
437
437
 
438
438
  Here's an example of how to use the HTTP connection feature:
439
439
 
@@ -482,7 +482,7 @@ This example demonstrates how to connect to an MCP server running on a specific
482
482
 
483
483
  # Multi-Server Support
484
484
 
485
- MCP-Use allows configuring and connecting to multiple MCP servers simultaneously using the `MCPClient`. This enables complex workflows that require tools from different servers, such as web browsing combined with file operations or 3D modeling.
485
+ mcp-use allows configuring and connecting to multiple MCP servers simultaneously using the `MCPClient`. This enables complex workflows that require tools from different servers, such as web browsing combined with file operations or 3D modeling.
486
486
 
487
487
  ## Configuration
488
488
 
@@ -564,7 +564,7 @@ if __name__ == "__main__":
564
564
 
565
565
  # Tool Access Control
566
566
 
567
- MCP-Use allows you to restrict which tools are available to the agent, providing better security and control over agent capabilities:
567
+ mcp-use allows you to restrict which tools are available to the agent, providing better security and control over agent capabilities:
568
568
 
569
569
  ```python
570
570
  import asyncio
@@ -597,7 +597,7 @@ if __name__ == "__main__":
597
597
 
598
598
  # Sandboxed Execution
599
599
 
600
- MCP-Use supports running MCP servers in a sandboxed environment using E2B's cloud infrastructure. This allows you to run MCP servers without having to install dependencies locally, making it easier to use tools that might have complex setups or system requirements.
600
+ mcp-use supports running MCP servers in a sandboxed environment using E2B's cloud infrastructure. This allows you to run MCP servers without having to install dependencies locally, making it easier to use tools that might have complex setups or system requirements.
601
601
 
602
602
  ## Installation
603
603
 
@@ -787,7 +787,7 @@ Python agents and clients can connect to TypeScript servers seamlessly - the MCP
787
787
 
788
788
  # Debugging
789
789
 
790
- MCP-Use provides a built-in debug mode that increases log verbosity and helps diagnose issues in your agent implementation.
790
+ mcp-use provides a built-in debug mode that increases log verbosity and helps diagnose issues in your agent implementation.
791
791
 
792
792
  ## Enabling Debug Mode
793
793
 
@@ -913,12 +913,12 @@ MIT
913
913
 
914
914
  # Citation
915
915
 
916
- If you use MCP-Use in your research or project, please cite:
916
+ If you use mcp-use in your research or project, please cite:
917
917
 
918
918
  ```bibtex
919
919
  @software{mcp_use2025,
920
920
  author = {Zullo, Pietro},
921
- title = {MCP-Use: MCP Library for Python},
921
+ title = {mcp-use: MCP Library for Python},
922
922
  year = {2025},
923
923
  publisher = {GitHub},
924
924
  url = {https://github.com/pietrozullo/mcp-use}
@@ -7,7 +7,7 @@
7
7
  </picture>
8
8
  </div>
9
9
 
10
- <h1 align="center">🚀 MCP-Use for Python</h1>
10
+ <h1 align="center">🚀 mcp-use for Python</h1>
11
11
  <p align="center">
12
12
  <a href="https://github.com/pietrozullo/mcp-use/stargazers" alt="GitHub stars">
13
13
  <img src="https://img.shields.io/github/stars/pietrozullo/mcp-use?style=social" /></a>
@@ -24,15 +24,15 @@
24
24
  </p>
25
25
  </div>
26
26
 
27
- > **📦 Part of the [MCP-Use Monorepo](../../README.md)** - This is the Python implementation. Also available in [TypeScript](../typescript/README.md).
27
+ > **📦 Part of the [mcp-use Monorepo](../../README.md)** - This is the Python implementation. Also available in [TypeScript](../typescript/README.md).
28
28
 
29
- 🌐 **MCP-Use for Python** is the complete way to connect **any LLM to any MCP server** and build custom MCP agents with tool access.
29
+ 🌐 **mcp-use for Python** is the complete way to connect **any LLM to any MCP server** and build custom MCP agents with tool access.
30
30
 
31
31
  💡 Let your Python applications leverage the power of the Model Context Protocol with support for agents, clients, and advanced features.
32
32
 
33
33
  ## 🏗️ What's Included
34
34
 
35
- MCP-Use for Python provides three main capabilities:
35
+ mcp-use for Python provides three main capabilities:
36
36
 
37
37
  - **🤖 MCP Agent** - Build AI agents that can use tools and reason across multiple steps
38
38
  - **🔌 MCP Client** - Connect directly to MCP servers for programmatic tool access
@@ -42,15 +42,15 @@ MCP-Use for Python provides three main capabilities:
42
42
 
43
43
  ## 📖 Quick Links
44
44
 
45
- - **[Main Repository](../../README.md)** - Overview of the entire MCP-Use ecosystem
45
+ - **[Main Repository](../../README.md)** - Overview of the entire mcp-use ecosystem
46
46
  - **[TypeScript Version](../typescript/README.md)** - TypeScript implementation with server framework
47
47
  - **[Documentation](https://docs.mcp-use.com)** - Complete online documentation
48
48
  - **[Examples](./examples/)** - Python code examples
49
49
 
50
50
  | Supports | |
51
51
  | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | **Primitives** | [![Tools](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-tools&label=Tools&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Resources](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-resources&label=Resources&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Prompts](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-prompts&label=Prompts&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Sampling](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-sampling&label=Sampling&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Elicitation](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-elicitation&label=Elicitation&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Authentication](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=primitive-authentication&label=Authentication&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) |
53
- | **Transports** | [![Stdio](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=transport-stdio&label=Stdio&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![SSE](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=transport-sse&label=SSE&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [![Streamable HTTP](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/tests.yml?job=transport-streamableHttp&label=Streamable%20HTTP&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) |
52
+ | **Primitives** | [![Tools](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/tools&label=Tools&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Resources](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/resources&label=Resources&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Prompts](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/prompts&label=Prompts&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Sampling](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/sampling&label=Sampling&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Elicitation](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/elicitation&label=Elicitation&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Authentication](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-primitive/authentication&label=Authentication&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) |
53
+ | **Transports** | [![Stdio](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-transport/stdio&label=Stdio&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![SSE](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-transport/sse&label=SSE&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) [![Streamable HTTP](https://img.shields.io/github/actions/workflow/status/pietrozullo/mcp-use/ci.yml?job=python-transport/streamable_http&label=Streamable%20HTTP&style=flat)](https://github.com/pietrozullo/mcp-use/actions/workflows/ci.yml) |
54
54
 
55
55
  ## Features
56
56
 
@@ -213,7 +213,7 @@ For other settings, models, and more, check out the documentation.
213
213
 
214
214
  ## Streaming Agent Output
215
215
 
216
- MCP-Use supports asynchronous streaming of agent output using the `stream` method on `MCPAgent`. This allows you to receive incremental results, tool actions, and intermediate steps as they are generated by the agent, enabling real-time feedback and progress reporting.
216
+ mcp-use supports asynchronous streaming of agent output using the `stream` method on `MCPAgent`. This allows you to receive incremental results, tool actions, and intermediate steps as they are generated by the agent, enabling real-time feedback and progress reporting.
217
217
 
218
218
  ### How to use
219
219
 
@@ -386,7 +386,7 @@ if __name__ == "__main__":
386
386
 
387
387
  ## HTTP Connection Example
388
388
 
389
- MCP-Use supports HTTP connections, allowing you to connect to MCP servers running on specific HTTP ports. This feature is particularly useful for integrating with web-based MCP servers.
389
+ mcp-use supports HTTP connections, allowing you to connect to MCP servers running on specific HTTP ports. This feature is particularly useful for integrating with web-based MCP servers.
390
390
 
391
391
  Here's an example of how to use the HTTP connection feature:
392
392
 
@@ -435,7 +435,7 @@ This example demonstrates how to connect to an MCP server running on a specific
435
435
 
436
436
  # Multi-Server Support
437
437
 
438
- MCP-Use allows configuring and connecting to multiple MCP servers simultaneously using the `MCPClient`. This enables complex workflows that require tools from different servers, such as web browsing combined with file operations or 3D modeling.
438
+ mcp-use allows configuring and connecting to multiple MCP servers simultaneously using the `MCPClient`. This enables complex workflows that require tools from different servers, such as web browsing combined with file operations or 3D modeling.
439
439
 
440
440
  ## Configuration
441
441
 
@@ -517,7 +517,7 @@ if __name__ == "__main__":
517
517
 
518
518
  # Tool Access Control
519
519
 
520
- MCP-Use allows you to restrict which tools are available to the agent, providing better security and control over agent capabilities:
520
+ mcp-use allows you to restrict which tools are available to the agent, providing better security and control over agent capabilities:
521
521
 
522
522
  ```python
523
523
  import asyncio
@@ -550,7 +550,7 @@ if __name__ == "__main__":
550
550
 
551
551
  # Sandboxed Execution
552
552
 
553
- MCP-Use supports running MCP servers in a sandboxed environment using E2B's cloud infrastructure. This allows you to run MCP servers without having to install dependencies locally, making it easier to use tools that might have complex setups or system requirements.
553
+ mcp-use supports running MCP servers in a sandboxed environment using E2B's cloud infrastructure. This allows you to run MCP servers without having to install dependencies locally, making it easier to use tools that might have complex setups or system requirements.
554
554
 
555
555
  ## Installation
556
556
 
@@ -740,7 +740,7 @@ Python agents and clients can connect to TypeScript servers seamlessly - the MCP
740
740
 
741
741
  # Debugging
742
742
 
743
- MCP-Use provides a built-in debug mode that increases log verbosity and helps diagnose issues in your agent implementation.
743
+ mcp-use provides a built-in debug mode that increases log verbosity and helps diagnose issues in your agent implementation.
744
744
 
745
745
  ## Enabling Debug Mode
746
746
 
@@ -866,12 +866,12 @@ MIT
866
866
 
867
867
  # Citation
868
868
 
869
- If you use MCP-Use in your research or project, please cite:
869
+ If you use mcp-use in your research or project, please cite:
870
870
 
871
871
  ```bibtex
872
872
  @software{mcp_use2025,
873
873
  author = {Zullo, Pietro},
874
- title = {MCP-Use: MCP Library for Python},
874
+ title = {mcp-use: MCP Library for Python},
875
875
  year = {2025},
876
876
  publisher = {GitHub},
877
877
  url = {https://github.com/pietrozullo/mcp-use}
@@ -0,0 +1,114 @@
1
+ import asyncio
2
+
3
+ from anthropic import Anthropic
4
+ from dotenv import load_dotenv
5
+
6
+ from mcp_use import MCPClient
7
+ from mcp_use.agents.adapters import AnthropicMCPAdapter
8
+
9
+ # This example demonstrates how to use our integration
10
+ # adapters to use MCP tools and convert to the right format.
11
+ # In particularly, this example uses the AnthropicMCPAdapter.
12
+
13
+ load_dotenv()
14
+
15
+
16
+ async def main():
17
+ config = {
18
+ "mcpServers": {
19
+ "airbnb": {"command": "npx", "args": ["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"]},
20
+ }
21
+ }
22
+
23
+ try:
24
+ client = MCPClient(config=config)
25
+
26
+ # Creates the adapter for Anthropic's format
27
+ adapter = AnthropicMCPAdapter()
28
+
29
+ # Convert tools from active connectors to the Anthropic's format
30
+ await adapter.create_all(client)
31
+
32
+ # List concatenation (if you loaded all tools)
33
+ anthropic_tools = adapter.tools + adapter.resources + adapter.prompts
34
+
35
+ # If you don't want to create all tools, you can call single functions
36
+ # await adapter.create_tools(client)
37
+ # await adapter.create_resources(client)
38
+ # await adapter.create_prompts(client)
39
+
40
+ # Use tools with Anthropic's SDK (not agent in this case)
41
+ anthropic = Anthropic()
42
+
43
+ # Initial request
44
+ messages = [{"role": "user", "content": "Please tell me the cheapest hotel for two people in Trapani."}]
45
+ response = anthropic.messages.create(
46
+ model="claude-sonnet-4-5", tools=anthropic_tools, max_tokens=1024, messages=messages
47
+ )
48
+ messages.append({"role": response.role, "content": response.content})
49
+
50
+ print("Claude wants to use tools:", response.stop_reason == "tool_use")
51
+ print("Number of tool calls:", len([c for c in response.content if c.type == "tool_use"]))
52
+
53
+ if response.stop_reason == "tool_use":
54
+ tool_results = []
55
+ for c in response.content:
56
+ if c.type != "tool_use":
57
+ continue
58
+
59
+ tool_name = c.name
60
+ arguments = c.input
61
+
62
+ # Use the adapter's map to get the correct executor
63
+ executor = adapter.tool_executors.get(tool_name)
64
+
65
+ if not executor:
66
+ print(f"Error: Unknown tool '{tool_name}' requested by model.")
67
+ content = f"Error: Tool '{tool_name}' not found."
68
+ else:
69
+ try:
70
+ # Execute the tool using the retrieved function
71
+ print(f"Executing tool: {tool_name}({arguments})")
72
+ tool_result = await executor(**arguments)
73
+
74
+ # Use the adapter's universal parser
75
+ content = adapter.parse_result(tool_result)
76
+ except Exception as e:
77
+ print(f"An unexpected error occurred while executing tool {tool_name}: {e}")
78
+ content = f"Error executing tool: {e}"
79
+
80
+ # Append the result for this specific tool call
81
+ tool_results.append(
82
+ {
83
+ "type": "tool_result",
84
+ "tool_use_id": c.id,
85
+ "content": content,
86
+ }
87
+ )
88
+
89
+ if tool_results:
90
+ messages.append(
91
+ {
92
+ "role": "user",
93
+ "content": tool_results,
94
+ }
95
+ )
96
+ # Get final response
97
+ final_response = anthropic.messages.create(
98
+ model="claude-sonnet-4-5", max_tokens=1024, tools=anthropic_tools, messages=messages
99
+ )
100
+ print("\n--- Final response from the model ---")
101
+ print(final_response.content[0].text)
102
+ else:
103
+ final_response = response
104
+ print("\n--- Final response from the model ---")
105
+ if final_response.content:
106
+ print(final_response.content[0].text)
107
+
108
+ except Exception as e:
109
+ print(f"Error: {e}")
110
+ raise e
111
+
112
+
113
+ if __name__ == "__main__":
114
+ asyncio.run(main())
@@ -0,0 +1,138 @@
1
+ import asyncio
2
+
3
+ from dotenv import load_dotenv
4
+ from google import genai
5
+ from google.genai import types
6
+
7
+ from mcp_use import MCPClient
8
+ from mcp_use.agents.adapters import GoogleMCPAdapter
9
+
10
+ # This example demonstrates how to use our integration
11
+ # adapters to use MCP tools and convert to the right format.
12
+ # In particularly, this example uses the GoogleMCPAdapter.
13
+
14
+ load_dotenv()
15
+
16
+
17
+ async def main():
18
+ config = {
19
+ "mcpServers": {"playwright": {"command": "npx", "args": ["@playwright/mcp@latest"], "env": {"DISPLAY": ":1"}}}
20
+ }
21
+
22
+ try:
23
+ client = MCPClient(config=config)
24
+
25
+ # Creates the adapter for Google's format
26
+ adapter = GoogleMCPAdapter()
27
+
28
+ # Convert tools from active connectors to the Google's format
29
+ await adapter.create_all(client)
30
+
31
+ # List concatenation (if you loaded all tools)
32
+ all_tools = adapter.tools + adapter.resources + adapter.prompts
33
+ google_tools = [types.Tool(function_declarations=all_tools)]
34
+
35
+ # If you don't want to create all tools, you can call single functions
36
+ # await adapter.create_tools(client)
37
+ # await adapter.create_resources(client)
38
+ # await adapter.create_prompts(client)
39
+
40
+ # Use tools with Google's SDK (not agent in this case)
41
+ gemini = genai.Client()
42
+
43
+ messages = [
44
+ types.Content(
45
+ role="user",
46
+ parts=[
47
+ types.Part.from_text(
48
+ text="Please search on the internet using browser: 'What time is it in Favignana now!'"
49
+ )
50
+ ],
51
+ )
52
+ ]
53
+ # Initial request
54
+ response = gemini.models.generate_content(
55
+ model="gemini-flash-lite-latest", contents=messages, config=types.GenerateContentConfig(tools=google_tools)
56
+ )
57
+
58
+ if not response.function_calls:
59
+ print("The model didn't do any tool call!")
60
+ return
61
+
62
+ # Do multiple tool calls if needed
63
+ while response.function_calls:
64
+ for function_call in response.function_calls:
65
+ function_call_content = response.candidates[0].content
66
+
67
+ messages.append(function_call_content)
68
+
69
+ tool_name = function_call.name
70
+ arguments = function_call.args
71
+
72
+ # Use the adapter's map to get the correct executor
73
+ executor = adapter.tool_executors.get(tool_name)
74
+
75
+ if not executor:
76
+ print(f"Error: Unknown tool '{tool_name}' requested by model.")
77
+ function_response_content = types.Content(
78
+ role="tool",
79
+ parts=[
80
+ types.Part.from_function_response(
81
+ name=tool_name,
82
+ response={"error": "No executor found for the tool requested"},
83
+ )
84
+ ],
85
+ )
86
+ else:
87
+ try:
88
+ # Execute the tool using the retrieved function
89
+ print(f"Executing tool: {tool_name}({arguments})")
90
+ tool_result = await executor(**arguments)
91
+
92
+ # Use the adapter's universal parser
93
+ content = adapter.parse_result(tool_result)
94
+ function_response = {"result": content}
95
+
96
+ # Build function response message
97
+ function_response_part = types.Part.from_function_response(
98
+ name=tool_name,
99
+ response=function_response,
100
+ )
101
+ function_response_content = types.Content(role="tool", parts=[function_response_part])
102
+ except Exception as e:
103
+ print(f"An unexpected error occurred while executing tool {tool_name}: {e}")
104
+ function_response_content = types.Content(
105
+ role="tool",
106
+ parts=[
107
+ types.Part.from_function_response(
108
+ name=tool_name,
109
+ response={"error": str(e)},
110
+ )
111
+ ],
112
+ )
113
+ # Append the tool's result to the conversation history
114
+ messages.append(function_response_content)
115
+ # Send the tool's result back to the model to get the next response
116
+
117
+ response = gemini.models.generate_content(
118
+ model="gemini-flash-lite-latest",
119
+ contents=messages,
120
+ config=types.GenerateContentConfig(tools=google_tools),
121
+ )
122
+
123
+ # Get final response, the loop has finished
124
+ print("\n--- Final response from the model ---")
125
+ if response.text:
126
+ print(response.text)
127
+ else:
128
+ print("The model did not return a final text response.")
129
+ print(response)
130
+
131
+ gemini.close()
132
+ except Exception as e:
133
+ print(f"Error: {e}")
134
+ raise e
135
+
136
+
137
+ if __name__ == "__main__":
138
+ asyncio.run(main())
@@ -0,0 +1,92 @@
1
+ import asyncio
2
+
3
+ from dotenv import load_dotenv
4
+ from openai import OpenAI
5
+
6
+ from mcp_use import MCPClient
7
+ from mcp_use.agents.adapters import OpenAIMCPAdapter
8
+
9
+ # This example demonstrates how to use our integration
10
+ # adapters to use MCP tools and convert to the right format.
11
+ # In particularly, this example uses the OpenAIMCPAdapter.
12
+
13
+ load_dotenv()
14
+
15
+
16
+ async def main():
17
+ config = {
18
+ "mcpServers": {
19
+ "airbnb": {"command": "npx", "args": ["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"]},
20
+ }
21
+ }
22
+
23
+ try:
24
+ client = MCPClient(config=config)
25
+
26
+ # Creates the adapter for OpenAI's format
27
+ adapter = OpenAIMCPAdapter()
28
+
29
+ # Convert tools from active connectors to the OpenAI's format
30
+ # this will populates the list of tools, resources and prompts
31
+ await adapter.create_all(client)
32
+
33
+ # If you don't want to create all tools, you can call single functions
34
+ # await adapter.create_tools(client)
35
+ # await adapter.create_resources(client)
36
+ # await adapter.create_prompts(client)
37
+
38
+ # If you decided to create all tools (list concatenation)
39
+ openai_tools = adapter.tools + adapter.resources + adapter.prompts
40
+
41
+ # Use tools with OpenAI's SDK (not agent in this case)
42
+ openai = OpenAI()
43
+ messages = [{"role": "user", "content": "Please tell me the cheapest hotel for two people in Trapani."}]
44
+ response = openai.chat.completions.create(model="gpt-4o", messages=messages, tools=openai_tools)
45
+
46
+ response_message = response.choices[0].message
47
+ messages.append(response_message)
48
+ if not response_message.tool_calls:
49
+ print("No tool call requested by the model")
50
+ print(response_message.content)
51
+ return
52
+
53
+ # Handle the tool calls (Tools, Resources, Prompts...)
54
+ for tool_call in response_message.tool_calls:
55
+ import json
56
+
57
+ function_name = tool_call.function.name
58
+ arguments = json.loads(tool_call.function.arguments)
59
+
60
+ # Use the adapter's map to get the correct executor
61
+ executor = adapter.tool_executors.get(function_name)
62
+
63
+ if not executor:
64
+ print(f"Error: Unknown tool '{function_name}' requested by model.")
65
+ content = f"Error: Tool '{function_name}' not found."
66
+ else:
67
+ try:
68
+ # Execute the tool using the retrieved function
69
+ print(f"Executing tool: {function_name}({arguments})")
70
+ tool_result = await executor(**arguments)
71
+
72
+ # Use the adapter's universal parser
73
+ content = adapter.parse_result(tool_result)
74
+ except Exception as e:
75
+ print(f"An unexpected error occurred while executing tool {function_name}: {e}")
76
+ content = f"Error executing tool: {e}"
77
+
78
+ # Append the result for this specific tool call
79
+ messages.append({"tool_call_id": tool_call.id, "role": "tool", "name": function_name, "content": content})
80
+
81
+ # Send the tool result back to the model
82
+ second_response = openai.chat.completions.create(model="gpt-4o", messages=messages, tools=openai_tools)
83
+ final_message = second_response.choices[0].message
84
+ print("\n--- Final response from the model ---")
85
+ print(final_message.content)
86
+
87
+ except Exception as e:
88
+ print(f"Error: {e}")
89
+
90
+
91
+ if __name__ == "__main__":
92
+ asyncio.run(main())