mcp-use 1.3.12__py3-none-any.whl → 1.4.0__py3-none-any.whl

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 (108) hide show
  1. mcp_use/__init__.py +1 -1
  2. mcp_use/adapters/.deprecated +0 -0
  3. mcp_use/adapters/__init__.py +18 -7
  4. mcp_use/adapters/base.py +12 -185
  5. mcp_use/adapters/langchain_adapter.py +12 -219
  6. mcp_use/agents/adapters/__init__.py +17 -0
  7. mcp_use/agents/adapters/anthropic.py +93 -0
  8. mcp_use/agents/adapters/base.py +316 -0
  9. mcp_use/agents/adapters/google.py +103 -0
  10. mcp_use/agents/adapters/langchain_adapter.py +212 -0
  11. mcp_use/agents/adapters/openai.py +111 -0
  12. mcp_use/agents/base.py +1 -1
  13. mcp_use/agents/managers/__init__.py +19 -0
  14. mcp_use/agents/managers/base.py +36 -0
  15. mcp_use/agents/managers/server_manager.py +131 -0
  16. mcp_use/agents/managers/tools/__init__.py +15 -0
  17. mcp_use/agents/managers/tools/base_tool.py +19 -0
  18. mcp_use/agents/managers/tools/connect_server.py +69 -0
  19. mcp_use/agents/managers/tools/disconnect_server.py +43 -0
  20. mcp_use/agents/managers/tools/get_active_server.py +29 -0
  21. mcp_use/agents/managers/tools/list_servers_tool.py +53 -0
  22. mcp_use/agents/managers/tools/search_tools.py +328 -0
  23. mcp_use/agents/mcpagent.py +386 -485
  24. mcp_use/agents/prompts/system_prompt_builder.py +1 -1
  25. mcp_use/agents/remote.py +15 -2
  26. mcp_use/auth/.deprecated +0 -0
  27. mcp_use/auth/__init__.py +19 -4
  28. mcp_use/auth/bearer.py +11 -12
  29. mcp_use/auth/oauth.py +11 -620
  30. mcp_use/auth/oauth_callback.py +16 -207
  31. mcp_use/client/__init__.py +1 -0
  32. mcp_use/client/auth/__init__.py +6 -0
  33. mcp_use/client/auth/bearer.py +23 -0
  34. mcp_use/client/auth/oauth.py +629 -0
  35. mcp_use/client/auth/oauth_callback.py +215 -0
  36. mcp_use/client/client.py +356 -0
  37. mcp_use/client/config.py +106 -0
  38. mcp_use/client/connectors/__init__.py +20 -0
  39. mcp_use/client/connectors/base.py +470 -0
  40. mcp_use/client/connectors/http.py +304 -0
  41. mcp_use/client/connectors/sandbox.py +332 -0
  42. mcp_use/client/connectors/stdio.py +109 -0
  43. mcp_use/client/connectors/utils.py +13 -0
  44. mcp_use/client/connectors/websocket.py +257 -0
  45. mcp_use/client/exceptions.py +31 -0
  46. mcp_use/client/middleware/__init__.py +50 -0
  47. mcp_use/client/middleware/logging.py +31 -0
  48. mcp_use/client/middleware/metrics.py +314 -0
  49. mcp_use/client/middleware/middleware.py +266 -0
  50. mcp_use/client/session.py +162 -0
  51. mcp_use/client/task_managers/__init__.py +20 -0
  52. mcp_use/client/task_managers/base.py +145 -0
  53. mcp_use/client/task_managers/sse.py +84 -0
  54. mcp_use/client/task_managers/stdio.py +69 -0
  55. mcp_use/client/task_managers/streamable_http.py +86 -0
  56. mcp_use/client/task_managers/websocket.py +68 -0
  57. mcp_use/client.py +12 -344
  58. mcp_use/config.py +20 -97
  59. mcp_use/connectors/.deprecated +0 -0
  60. mcp_use/connectors/__init__.py +46 -20
  61. mcp_use/connectors/base.py +12 -455
  62. mcp_use/connectors/http.py +13 -300
  63. mcp_use/connectors/sandbox.py +13 -306
  64. mcp_use/connectors/stdio.py +13 -104
  65. mcp_use/connectors/utils.py +15 -8
  66. mcp_use/connectors/websocket.py +13 -252
  67. mcp_use/exceptions.py +33 -18
  68. mcp_use/logging.py +1 -1
  69. mcp_use/managers/.deprecated +0 -0
  70. mcp_use/managers/__init__.py +56 -17
  71. mcp_use/managers/base.py +13 -31
  72. mcp_use/managers/server_manager.py +13 -119
  73. mcp_use/managers/tools/__init__.py +45 -15
  74. mcp_use/managers/tools/base_tool.py +5 -16
  75. mcp_use/managers/tools/connect_server.py +5 -67
  76. mcp_use/managers/tools/disconnect_server.py +5 -41
  77. mcp_use/managers/tools/get_active_server.py +5 -26
  78. mcp_use/managers/tools/list_servers_tool.py +5 -51
  79. mcp_use/managers/tools/search_tools.py +17 -321
  80. mcp_use/middleware/.deprecated +0 -0
  81. mcp_use/middleware/__init__.py +89 -50
  82. mcp_use/middleware/logging.py +14 -26
  83. mcp_use/middleware/metrics.py +30 -303
  84. mcp_use/middleware/middleware.py +39 -246
  85. mcp_use/session.py +13 -149
  86. mcp_use/task_managers/.deprecated +0 -0
  87. mcp_use/task_managers/__init__.py +48 -20
  88. mcp_use/task_managers/base.py +13 -140
  89. mcp_use/task_managers/sse.py +13 -79
  90. mcp_use/task_managers/stdio.py +13 -64
  91. mcp_use/task_managers/streamable_http.py +15 -81
  92. mcp_use/task_managers/websocket.py +13 -63
  93. mcp_use/telemetry/events.py +58 -0
  94. mcp_use/telemetry/telemetry.py +71 -1
  95. mcp_use/telemetry/utils.py +1 -1
  96. mcp_use/types/.deprecated +0 -0
  97. mcp_use/types/sandbox.py +13 -18
  98. {mcp_use-1.3.12.dist-info → mcp_use-1.4.0.dist-info}/METADATA +68 -43
  99. mcp_use-1.4.0.dist-info/RECORD +111 -0
  100. mcp_use/cli.py +0 -581
  101. mcp_use-1.3.12.dist-info/RECORD +0 -64
  102. mcp_use-1.3.12.dist-info/licenses/LICENSE +0 -21
  103. /mcp_use/{observability → agents/observability}/__init__.py +0 -0
  104. /mcp_use/{observability → agents/observability}/callbacks_manager.py +0 -0
  105. /mcp_use/{observability → agents/observability}/laminar.py +0 -0
  106. /mcp_use/{observability → agents/observability}/langfuse.py +0 -0
  107. {mcp_use-1.3.12.dist-info → mcp_use-1.4.0.dist-info}/WHEEL +0 -0
  108. {mcp_use-1.3.12.dist-info → mcp_use-1.4.0.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,4 @@
1
- from langchain.schema import SystemMessage
1
+ from langchain_core.messages import SystemMessage
2
2
  from langchain_core.tools import BaseTool
3
3
 
4
4
 
mcp_use/agents/remote.py CHANGED
@@ -9,10 +9,10 @@ from typing import Any, TypeVar
9
9
  from uuid import UUID
10
10
 
11
11
  import httpx
12
- from langchain.schema import BaseMessage
12
+ from langchain_core.messages import BaseMessage
13
13
  from pydantic import BaseModel
14
14
 
15
- from ..logging import logger
15
+ from mcp_use.logging import logger
16
16
 
17
17
  T = TypeVar("T", bound=BaseModel)
18
18
 
@@ -282,6 +282,7 @@ class RemoteAgent:
282
282
  if event.startswith("0:"): # Text event
283
283
  try:
284
284
  text_data = json.loads(event[2:]) # Remove "0:" prefix
285
+ # Normal text accumulation
285
286
  if final_result is None:
286
287
  final_result = ""
287
288
  final_result += text_data
@@ -308,6 +309,18 @@ class RemoteAgent:
308
309
  except json.JSONDecodeError as e:
309
310
  raise RuntimeError("Agent execution failed with unknown error") from e
310
311
 
312
+ elif event.startswith("f:"): # Structured final event
313
+ try:
314
+ structured_data = json.loads(event[2:]) # Remove "f:" prefix
315
+ logger.info(f"📋 [{self.chat_id}] Received structured final event")
316
+
317
+ # Replace accumulated text with structured output
318
+ final_result = structured_data
319
+ logger.info(f"📋 [{self.chat_id}] Replaced accumulated text with structured output")
320
+ except json.JSONDecodeError:
321
+ logger.warning(f"Failed to parse structured final event: {event[:100]}")
322
+ continue
323
+
311
324
  # Log completion of stream consumption
312
325
  logger.info(f"Stream consumption complete. Finished: {finished}, Steps taken: {steps_taken}")
313
326
 
File without changes
mcp_use/auth/__init__.py CHANGED
@@ -1,6 +1,21 @@
1
- """Authentication support for MCP clients."""
1
+ # mcp_use/auth/__init__.py
2
+ import warnings
2
3
 
3
- from .bearer import BearerAuth
4
- from .oauth import OAuth
4
+ from typing_extensions import deprecated
5
5
 
6
- __all__ = ["BearerAuth", "OAuth"]
6
+ from mcp_use.client.auth import BearerAuth as _BearerAuth
7
+ from mcp_use.client.auth import OAuth as _OAuth
8
+
9
+ warnings.warn(
10
+ "mcp_use.auth is deprecated. Use mcp_use.client.auth. This import will be removed in version 1.4.0",
11
+ DeprecationWarning,
12
+ stacklevel=2,
13
+ )
14
+
15
+
16
+ @deprecated("Use mcp_use.client.auth.BearerAuth")
17
+ class BearerAuth(_BearerAuth): ...
18
+
19
+
20
+ @deprecated("Use mcp_use.client.auth.OAuth")
21
+ class OAuth(_OAuth): ...
mcp_use/auth/bearer.py CHANGED
@@ -1,17 +1,16 @@
1
- """Bearer token authentication support."""
1
+ # mcp_use/auth/bearer.py
2
+ import warnings
2
3
 
3
- from collections.abc import Generator
4
+ from typing_extensions import deprecated
4
5
 
5
- import httpx
6
- from pydantic import BaseModel, SecretStr
6
+ from mcp_use.client.auth.bearer import BearerAuth as _BearerAuth
7
7
 
8
+ warnings.warn(
9
+ "mcp_use.auth.bearer is deprecated. Use mcp_use.client.auth.bearer. This import will be removed in version 1.4.0",
10
+ DeprecationWarning,
11
+ stacklevel=2,
12
+ )
8
13
 
9
- class BearerAuth(httpx.Auth, BaseModel):
10
- """Bearer token authentication for HTTP requests."""
11
14
 
12
- token: SecretStr
13
-
14
- def auth_flow(self, request: httpx.Request) -> Generator[httpx.Request, httpx.Response, None]:
15
- """Apply bearer token authentication to the request."""
16
- request.headers["Authorization"] = f"Bearer {self.token.get_secret_value()}"
17
- yield request
15
+ @deprecated("Use mcp_use.client.auth.bearer.BearerAuth")
16
+ class BearerAuth(_BearerAuth): ...