mcp-use 1.3.4__py3-none-any.whl → 1.3.6__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.
- mcp_use/agents/mcpagent.py +4 -0
- mcp_use/client.py +1 -3
- mcp_use/connectors/base.py +16 -12
- mcp_use/connectors/http.py +26 -1
- {mcp_use-1.3.4.dist-info → mcp_use-1.3.6.dist-info}/METADATA +1 -1
- {mcp_use-1.3.4.dist-info → mcp_use-1.3.6.dist-info}/RECORD +8 -8
- {mcp_use-1.3.4.dist-info → mcp_use-1.3.6.dist-info}/WHEEL +0 -0
- {mcp_use-1.3.4.dist-info → mcp_use-1.3.6.dist-info}/licenses/LICENSE +0 -0
mcp_use/agents/mcpagent.py
CHANGED
|
@@ -589,6 +589,10 @@ class MCPAgent:
|
|
|
589
589
|
success = True
|
|
590
590
|
start_time = time.time()
|
|
591
591
|
generator = self.stream(query, max_steps, manage_connector, external_history, track_execution=False)
|
|
592
|
+
error = None
|
|
593
|
+
steps_taken = 0
|
|
594
|
+
tools_used_names = []
|
|
595
|
+
result = None
|
|
592
596
|
try:
|
|
593
597
|
result, steps_taken, tools_used_names = await self._consume_and_return(generator)
|
|
594
598
|
except Exception as e:
|
mcp_use/client.py
CHANGED
|
@@ -189,9 +189,7 @@ class MCPClient:
|
|
|
189
189
|
|
|
190
190
|
# Create sessions for all servers
|
|
191
191
|
for name in servers:
|
|
192
|
-
|
|
193
|
-
if auto_initialize:
|
|
194
|
-
await session.initialize()
|
|
192
|
+
await self.create_session(name, auto_initialize)
|
|
195
193
|
|
|
196
194
|
return self.sessions
|
|
197
195
|
|
mcp_use/connectors/base.py
CHANGED
|
@@ -31,6 +31,7 @@ class BaseConnector(ABC):
|
|
|
31
31
|
self._resources: list[Resource] | None = None
|
|
32
32
|
self._prompts: list[Prompt] | None = None
|
|
33
33
|
self._connected = False
|
|
34
|
+
self._initialized = False # Track if client_session.initialize() has been called
|
|
34
35
|
self.auto_reconnect = True # Whether to automatically reconnect on connection loss (not configurable for now)
|
|
35
36
|
|
|
36
37
|
@abstractmethod
|
|
@@ -87,6 +88,7 @@ class BaseConnector(ABC):
|
|
|
87
88
|
self._tools = None
|
|
88
89
|
self._resources = None
|
|
89
90
|
self._prompts = None
|
|
91
|
+
self._initialized = False # Reset initialization flag
|
|
90
92
|
|
|
91
93
|
if errors:
|
|
92
94
|
logger.warning(f"Encountered {len(errors)} errors during resource cleanup")
|
|
@@ -96,38 +98,40 @@ class BaseConnector(ABC):
|
|
|
96
98
|
if not self.client_session:
|
|
97
99
|
raise RuntimeError("MCP client is not connected")
|
|
98
100
|
|
|
99
|
-
|
|
101
|
+
# Check if already initialized
|
|
102
|
+
if self._initialized:
|
|
103
|
+
return {"status": "already_initialized"}
|
|
100
104
|
|
|
101
105
|
# Initialize the session
|
|
102
106
|
result = await self.client_session.initialize()
|
|
107
|
+
self._initialized = True # Mark as initialized
|
|
103
108
|
|
|
104
109
|
server_capabilities = result.capabilities
|
|
105
110
|
|
|
106
111
|
if server_capabilities.tools:
|
|
107
|
-
# Get available tools
|
|
108
|
-
tools_result = await self.list_tools()
|
|
109
|
-
self._tools = tools_result
|
|
112
|
+
# Get available tools directly from client session
|
|
113
|
+
tools_result = await self.client_session.list_tools()
|
|
114
|
+
self._tools = tools_result.tools if tools_result else []
|
|
110
115
|
else:
|
|
111
116
|
self._tools = []
|
|
112
117
|
|
|
113
118
|
if server_capabilities.resources:
|
|
114
|
-
# Get available resources
|
|
115
|
-
resources_result = await self.list_resources()
|
|
116
|
-
self._resources = resources_result
|
|
119
|
+
# Get available resources directly from client session
|
|
120
|
+
resources_result = await self.client_session.list_resources()
|
|
121
|
+
self._resources = resources_result.resources if resources_result else []
|
|
117
122
|
else:
|
|
118
123
|
self._resources = []
|
|
119
124
|
|
|
120
125
|
if server_capabilities.prompts:
|
|
121
|
-
# Get available prompts
|
|
122
|
-
prompts_result = await self.list_prompts()
|
|
123
|
-
self._prompts = prompts_result
|
|
126
|
+
# Get available prompts directly from client session
|
|
127
|
+
prompts_result = await self.client_session.list_prompts()
|
|
128
|
+
self._prompts = prompts_result.prompts if prompts_result else []
|
|
124
129
|
else:
|
|
125
130
|
self._prompts = []
|
|
126
131
|
|
|
127
132
|
logger.debug(
|
|
128
133
|
f"MCP session initialized with {len(self._tools)} tools, "
|
|
129
|
-
|
|
130
|
-
f"and {len(self._prompts)} prompts"
|
|
134
|
+
"{len(self._resources)} resources, and {len(self._prompts)} prompts"
|
|
131
135
|
)
|
|
132
136
|
|
|
133
137
|
return result
|
mcp_use/connectors/http.py
CHANGED
|
@@ -81,12 +81,37 @@ class HttpConnector(BaseConnector):
|
|
|
81
81
|
|
|
82
82
|
try:
|
|
83
83
|
# Try to initialize - this is where streamable HTTP vs SSE difference should show up
|
|
84
|
-
await test_client.initialize()
|
|
84
|
+
result = await test_client.initialize()
|
|
85
85
|
|
|
86
86
|
# If we get here, streamable HTTP works
|
|
87
87
|
|
|
88
88
|
self.client_session = test_client
|
|
89
89
|
self.transport_type = "streamable HTTP"
|
|
90
|
+
self._initialized = True # Mark as initialized since we just called initialize()
|
|
91
|
+
|
|
92
|
+
# Populate tools, resources, and prompts since we've initialized
|
|
93
|
+
server_capabilities = result.capabilities
|
|
94
|
+
|
|
95
|
+
if server_capabilities.tools:
|
|
96
|
+
# Get available tools directly from client session
|
|
97
|
+
tools_result = await self.client_session.list_tools()
|
|
98
|
+
self._tools = tools_result.tools if tools_result else []
|
|
99
|
+
else:
|
|
100
|
+
self._tools = []
|
|
101
|
+
|
|
102
|
+
if server_capabilities.resources:
|
|
103
|
+
# Get available resources directly from client session
|
|
104
|
+
resources_result = await self.client_session.list_resources()
|
|
105
|
+
self._resources = resources_result.resources if resources_result else []
|
|
106
|
+
else:
|
|
107
|
+
self._resources = []
|
|
108
|
+
|
|
109
|
+
if server_capabilities.prompts:
|
|
110
|
+
# Get available prompts directly from client session
|
|
111
|
+
prompts_result = await self.client_session.list_prompts()
|
|
112
|
+
self._prompts = prompts_result.prompts if prompts_result else []
|
|
113
|
+
else:
|
|
114
|
+
self._prompts = []
|
|
90
115
|
|
|
91
116
|
except Exception as init_error:
|
|
92
117
|
# Clean up the test client
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
mcp_use/__init__.py,sha256=I3gFxw6Id45RksUBIZS1kxBW3ItjFXuAfoReJabpnW0,1055
|
|
2
|
-
mcp_use/client.py,sha256=
|
|
2
|
+
mcp_use/client.py,sha256=9u_GZxsyVoZY_g1dWGK8JiLmTatY6YvwGb4IM8idYZs,9391
|
|
3
3
|
mcp_use/config.py,sha256=jRjTVNMxi7pkqFHMJhzSWpwukE4PbdYU8Pe_IZ33sYI,2433
|
|
4
4
|
mcp_use/logging.py,sha256=CRtkPwR-bkXK_kQ0QOL86RikMWOHzEOi7A8VRHkNsZw,4270
|
|
5
5
|
mcp_use/session.py,sha256=4kwcB_IkTt_3FiBSTI1H17KhL1W_6N5oai3HTxFrTH4,2496
|
|
@@ -9,12 +9,12 @@ mcp_use/adapters/base.py,sha256=U1z_UzojC-bytb4ZuKTRpEgEp-2F_BVBgqEXbUqLYB4,6901
|
|
|
9
9
|
mcp_use/adapters/langchain_adapter.py,sha256=LdlpRyLORhl8NZvtAmisgPelXkhEbBErSNdGHb8SF18,10860
|
|
10
10
|
mcp_use/agents/__init__.py,sha256=N3eVYP2PxqNO2KcQv5fY8UMUX2W3eLTNkkzuFIJ1DUA,261
|
|
11
11
|
mcp_use/agents/base.py,sha256=EN-dRbwOi9vIqofFg3jmi5yT2VKlwEr9Cwi1DZgB3eE,1591
|
|
12
|
-
mcp_use/agents/mcpagent.py,sha256=
|
|
12
|
+
mcp_use/agents/mcpagent.py,sha256=K3gKlPvqIPiniifi46Xs82_D2YKNO-Vn4BTTH55LPbI,35753
|
|
13
13
|
mcp_use/agents/prompts/system_prompt_builder.py,sha256=E86STmxcl2Ic763_114awNqFB2RyLrQlbvgRmJajQjI,4116
|
|
14
14
|
mcp_use/agents/prompts/templates.py,sha256=AZKrGWuI516C-PmyOPvxDBibNdqJtN24sOHTGR06bi4,1933
|
|
15
15
|
mcp_use/connectors/__init__.py,sha256=cUF4yT0bNr8qeLkSzg28SHueiV5qDaHEB1l1GZ2K0dc,536
|
|
16
|
-
mcp_use/connectors/base.py,sha256=
|
|
17
|
-
mcp_use/connectors/http.py,sha256=
|
|
16
|
+
mcp_use/connectors/base.py,sha256=GnI2WCrcxjOaB0R6Hj9pTpAZ0I1YRwkz1gGt-tvuZa0,12609
|
|
17
|
+
mcp_use/connectors/http.py,sha256=oZbLLVDNwUaY6EwK2rVnjoZEKsBLf5-AXtPvGtbMmwc,7559
|
|
18
18
|
mcp_use/connectors/sandbox.py,sha256=cnybcNW55k-S0hUtRR1M3KcGXwnaeDMVm8wDTsfF1Mk,10875
|
|
19
19
|
mcp_use/connectors/stdio.py,sha256=rnJoLaHf1cIjk1KqfxfSsUs-iGTJ7KZonxgIc3kXeCM,2791
|
|
20
20
|
mcp_use/connectors/utils.py,sha256=zQ8GdNQx0Twz3by90BoU1RsWPf9wODGof4K3-NxPXeA,366
|
|
@@ -43,7 +43,7 @@ mcp_use/telemetry/events.py,sha256=K5xqbmkum30r4gM2PWtTiUWGF8oZzGZw2DYwco1RfOQ,3
|
|
|
43
43
|
mcp_use/telemetry/telemetry.py,sha256=ck2MDFMtooafriR1W_zi41dWq-0O-ucF89pCkdkyc9E,11724
|
|
44
44
|
mcp_use/telemetry/utils.py,sha256=kDVTqt2oSeWNJbnTOlXOehr2yFO0PMyx2UGkrWkfJiw,1769
|
|
45
45
|
mcp_use/types/sandbox.py,sha256=opJ9r56F1FvaqVvPovfAj5jZbsOexgwYx5wLgSlN8_U,712
|
|
46
|
-
mcp_use-1.3.
|
|
47
|
-
mcp_use-1.3.
|
|
48
|
-
mcp_use-1.3.
|
|
49
|
-
mcp_use-1.3.
|
|
46
|
+
mcp_use-1.3.6.dist-info/METADATA,sha256=Mm5tZfT6AQmckx_9d75uLPYwVaM2K_a4MG4L64DPblY,28534
|
|
47
|
+
mcp_use-1.3.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
48
|
+
mcp_use-1.3.6.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
|
|
49
|
+
mcp_use-1.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|