mcp-use 1.6.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.
Files changed (326) hide show
  1. mcp_use-1.6.0/.env.example +61 -0
  2. mcp_use-1.6.0/.gitignore +128 -0
  3. mcp_use-1.6.0/.pre-commit-config.yaml +28 -0
  4. mcp_use-1.6.0/CLAUDE.md +254 -0
  5. mcp_use-1.6.0/PKG-INFO +928 -0
  6. mcp_use-1.6.0/README.md +881 -0
  7. mcp_use-1.6.0/examples/airbnb_mcp.json +8 -0
  8. mcp_use-1.6.0/examples/airbnb_use.py +46 -0
  9. mcp_use-1.6.0/examples/anthropic_integration_example.py +114 -0
  10. mcp_use-1.6.0/examples/blender_use.py +53 -0
  11. mcp_use-1.6.0/examples/browser_use.py +48 -0
  12. mcp_use-1.6.0/examples/chat_example.py +79 -0
  13. mcp_use-1.6.0/examples/client/oauth_dynamic_client_registration.py +46 -0
  14. mcp_use-1.6.0/examples/client/oauth_preregistered.py +71 -0
  15. mcp_use-1.6.0/examples/code_mode_example.py +55 -0
  16. mcp_use-1.6.0/examples/direct_tool_call.py +59 -0
  17. mcp_use-1.6.0/examples/example_middleware.py +102 -0
  18. mcp_use-1.6.0/examples/filesystem_use.py +58 -0
  19. mcp_use-1.6.0/examples/google_integration_example.py +138 -0
  20. mcp_use-1.6.0/examples/http_example.py +53 -0
  21. mcp_use-1.6.0/examples/langchain_integration_example.py +78 -0
  22. mcp_use-1.6.0/examples/limited_memory_chat.py +89 -0
  23. mcp_use-1.6.0/examples/mcp_everything.py +39 -0
  24. mcp_use-1.6.0/examples/multi_server_example.py +66 -0
  25. mcp_use-1.6.0/examples/multimodal_input_example.py +35 -0
  26. mcp_use-1.6.0/examples/openai_integration_example.py +92 -0
  27. mcp_use-1.6.0/examples/sandbox_everything.py +66 -0
  28. mcp_use-1.6.0/examples/server/context_example.py +301 -0
  29. mcp_use-1.6.0/examples/server/middleware_example.py +267 -0
  30. mcp_use-1.6.0/examples/server/server_example.py +84 -0
  31. mcp_use-1.6.0/examples/simple_oauth_example.py +40 -0
  32. mcp_use-1.6.0/examples/simple_server_manager_use.py +113 -0
  33. mcp_use-1.6.0/examples/stream_example.py +60 -0
  34. mcp_use-1.6.0/examples/structured_output.py +78 -0
  35. mcp_use-1.6.0/mcp_use/__init__.py +52 -0
  36. mcp_use-1.6.0/mcp_use/adapters/.deprecated +0 -0
  37. mcp_use-1.6.0/mcp_use/adapters/__init__.py +21 -0
  38. mcp_use-1.6.0/mcp_use/adapters/base.py +17 -0
  39. mcp_use-1.6.0/mcp_use/adapters/langchain_adapter.py +18 -0
  40. mcp_use-1.6.0/mcp_use/agents/__init__.py +14 -0
  41. mcp_use-1.6.0/mcp_use/agents/adapters/__init__.py +17 -0
  42. mcp_use-1.6.0/mcp_use/agents/adapters/anthropic.py +95 -0
  43. mcp_use-1.6.0/mcp_use/agents/adapters/base.py +343 -0
  44. mcp_use-1.6.0/mcp_use/agents/adapters/google.py +105 -0
  45. mcp_use-1.6.0/mcp_use/agents/adapters/langchain_adapter.py +215 -0
  46. mcp_use-1.6.0/mcp_use/agents/adapters/openai.py +113 -0
  47. mcp_use-1.6.0/mcp_use/agents/base.py +61 -0
  48. mcp_use-1.6.0/mcp_use/agents/display.py +562 -0
  49. mcp_use-1.6.0/mcp_use/agents/managers/__init__.py +19 -0
  50. mcp_use-1.6.0/mcp_use/agents/managers/base.py +36 -0
  51. mcp_use-1.6.0/mcp_use/agents/managers/server_manager.py +137 -0
  52. mcp_use-1.6.0/mcp_use/agents/managers/tools/__init__.py +15 -0
  53. mcp_use-1.6.0/mcp_use/agents/managers/tools/base_tool.py +19 -0
  54. mcp_use-1.6.0/mcp_use/agents/managers/tools/connect_server.py +77 -0
  55. mcp_use-1.6.0/mcp_use/agents/managers/tools/disconnect_server.py +43 -0
  56. mcp_use-1.6.0/mcp_use/agents/managers/tools/get_active_server.py +29 -0
  57. mcp_use-1.6.0/mcp_use/agents/managers/tools/list_servers_tool.py +53 -0
  58. mcp_use-1.6.0/mcp_use/agents/managers/tools/search_tools.py +328 -0
  59. mcp_use-1.6.0/mcp_use/agents/mcpagent.py +1112 -0
  60. mcp_use-1.6.0/mcp_use/agents/middleware/__init__.py +5 -0
  61. mcp_use-1.6.0/mcp_use/agents/middleware/tool_error_middleware.py +71 -0
  62. mcp_use-1.6.0/mcp_use/agents/observability/__init__.py +9 -0
  63. mcp_use-1.6.0/mcp_use/agents/observability/callbacks_manager.py +162 -0
  64. mcp_use-1.6.0/mcp_use/agents/observability/laminar.py +42 -0
  65. mcp_use-1.6.0/mcp_use/agents/observability/langfuse.py +59 -0
  66. mcp_use-1.6.0/mcp_use/agents/prompts/system_prompt_builder.py +103 -0
  67. mcp_use-1.6.0/mcp_use/agents/prompts/templates.py +32 -0
  68. mcp_use-1.6.0/mcp_use/agents/remote.py +366 -0
  69. mcp_use-1.6.0/mcp_use/auth/.deprecated +0 -0
  70. mcp_use-1.6.0/mcp_use/auth/__init__.py +21 -0
  71. mcp_use-1.6.0/mcp_use/auth/bearer.py +16 -0
  72. mcp_use-1.6.0/mcp_use/auth/oauth.py +16 -0
  73. mcp_use-1.6.0/mcp_use/auth/oauth_callback.py +23 -0
  74. mcp_use-1.6.0/mcp_use/client/__init__.py +1 -0
  75. mcp_use-1.6.0/mcp_use/client/auth/__init__.py +6 -0
  76. mcp_use-1.6.0/mcp_use/client/auth/bearer.py +23 -0
  77. mcp_use-1.6.0/mcp_use/client/auth/oauth.py +805 -0
  78. mcp_use-1.6.0/mcp_use/client/auth/oauth_callback.py +212 -0
  79. mcp_use-1.6.0/mcp_use/client/client.py +604 -0
  80. mcp_use-1.6.0/mcp_use/client/code_executor.py +352 -0
  81. mcp_use-1.6.0/mcp_use/client/config.py +142 -0
  82. mcp_use-1.6.0/mcp_use/client/connectors/__init__.py +25 -0
  83. mcp_use-1.6.0/mcp_use/client/connectors/base.py +555 -0
  84. mcp_use-1.6.0/mcp_use/client/connectors/code_mode.py +176 -0
  85. mcp_use-1.6.0/mcp_use/client/connectors/http.py +349 -0
  86. mcp_use-1.6.0/mcp_use/client/connectors/sandbox.py +343 -0
  87. mcp_use-1.6.0/mcp_use/client/connectors/stdio.py +182 -0
  88. mcp_use-1.6.0/mcp_use/client/connectors/utils.py +13 -0
  89. mcp_use-1.6.0/mcp_use/client/connectors/websocket.py +257 -0
  90. mcp_use-1.6.0/mcp_use/client/exceptions.py +31 -0
  91. mcp_use-1.6.0/mcp_use/client/middleware/__init__.py +50 -0
  92. mcp_use-1.6.0/mcp_use/client/middleware/logging.py +31 -0
  93. mcp_use-1.6.0/mcp_use/client/middleware/metrics.py +314 -0
  94. mcp_use-1.6.0/mcp_use/client/middleware/middleware.py +276 -0
  95. mcp_use-1.6.0/mcp_use/client/prompts.py +130 -0
  96. mcp_use-1.6.0/mcp_use/client/session.py +164 -0
  97. mcp_use-1.6.0/mcp_use/client/task_managers/__init__.py +20 -0
  98. mcp_use-1.6.0/mcp_use/client/task_managers/base.py +213 -0
  99. mcp_use-1.6.0/mcp_use/client/task_managers/sse.py +89 -0
  100. mcp_use-1.6.0/mcp_use/client/task_managers/stdio.py +69 -0
  101. mcp_use-1.6.0/mcp_use/client/task_managers/streamable_http.py +91 -0
  102. mcp_use-1.6.0/mcp_use/client/task_managers/websocket.py +68 -0
  103. mcp_use-1.6.0/mcp_use/client.py +18 -0
  104. mcp_use-1.6.0/mcp_use/config.py +27 -0
  105. mcp_use-1.6.0/mcp_use/connectors/.deprecated +0 -0
  106. mcp_use-1.6.0/mcp_use/connectors/__init__.py +46 -0
  107. mcp_use-1.6.0/mcp_use/connectors/base.py +18 -0
  108. mcp_use-1.6.0/mcp_use/connectors/http.py +18 -0
  109. mcp_use-1.6.0/mcp_use/connectors/sandbox.py +18 -0
  110. mcp_use-1.6.0/mcp_use/connectors/stdio.py +18 -0
  111. mcp_use-1.6.0/mcp_use/connectors/utils.py +20 -0
  112. mcp_use-1.6.0/mcp_use/connectors/websocket.py +18 -0
  113. mcp_use-1.6.0/mcp_use/errors/__init__.py +1 -0
  114. mcp_use-1.6.0/mcp_use/errors/error_formatting.py +26 -0
  115. mcp_use-1.6.0/mcp_use/exceptions.py +46 -0
  116. mcp_use-1.6.0/mcp_use/logging.py +158 -0
  117. mcp_use-1.6.0/mcp_use/managers/.deprecated +0 -0
  118. mcp_use-1.6.0/mcp_use/managers/__init__.py +58 -0
  119. mcp_use-1.6.0/mcp_use/managers/base.py +18 -0
  120. mcp_use-1.6.0/mcp_use/managers/server_manager.py +18 -0
  121. mcp_use-1.6.0/mcp_use/managers/tools/__init__.py +45 -0
  122. mcp_use-1.6.0/mcp_use/managers/tools/base_tool.py +8 -0
  123. mcp_use-1.6.0/mcp_use/managers/tools/connect_server.py +8 -0
  124. mcp_use-1.6.0/mcp_use/managers/tools/disconnect_server.py +8 -0
  125. mcp_use-1.6.0/mcp_use/managers/tools/get_active_server.py +8 -0
  126. mcp_use-1.6.0/mcp_use/managers/tools/list_servers_tool.py +8 -0
  127. mcp_use-1.6.0/mcp_use/managers/tools/search_tools.py +24 -0
  128. mcp_use-1.6.0/mcp_use/middleware/.deprecated +0 -0
  129. mcp_use-1.6.0/mcp_use/middleware/__init__.py +89 -0
  130. mcp_use-1.6.0/mcp_use/middleware/logging.py +19 -0
  131. mcp_use-1.6.0/mcp_use/middleware/metrics.py +41 -0
  132. mcp_use-1.6.0/mcp_use/middleware/middleware.py +55 -0
  133. mcp_use-1.6.0/mcp_use/server/__fastmcp.py +5 -0
  134. mcp_use-1.6.0/mcp_use/server/__init__.py +16 -0
  135. mcp_use-1.6.0/mcp_use/server/auth/__init__.py +40 -0
  136. mcp_use-1.6.0/mcp_use/server/auth/bearer.py +47 -0
  137. mcp_use-1.6.0/mcp_use/server/auth/dependencies.py +59 -0
  138. mcp_use-1.6.0/mcp_use/server/auth/middleware.py +137 -0
  139. mcp_use-1.6.0/mcp_use/server/auth/models.py +39 -0
  140. mcp_use-1.6.0/mcp_use/server/context.py +156 -0
  141. mcp_use-1.6.0/mcp_use/server/logging/__init__.py +40 -0
  142. mcp_use-1.6.0/mcp_use/server/logging/config.py +118 -0
  143. mcp_use-1.6.0/mcp_use/server/logging/formatters.py +148 -0
  144. mcp_use-1.6.0/mcp_use/server/logging/middleware.py +206 -0
  145. mcp_use-1.6.0/mcp_use/server/logging/startup.py +53 -0
  146. mcp_use-1.6.0/mcp_use/server/logging/state.py +16 -0
  147. mcp_use-1.6.0/mcp_use/server/middleware/__init__.py +17 -0
  148. mcp_use-1.6.0/mcp_use/server/middleware/middleware.py +148 -0
  149. mcp_use-1.6.0/mcp_use/server/middleware/server_session.py +58 -0
  150. mcp_use-1.6.0/mcp_use/server/middleware/telemetry.py +72 -0
  151. mcp_use-1.6.0/mcp_use/server/router.py +260 -0
  152. mcp_use-1.6.0/mcp_use/server/runner.py +99 -0
  153. mcp_use-1.6.0/mcp_use/server/server.py +441 -0
  154. mcp_use-1.6.0/mcp_use/server/types.py +9 -0
  155. mcp_use-1.6.0/mcp_use/server/utils/__init__.py +0 -0
  156. mcp_use-1.6.0/mcp_use/server/utils/inspector.py +75 -0
  157. mcp_use-1.6.0/mcp_use/server/utils/openmcp.py +173 -0
  158. mcp_use-1.6.0/mcp_use/server/utils/routes.py +20 -0
  159. mcp_use-1.6.0/mcp_use/server/utils/templates/docs.html +222 -0
  160. mcp_use-1.6.0/mcp_use/server/utils/utils.py +54 -0
  161. mcp_use-1.6.0/mcp_use/session.py +18 -0
  162. mcp_use-1.6.0/mcp_use/task_managers/.deprecated +0 -0
  163. mcp_use-1.6.0/mcp_use/task_managers/__init__.py +48 -0
  164. mcp_use-1.6.0/mcp_use/task_managers/base.py +18 -0
  165. mcp_use-1.6.0/mcp_use/task_managers/sse.py +18 -0
  166. mcp_use-1.6.0/mcp_use/task_managers/stdio.py +18 -0
  167. mcp_use-1.6.0/mcp_use/task_managers/streamable_http.py +20 -0
  168. mcp_use-1.6.0/mcp_use/task_managers/websocket.py +18 -0
  169. mcp_use-1.6.0/mcp_use/telemetry/__init__.py +11 -0
  170. mcp_use-1.6.0/mcp_use/telemetry/events.py +275 -0
  171. mcp_use-1.6.0/mcp_use/telemetry/telemetry.py +557 -0
  172. mcp_use-1.6.0/mcp_use/telemetry/utils.py +308 -0
  173. mcp_use-1.6.0/mcp_use/types/.deprecated +0 -0
  174. mcp_use-1.6.0/mcp_use/types/sandbox.py +18 -0
  175. mcp_use-1.6.0/mcp_use/utils.py +27 -0
  176. mcp_use-1.6.0/pyproject.toml +100 -0
  177. mcp_use-1.6.0/pytest.ini +6 -0
  178. mcp_use-1.6.0/python/api-reference/mcp_use_adapters_base.mdx +49 -0
  179. mcp_use-1.6.0/python/api-reference/mcp_use_adapters_langchain_adapter.mdx +49 -0
  180. mcp_use-1.6.0/python/api-reference/mcp_use_agents_adapters_anthropic.mdx +49 -0
  181. mcp_use-1.6.0/python/api-reference/mcp_use_agents_adapters_base.mdx +240 -0
  182. mcp_use-1.6.0/python/api-reference/mcp_use_agents_adapters_langchain_adapter.mdx +55 -0
  183. mcp_use-1.6.0/python/api-reference/mcp_use_agents_adapters_openai.mdx +49 -0
  184. mcp_use-1.6.0/python/api-reference/mcp_use_agents_base.mdx +109 -0
  185. mcp_use-1.6.0/python/api-reference/mcp_use_agents_display.mdx +57 -0
  186. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_base.mdx +81 -0
  187. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_server_manager.mdx +82 -0
  188. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_tools_base_tool.mdx +62 -0
  189. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_tools_connect_server.mdx +95 -0
  190. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_tools_disconnect_server.mdx +88 -0
  191. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_tools_get_active_server.mdx +88 -0
  192. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_tools_list_servers_tool.mdx +88 -0
  193. mcp_use-1.6.0/python/api-reference/mcp_use_agents_managers_tools_search_tools.mdx +203 -0
  194. mcp_use-1.6.0/python/api-reference/mcp_use_agents_mcpagent.mdx +352 -0
  195. mcp_use-1.6.0/python/api-reference/mcp_use_agents_middleware_tool_error_middleware.mdx +17 -0
  196. mcp_use-1.6.0/python/api-reference/mcp_use_agents_observability_callbacks_manager.mdx +180 -0
  197. mcp_use-1.6.0/python/api-reference/mcp_use_agents_observability_laminar.mdx +16 -0
  198. mcp_use-1.6.0/python/api-reference/mcp_use_agents_observability_langfuse.mdx +12 -0
  199. mcp_use-1.6.0/python/api-reference/mcp_use_agents_prompts_system_prompt_builder.mdx +115 -0
  200. mcp_use-1.6.0/python/api-reference/mcp_use_agents_prompts_templates.mdx +12 -0
  201. mcp_use-1.6.0/python/api-reference/mcp_use_agents_remote.mdx +118 -0
  202. mcp_use-1.6.0/python/api-reference/mcp_use_auth_bearer.mdx +46 -0
  203. mcp_use-1.6.0/python/api-reference/mcp_use_auth_oauth.mdx +48 -0
  204. mcp_use-1.6.0/python/api-reference/mcp_use_auth_oauth_callback.mdx +73 -0
  205. mcp_use-1.6.0/python/api-reference/mcp_use_client.mdx +12 -0
  206. mcp_use-1.6.0/python/api-reference/mcp_use_client_auth_bearer.mdx +50 -0
  207. mcp_use-1.6.0/python/api-reference/mcp_use_client_auth_oauth.mdx +432 -0
  208. mcp_use-1.6.0/python/api-reference/mcp_use_client_auth_oauth_callback.mdx +138 -0
  209. mcp_use-1.6.0/python/api-reference/mcp_use_client_client.mdx +332 -0
  210. mcp_use-1.6.0/python/api-reference/mcp_use_client_code_executor.mdx +74 -0
  211. mcp_use-1.6.0/python/api-reference/mcp_use_client_config.mdx +86 -0
  212. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_base.mdx +325 -0
  213. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_code_mode.mdx +52 -0
  214. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_http.mdx +62 -0
  215. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_sandbox.mdx +127 -0
  216. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_stdio.mdx +61 -0
  217. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_utils.mdx +37 -0
  218. mcp_use-1.6.0/python/api-reference/mcp_use_client_connectors_websocket.mdx +74 -0
  219. mcp_use-1.6.0/python/api-reference/mcp_use_client_exceptions.mdx +174 -0
  220. mcp_use-1.6.0/python/api-reference/mcp_use_client_middleware_logging.mdx +33 -0
  221. mcp_use-1.6.0/python/api-reference/mcp_use_client_middleware_metrics.mdx +185 -0
  222. mcp_use-1.6.0/python/api-reference/mcp_use_client_middleware_middleware.mdx +595 -0
  223. mcp_use-1.6.0/python/api-reference/mcp_use_client_prompts.mdx +17 -0
  224. mcp_use-1.6.0/python/api-reference/mcp_use_client_session.mdx +232 -0
  225. mcp_use-1.6.0/python/api-reference/mcp_use_client_task_managers_base.mdx +95 -0
  226. mcp_use-1.6.0/python/api-reference/mcp_use_client_task_managers_sse.mdx +58 -0
  227. mcp_use-1.6.0/python/api-reference/mcp_use_client_task_managers_stdio.mdx +54 -0
  228. mcp_use-1.6.0/python/api-reference/mcp_use_client_task_managers_streamable_http.mdx +58 -0
  229. mcp_use-1.6.0/python/api-reference/mcp_use_client_task_managers_websocket.mdx +52 -0
  230. mcp_use-1.6.0/python/api-reference/mcp_use_config.mdx +52 -0
  231. mcp_use-1.6.0/python/api-reference/mcp_use_connectors_base.mdx +45 -0
  232. mcp_use-1.6.0/python/api-reference/mcp_use_connectors_http.mdx +52 -0
  233. mcp_use-1.6.0/python/api-reference/mcp_use_connectors_sandbox.mdx +52 -0
  234. mcp_use-1.6.0/python/api-reference/mcp_use_connectors_stdio.mdx +50 -0
  235. mcp_use-1.6.0/python/api-reference/mcp_use_connectors_utils.mdx +34 -0
  236. mcp_use-1.6.0/python/api-reference/mcp_use_connectors_websocket.mdx +44 -0
  237. mcp_use-1.6.0/python/api-reference/mcp_use_errors_error_formatting.mdx +38 -0
  238. mcp_use-1.6.0/python/api-reference/mcp_use_exceptions.mdx +162 -0
  239. mcp_use-1.6.0/python/api-reference/mcp_use_logging.mdx +37 -0
  240. mcp_use-1.6.0/python/api-reference/mcp_use_managers_base.mdx +27 -0
  241. mcp_use-1.6.0/python/api-reference/mcp_use_managers_server_manager.mdx +43 -0
  242. mcp_use-1.6.0/python/api-reference/mcp_use_managers_tools_base_tool.mdx +49 -0
  243. mcp_use-1.6.0/python/api-reference/mcp_use_managers_tools_connect_server.mdx +50 -0
  244. mcp_use-1.6.0/python/api-reference/mcp_use_managers_tools_disconnect_server.mdx +50 -0
  245. mcp_use-1.6.0/python/api-reference/mcp_use_managers_tools_get_active_server.mdx +50 -0
  246. mcp_use-1.6.0/python/api-reference/mcp_use_managers_tools_list_servers_tool.mdx +50 -0
  247. mcp_use-1.6.0/python/api-reference/mcp_use_managers_tools_search_tools.mdx +123 -0
  248. mcp_use-1.6.0/python/api-reference/mcp_use_middleware_logging.mdx +32 -0
  249. mcp_use-1.6.0/python/api-reference/mcp_use_middleware_metrics.mdx +108 -0
  250. mcp_use-1.6.0/python/api-reference/mcp_use_middleware_middleware.mdx +172 -0
  251. mcp_use-1.6.0/python/api-reference/mcp_use_server_context.mdx +135 -0
  252. mcp_use-1.6.0/python/api-reference/mcp_use_server_logging_config.mdx +76 -0
  253. mcp_use-1.6.0/python/api-reference/mcp_use_server_logging_formatters.mdx +205 -0
  254. mcp_use-1.6.0/python/api-reference/mcp_use_server_logging_middleware.mdx +62 -0
  255. mcp_use-1.6.0/python/api-reference/mcp_use_server_logging_startup.mdx +43 -0
  256. mcp_use-1.6.0/python/api-reference/mcp_use_server_logging_state.mdx +56 -0
  257. mcp_use-1.6.0/python/api-reference/mcp_use_server_middleware_middleware.mdx +407 -0
  258. mcp_use-1.6.0/python/api-reference/mcp_use_server_router.mdx +365 -0
  259. mcp_use-1.6.0/python/api-reference/mcp_use_server_runner.mdx +130 -0
  260. mcp_use-1.6.0/python/api-reference/mcp_use_server_server.mdx +105 -0
  261. mcp_use-1.6.0/python/api-reference/mcp_use_server_types.mdx +14 -0
  262. mcp_use-1.6.0/python/api-reference/mcp_use_server_utils_inspector.mdx +12 -0
  263. mcp_use-1.6.0/python/api-reference/mcp_use_server_utils_openmcp.mdx +118 -0
  264. mcp_use-1.6.0/python/api-reference/mcp_use_server_utils_routes.mdx +60 -0
  265. mcp_use-1.6.0/python/api-reference/mcp_use_server_utils_signals.mdx +32 -0
  266. mcp_use-1.6.0/python/api-reference/mcp_use_server_utils_utils.mdx +81 -0
  267. mcp_use-1.6.0/python/api-reference/mcp_use_session.mdx +43 -0
  268. mcp_use-1.6.0/python/api-reference/mcp_use_task_managers_base.mdx +38 -0
  269. mcp_use-1.6.0/python/api-reference/mcp_use_task_managers_sse.mdx +47 -0
  270. mcp_use-1.6.0/python/api-reference/mcp_use_task_managers_stdio.mdx +43 -0
  271. mcp_use-1.6.0/python/api-reference/mcp_use_task_managers_streamable_http.mdx +47 -0
  272. mcp_use-1.6.0/python/api-reference/mcp_use_task_managers_websocket.mdx +43 -0
  273. mcp_use-1.6.0/python/api-reference/mcp_use_types_sandbox.mdx +51 -0
  274. mcp_use-1.6.0/python/api-reference/mcp_use_utils.mdx +44 -0
  275. mcp_use-1.6.0/static/logo-gh.jpg +0 -0
  276. mcp_use-1.6.0/static/logo_black.svg +8 -0
  277. mcp_use-1.6.0/static/logo_white.svg +8 -0
  278. mcp_use-1.6.0/tests/conftest.py +37 -0
  279. mcp_use-1.6.0/tests/integration/__init__.py +1 -0
  280. mcp_use-1.6.0/tests/integration/agent/test_agent_run.py +47 -0
  281. mcp_use-1.6.0/tests/integration/agent/test_agent_stream.py +84 -0
  282. mcp_use-1.6.0/tests/integration/agent/test_agent_structured_output.py +63 -0
  283. mcp_use-1.6.0/tests/integration/agent/test_server_manager.py +118 -0
  284. mcp_use-1.6.0/tests/integration/agent/test_stream_events_memory.py +143 -0
  285. mcp_use-1.6.0/tests/integration/client/auth/__init__.py +0 -0
  286. mcp_use-1.6.0/tests/integration/client/auth/test_bearer_auth.py +216 -0
  287. mcp_use-1.6.0/tests/integration/client/others/test_code_mode.py +218 -0
  288. mcp_use-1.6.0/tests/integration/client/primitives/test_auth.py +201 -0
  289. mcp_use-1.6.0/tests/integration/client/primitives/test_discovery.py +70 -0
  290. mcp_use-1.6.0/tests/integration/client/primitives/test_elicitation.py +26 -0
  291. mcp_use-1.6.0/tests/integration/client/primitives/test_logging.py +22 -0
  292. mcp_use-1.6.0/tests/integration/client/primitives/test_notifications.py +22 -0
  293. mcp_use-1.6.0/tests/integration/client/primitives/test_prompts.py +20 -0
  294. mcp_use-1.6.0/tests/integration/client/primitives/test_resources.py +42 -0
  295. mcp_use-1.6.0/tests/integration/client/primitives/test_roots.py +161 -0
  296. mcp_use-1.6.0/tests/integration/client/primitives/test_sampling.py +48 -0
  297. mcp_use-1.6.0/tests/integration/client/primitives/test_tools.py +23 -0
  298. mcp_use-1.6.0/tests/integration/client/transports/test_stdio.py +53 -0
  299. mcp_use-1.6.0/tests/integration/client/transports/test_streamable_http.py +73 -0
  300. mcp_use-1.6.0/tests/integration/conftest.py +76 -0
  301. mcp_use-1.6.0/tests/integration/servers_for_testing/__init__.py +1 -0
  302. mcp_use-1.6.0/tests/integration/servers_for_testing/auth_server.py +158 -0
  303. mcp_use-1.6.0/tests/integration/servers_for_testing/bearer_auth_server.py +95 -0
  304. mcp_use-1.6.0/tests/integration/servers_for_testing/conformance_server.py +318 -0
  305. mcp_use-1.6.0/tests/integration/servers_for_testing/primitive_server.py +165 -0
  306. mcp_use-1.6.0/tests/integration/servers_for_testing/simple_server.py +34 -0
  307. mcp_use-1.6.0/tests/integration/servers_for_testing/timeout_test_server.py +151 -0
  308. mcp_use-1.6.0/tests/unit/backward_compatibility.py +104 -0
  309. mcp_use-1.6.0/tests/unit/server/auth/__init__.py +0 -0
  310. mcp_use-1.6.0/tests/unit/server/auth/test_auth_middleware.py +346 -0
  311. mcp_use-1.6.0/tests/unit/server/auth/test_bearer_auth.py +177 -0
  312. mcp_use-1.6.0/tests/unit/server/middleware/test_initialize_middleware.py +440 -0
  313. mcp_use-1.6.0/tests/unit/server/test_server_config.py +108 -0
  314. mcp_use-1.6.0/tests/unit/test_agent.py +279 -0
  315. mcp_use-1.6.0/tests/unit/test_client.py +577 -0
  316. mcp_use-1.6.0/tests/unit/test_client_capabilities.py +296 -0
  317. mcp_use-1.6.0/tests/unit/test_code_executor.py +426 -0
  318. mcp_use-1.6.0/tests/unit/test_config.py +225 -0
  319. mcp_use-1.6.0/tests/unit/test_connection_manager_timeout.py +240 -0
  320. mcp_use-1.6.0/tests/unit/test_enum_handling.py +109 -0
  321. mcp_use-1.6.0/tests/unit/test_http_connector.py +456 -0
  322. mcp_use-1.6.0/tests/unit/test_sandbox_connector.py +311 -0
  323. mcp_use-1.6.0/tests/unit/test_search_tools_issue_138.py +185 -0
  324. mcp_use-1.6.0/tests/unit/test_session.py +114 -0
  325. mcp_use-1.6.0/tests/unit/test_stdio_connector.py +389 -0
  326. mcp_use-1.6.0/tests/unit/test_websocket_connection_manager.py +81 -0
@@ -0,0 +1,61 @@
1
+ # =============================================================================
2
+ # MCP-Use Environment Configuration
3
+ # =============================================================================
4
+ # Copy this file to .env and fill in your actual values
5
+ # The .env file is already in .gitignore and won't be committed
6
+
7
+ # =============================================================================
8
+ # Observability - Optional but recommended for debugging and monitoring
9
+ # =============================================================================
10
+
11
+ # Langfuse Configuration (https://langfuse.com)
12
+ # Sign up at https://cloud.langfuse.com or self-host
13
+ LANGFUSE_PUBLIC_KEY=pk-lf-your-public-key-here
14
+ LANGFUSE_SECRET_KEY=sk-lf-your-secret-key-here
15
+ # LANGFUSE_HOST=https://cloud.langfuse.com # Default, uncomment for self-hosted
16
+
17
+ # Laminar Configuration (https://www.lmnr.ai)
18
+ # Sign up at https://www.lmnr.ai and get your project API key
19
+ LAMINAR_PROJECT_API_KEY=your-laminar-project-api-key-here
20
+
21
+ # =============================================================================
22
+ # LLM Provider API Keys
23
+ # =============================================================================
24
+
25
+ # OpenAI
26
+ OPENAI_API_KEY=sk-your-openai-api-key-here
27
+
28
+ # Anthropic
29
+ ANTHROPIC_API_KEY=sk-ant-your-anthropic-api-key-here
30
+
31
+ # Google (for Gemini)
32
+ GOOGLE_API_KEY=your-google-api-key-here
33
+
34
+ # Azure OpenAI
35
+ AZURE_OPENAI_API_KEY=your-azure-openai-key-here
36
+ AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com/
37
+
38
+ # =============================================================================
39
+ # Debug and Development
40
+ # =============================================================================
41
+
42
+ # MCP-Use Debug Level (1=INFO, 2=DEBUG)
43
+ DEBUG=1
44
+ # Alternative debug variable
45
+ MCP_USE_DEBUG=1
46
+
47
+ # Disable specific features (set to 'false' to disable)
48
+ # MCP_USE_LANGFUSE=false
49
+ # MCP_USE_LAMINAR=false
50
+ # MCP_USE_TELEMETRY=false
51
+
52
+ # =============================================================================
53
+ # MCP Server Specific Configuration
54
+ # =============================================================================
55
+
56
+ # E2B Sandbox (for sandboxed execution)
57
+ E2B_API_KEY=your-e2b-api-key-here
58
+
59
+ # Custom MCP server endpoints (if using HTTP/WebSocket servers)
60
+ # MCP_SERVER_URL=http://localhost:8080
61
+ # MCP_WEBSOCKET_URL=ws://localhost:8081
@@ -0,0 +1,128 @@
1
+
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+
28
+ # PyInstaller
29
+ *.manifest
30
+ *.spec
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+
36
+ # Unit test / coverage reports
37
+ htmlcov/
38
+ .tox/
39
+ .nox/
40
+ .coverage
41
+ .coverage.*
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ *.cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Django stuff:
54
+ *.log
55
+ local_settings.py
56
+ db.sqlite3
57
+ db.sqlite3-journal
58
+
59
+ # Flask stuff:
60
+ instance/
61
+ .webassets-cache
62
+
63
+ # Scrapy stuff:
64
+ .scrapy
65
+
66
+ # Sphinx documentation
67
+ docs/_build/
68
+
69
+ # PyBuilder
70
+ target/
71
+
72
+ # Jupyter Notebook
73
+ .ipynb_checkpoints
74
+
75
+ # IPython
76
+ profile_default/
77
+ ipython_config.py
78
+
79
+ # pyenv
80
+ .python-version
81
+
82
+ # pipenv
83
+ Pipfile.lock
84
+
85
+ # poetry
86
+ poetry.lock
87
+
88
+ # Environment variables
89
+ .env
90
+ .venv
91
+ env/
92
+ venv/
93
+ ENV/
94
+ env.bak/
95
+ venv.bak/
96
+
97
+ # Spyder project settings
98
+ .spyderproject
99
+ .spyproject
100
+
101
+ # Rope project settings
102
+ .ropeproject
103
+
104
+ # mkdocs documentation
105
+ /site
106
+
107
+ # mypy
108
+ .mypy_cache/
109
+ .dmypy.json
110
+ dmypy.json
111
+
112
+ # Pyre type checker
113
+ .pyre/
114
+
115
+ # VS Code
116
+ .vscode/
117
+ *.code-workspace
118
+
119
+ # PyCharm
120
+ .idea/
121
+ *.iml
122
+
123
+ # macOS
124
+ .DS_Store
125
+
126
+ # AI
127
+ .cursor
128
+ .claude
@@ -0,0 +1,28 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.11.12
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix, --exit-non-zero-on-fix]
7
+ - id: ruff-format
8
+
9
+ - repo: local
10
+ hooks:
11
+ - id: ty
12
+ name: ty check
13
+ entry: ty check
14
+ language: system
15
+ types: [python]
16
+ exclude: ^tests/
17
+
18
+ - repo: https://github.com/pre-commit/pre-commit-hooks
19
+ rev: v5.0.0
20
+ hooks:
21
+ - id: trailing-whitespace
22
+ - id: end-of-file-fixer
23
+ - id: check-yaml
24
+ - id: check-added-large-files
25
+ - id: debug-statements
26
+
27
+ default_language_version:
28
+ python: python3.11
@@ -0,0 +1,254 @@
1
+ # CLAUDE.md - Python Library
2
+
3
+ This file provides guidance for working with the Python implementation of mcp-use.
4
+
5
+ **IMPORTANT:** Read the root `/CLAUDE.md` first for critical workflow requirements around planning, breaking changes, and testing standards.
6
+
7
+ ---
8
+
9
+ ## Project Overview
10
+
11
+ **mcp-use** is a unified MCP (Model Context Protocol) client library that enables any LLM to connect to MCP servers and build custom agents with tool access. The library provides a high-level Python interface for connecting LangChain-compatible LLMs to MCP tools like web browsing, file operations, and more.
12
+
13
+ ## Development Commands
14
+
15
+ ### Setup
16
+
17
+ ```bash
18
+ # Activate virtual environment (if it exists)
19
+ source env/bin/activate
20
+
21
+ # Create virtual environment if it doesn't exist
22
+ # python -m venv env && source env/bin/activate
23
+
24
+ # Install for development
25
+ pip install -e ".[dev,search]"
26
+
27
+ # Install with optional dependencies
28
+ pip install -e ".[dev,anthropic,openai,e2b,search]"
29
+ ```
30
+
31
+ ### Code Quality
32
+
33
+ ```bash
34
+ # Run linting and formatting
35
+ ruff check --fix
36
+ ruff format
37
+
38
+ # Run type checking
39
+ ty check
40
+
41
+ # Run pre-commit hooks
42
+ prek run --all-files
43
+ ```
44
+
45
+ ### Testing
46
+
47
+ ```bash
48
+ # Run all tests
49
+ pytest
50
+
51
+ # Run specific test types
52
+ pytest tests/unit/ # Unit tests only
53
+ pytest tests/integration/ # Integration tests only
54
+
55
+ # Run with coverage
56
+ pytest --cov=mcp_use --cov-report=html
57
+
58
+ # Run specific test file
59
+ pytest tests/unit/test_client.py
60
+
61
+ # Run with debug output
62
+ DEBUG=2 pytest tests/unit/test_client.py -v -s
63
+ ```
64
+
65
+ ### Local Development
66
+
67
+ ```bash
68
+ # Debug mode environment variable
69
+ export DEBUG=1 # INFO level
70
+ export DEBUG=2 # DEBUG level (full verbose)
71
+
72
+ # Or set MCP_USE_DEBUG
73
+ export MCP_USE_DEBUG=2
74
+ ```
75
+
76
+ ## Architecture Overview
77
+
78
+ ### Core Components
79
+
80
+ **MCPClient** (`mcp_use/client.py`)
81
+
82
+ - Main entry point for MCP server management
83
+ - Handles configuration loading from files or dictionaries
84
+ - Manages multiple MCP server sessions
85
+ - Supports sandboxed execution via E2B
86
+
87
+ **MCPAgent** (`mcp_use/agents/mcpagent.py`)
88
+
89
+ - High-level agent interface using LangChain's agent framework
90
+ - Integrates LLMs with MCP tools
91
+ - Supports streaming responses and conversation memory
92
+ - Can use ServerManager for dynamic server selection
93
+
94
+ **MCPSession** (`mcp_use/session.py`)
95
+
96
+ - Manages individual MCP server connections
97
+ - Handles tool discovery and resource management
98
+ - Maintains connection state and lifecycle
99
+
100
+ **Connectors** (`mcp_use/connectors/`)
101
+
102
+ - Abstraction layer for different MCP transport protocols
103
+ - `StdioConnector`: Process-based MCP servers
104
+ - `HttpConnector`: HTTP-based MCP servers
105
+ - `WebSocketConnector`: WebSocket-based MCP servers
106
+ - `SandboxConnector`: E2B sandboxed execution
107
+
108
+ **ServerManager** (`mcp_use/managers/server_manager.py`)
109
+
110
+ - Provides dynamic server selection capabilities
111
+ - Allows agents to choose appropriate servers for tasks
112
+ - Manages server tool discovery and activation
113
+
114
+ ### Key Patterns
115
+
116
+ **Configuration-Driven Design**: Servers are configured via JSON files or dictionaries with `mcpServers` key containing server definitions.
117
+
118
+ **Async/Await**: All I/O operations are asynchronous using asyncio patterns.
119
+
120
+ **LangChain Integration**: Tools are converted to LangChain format via adapters, enabling use with any LangChain-compatible LLM.
121
+
122
+ **Multi-Transport Support**: Supports stdio, HTTP, WebSocket, and sandboxed connections to MCP servers.
123
+
124
+ **Telemetry**: Built-in telemetry using PostHog and Scarf.sh for usage analytics (can be disabled).
125
+
126
+ ## Configuration Examples
127
+
128
+ ### Basic Server Configuration
129
+
130
+ ```json
131
+ {
132
+ "mcpServers": {
133
+ "playwright": {
134
+ "command": "npx",
135
+ "args": ["@playwright/mcp@latest"],
136
+ "env": { "DISPLAY": ":1" }
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ ### HTTP Server Configuration
143
+
144
+ ```json
145
+ {
146
+ "mcpServers": {
147
+ "http_server": {
148
+ "url": "http://localhost:8931/sse"
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### Multi-Server Configuration
155
+
156
+ ```json
157
+ {
158
+ "mcpServers": {
159
+ "playwright": {
160
+ "command": "npx",
161
+ "args": ["@playwright/mcp@latest"]
162
+ },
163
+ "airbnb": {
164
+ "command": "npx",
165
+ "args": ["-y", "@openbnb/mcp-server-airbnb"]
166
+ }
167
+ }
168
+ }
169
+ ```
170
+
171
+ ## Code Style and Standards
172
+
173
+ - **Line Length**: 200 characters (configured in ruff.toml)
174
+ - **Python Version**: 3.11+ required
175
+ - **Formatting**: Use Ruff for formatting and linting
176
+ - **Type Hints**: All public APIs should have type hints
177
+ - **Async Patterns**: Use async/await consistently for I/O operations
178
+ - **Error Handling**: Proper exception handling with logging
179
+ - **Documentation**: Docstrings follow Google style
180
+
181
+ ## Testing Strategy
182
+
183
+ **Tests are MANDATORY for new functionality. See root CLAUDE.md for standards.**
184
+
185
+ ### Unit Tests (`tests/unit/`)
186
+
187
+ - Test individual components in isolation
188
+ - Mock only external dependencies (network, file I/O), NOT internal logic
189
+ - Focus on business logic and edge cases
190
+ - **DO NOT** create tests that only verify mocks were called
191
+
192
+ ### Integration Tests (`tests/integration/`)
193
+
194
+ - Test component interactions with real MCP servers
195
+ - Organized by category:
196
+ - `client/transports/` - stdio, sse, streamable_http
197
+ - `client/primitives/` - tools, resources, prompts
198
+ - `agent/` - Full agent workflows (require API keys)
199
+ - Custom test servers in `tests/integration/servers_for_testing/`
200
+
201
+ ### Test Requirements
202
+
203
+ - Every new public method/function needs tests
204
+ - Test both success cases AND error handling
205
+ - Integration tests preferred over heavily mocked unit tests
206
+ - If you mock everything, you're testing nothing
207
+
208
+ ### Test Configuration
209
+
210
+ - Uses pytest with asyncio mode
211
+ - Fixtures defined in `conftest.py`
212
+ - Test servers provide controlled MCP environments
213
+
214
+ ## Important Development Notes
215
+
216
+ - **Environment Setup**: Requires Python 3.11+ and appropriate LangChain provider packages
217
+ - **MCP Protocol**: Built on Model Context Protocol specification
218
+ - **LangChain Compatibility**: Only models with tool calling capabilities are supported
219
+ - **Resource Management**: Always properly close sessions to avoid resource leaks
220
+ - **Debugging**: Use DEBUG environment variable or `mcp_use.set_debug()` for verbose logging
221
+ - **Memory Management**: MCPAgent supports conversation memory for context retention
222
+ - **Security**: Tool access can be restricted via `disallowed_tools` parameter
223
+
224
+ ## Common Development Tasks
225
+
226
+ ### Adding a New Connector
227
+
228
+ 1. Extend `BaseConnector` in `mcp_use/connectors/`
229
+ 2. Implement required async methods
230
+ 3. Add connector to factory in `config.py`
231
+ 4. Write integration tests
232
+
233
+ ### Adding New Agent Features
234
+
235
+ 1. Modify `MCPAgent` class in `mcp_use/agents/mcpagent.py`
236
+ 2. Update system prompt templates if needed
237
+ 3. Add comprehensive tests
238
+ 4. Update documentation
239
+
240
+ ### Testing with Custom MCP Servers
241
+
242
+ 1. Create test server in `tests/integration/servers_for_testing/`
243
+ 2. Add integration test in appropriate transport directory
244
+ 3. Use custom servers for controlled testing scenarios
245
+
246
+ ## Post-Implementation Checklist
247
+
248
+ After completing any feature or fix:
249
+
250
+ 1. **Tests pass**: `pytest tests/unit` (and integration if applicable)
251
+ 2. **Linting passes**: `ruff check && ruff format --check`
252
+ 3. **Documentation updated**: Check `docs/`, README, docstrings
253
+ 4. **Examples updated**: Check `examples/` directory if API changed
254
+ 5. **PR description ready**: Follow `.github/pull_request_template.md`