mcp-use 1.3.4__py3-none-any.whl → 1.3.5__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/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
- session = await self.create_session(name, auto_initialize)
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
 
@@ -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
- logger.debug("Initializing MCP session")
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 or []
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 or []
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 or []
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
- f"{len(self._resources)} resources, "
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
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-use
3
- Version: 1.3.4
3
+ Version: 1.3.5
4
4
  Summary: MCP Library for LLMs
5
5
  Author-email: Pietro Zullo <pietro.zullo@gmail.com>
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  mcp_use/__init__.py,sha256=I3gFxw6Id45RksUBIZS1kxBW3ItjFXuAfoReJabpnW0,1055
2
- mcp_use/client.py,sha256=sAyZY6n5XHRW5dWKinfMZ-ovnUYi0s4u7T1mFfEHGLs,9476
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
@@ -13,8 +13,8 @@ mcp_use/agents/mcpagent.py,sha256=ke912HbpkXxcv1DpjiFTEg3hoIEMSFlTS62IRxYaTDs,35
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=c0Vj_hP9sw9YFHlap_W8OhGQy67OIpn-IpAdD0j3FD4,12128
17
- mcp_use/connectors/http.py,sha256=Aw0DVQN-7fYebDKuX3bvlH9GAFS7Mq9CM_HylXdNqEI,6274
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.4.dist-info/METADATA,sha256=_RG0jvtG9ti0jnn2qQ8YfXZ1s0-_VdfniJ9EFNaJePY,28534
47
- mcp_use-1.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
48
- mcp_use-1.3.4.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
49
- mcp_use-1.3.4.dist-info/RECORD,,
46
+ mcp_use-1.3.5.dist-info/METADATA,sha256=dMpM6hZi0cuGyKdbTVB5_YuUJhcZSIeBNn_riJSkbZ0,28534
47
+ mcp_use-1.3.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
48
+ mcp_use-1.3.5.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
49
+ mcp_use-1.3.5.dist-info/RECORD,,