mcp-use 1.0.3__py3-none-any.whl → 1.1.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.

@@ -112,7 +112,7 @@ class LangChainAgent:
112
112
  # Recreate the agent with the new system message if it exists
113
113
  if self.agent and self.tools:
114
114
  self.agent = self._create_agent()
115
- logger.info("Agent recreated with new system message")
115
+ logger.debug("Agent recreated with new system message")
116
116
 
117
117
  async def initialize(self) -> None:
118
118
  """Initialize the agent and its tools."""
@@ -181,7 +181,7 @@ class LangChainAgent:
181
181
  Raises:
182
182
  ToolException: If tool execution fails.
183
183
  """
184
- logger.info(f'MCP tool: "{self.name}" received input: {kwargs}')
184
+ logger.debug(f'MCP tool: "{self.name}" received input: {kwargs}')
185
185
 
186
186
  try:
187
187
  tool_result: CallToolResult = await self.connector.call_tool(
@@ -207,7 +207,7 @@ class LangChainAgent:
207
207
  tools.append(McpToLangChainAdapter())
208
208
 
209
209
  # Log available tools for debugging
210
- logger.info(f"Available tools: {[tool.name for tool in tools]}")
210
+ logger.debug(f"Available tools: {[tool.name for tool in tools]}")
211
211
  return tools
212
212
 
213
213
  def _create_agent(self) -> AgentExecutor:
@@ -209,7 +209,7 @@ class MCPAgent:
209
209
  # If the agent is already initialized, we need to reinitialize it
210
210
  # to apply the changes to the available tools
211
211
  if self._initialized:
212
- logger.info(
212
+ logger.debug(
213
213
  "Agent already initialized. Changes will take effect on next initialization."
214
214
  )
215
215
  # We don't automatically reinitialize here as it could be disruptive
@@ -254,11 +254,11 @@ class MCPAgent:
254
254
  try:
255
255
  # Initialize if needed
256
256
  if manage_connector and (not self._initialized or not self._agent):
257
- logger.info("Initializing agent before running query")
257
+ logger.debug("Initializing agent before running query")
258
258
  await self.initialize()
259
259
  initialized_here = True
260
260
  elif not self._initialized and self.auto_initialize:
261
- logger.info("Auto-initializing agent before running query")
261
+ logger.debug("Auto-initializing agent before running query")
262
262
  await self.initialize()
263
263
  initialized_here = True
264
264
 
@@ -289,7 +289,7 @@ class MCPAgent:
289
289
  # Other message types can be handled here if needed
290
290
 
291
291
  # Run the query with the specified max_steps or default
292
- logger.info(f"Running query with max_steps={max_steps or self.max_steps}")
292
+ logger.debug(f"Running query with max_steps={max_steps or self.max_steps}")
293
293
  result = await self._agent.run(
294
294
  query=query,
295
295
  max_steps=max_steps,
@@ -307,7 +307,7 @@ class MCPAgent:
307
307
  # If we initialized in this method and there was an error,
308
308
  # make sure to clean up
309
309
  if initialized_here and manage_connector:
310
- logger.info("Cleaning up resources after initialization error")
310
+ logger.debug("Cleaning up resources after initialization error")
311
311
  await self.close()
312
312
  raise
313
313
 
@@ -315,7 +315,7 @@ class MCPAgent:
315
315
  # Clean up resources if we're managing the connector and
316
316
  # we're not using a client that manages sessions
317
317
  if manage_connector and not self.client and not initialized_here:
318
- logger.info("Closing agent after query completion")
318
+ logger.debug("Closing agent after query completion")
319
319
  await self.close()
320
320
 
321
321
  async def close(self) -> None:
@@ -338,7 +338,7 @@ class MCPAgent:
338
338
  await connector.disconnect()
339
339
 
340
340
  self._initialized = False
341
- logger.info("Agent closed successfully")
341
+ logger.debug("Agent closed successfully")
342
342
 
343
343
  except Exception as e:
344
344
  logger.error(f"Error during agent closure: {e}")
mcp_use/client.py CHANGED
@@ -214,7 +214,7 @@ class MCPClient:
214
214
 
215
215
  try:
216
216
  # Disconnect from the session
217
- logger.info(f"Closing session for server '{server_name}'")
217
+ logger.debug(f"Closing session for server '{server_name}'")
218
218
  await session.disconnect()
219
219
  except Exception as e:
220
220
  logger.error(f"Error closing session for server '{server_name}': {e}")
@@ -237,7 +237,7 @@ class MCPClient:
237
237
 
238
238
  for server_name in server_names:
239
239
  try:
240
- logger.info(f"Closing session for server '{server_name}'")
240
+ logger.debug(f"Closing session for server '{server_name}'")
241
241
  await self.close_session(server_name)
242
242
  except Exception as e:
243
243
  error_msg = f"Failed to close session for server '{server_name}': {e}"
@@ -248,4 +248,4 @@ class MCPClient:
248
248
  if errors:
249
249
  logger.error(f"Encountered {len(errors)} errors while closing sessions")
250
250
  else:
251
- logger.info("All sessions closed successfully")
251
+ logger.debug("All sessions closed successfully")
@@ -39,10 +39,10 @@ class BaseConnector(ABC):
39
39
  logger.debug("Not connected to MCP implementation")
40
40
  return
41
41
 
42
- logger.info("Disconnecting from MCP implementation")
42
+ logger.debug("Disconnecting from MCP implementation")
43
43
  await self._cleanup_resources()
44
44
  self._connected = False
45
- logger.info("Disconnected from MCP implementation")
45
+ logger.debug("Disconnected from MCP implementation")
46
46
 
47
47
  async def _cleanup_resources(self) -> None:
48
48
  """Clean up all resources associated with this connector."""
@@ -83,7 +83,7 @@ class BaseConnector(ABC):
83
83
  if not self.client:
84
84
  raise RuntimeError("MCP client is not connected")
85
85
 
86
- logger.info("Initializing MCP session")
86
+ logger.debug("Initializing MCP session")
87
87
 
88
88
  # Initialize the session
89
89
  result = await self.client.initialize()
@@ -92,7 +92,7 @@ class BaseConnector(ABC):
92
92
  tools_result = await self.client.list_tools()
93
93
  self._tools = tools_result.tools
94
94
 
95
- logger.info(f"MCP session initialized with {len(self._tools)} tools")
95
+ logger.debug(f"MCP session initialized with {len(self._tools)} tools")
96
96
 
97
97
  return result
98
98
 
@@ -110,6 +110,7 @@ class BaseConnector(ABC):
110
110
 
111
111
  logger.debug(f"Calling tool '{name}' with arguments: {arguments}")
112
112
  result = await self.client.call_tool(name, arguments)
113
+ logger.debug(f"Tool '{name}' called with result: {result}")
113
114
  return result
114
115
 
115
116
  async def list_resources(self) -> list[dict[str, Any]]:
@@ -51,7 +51,7 @@ class HttpConnector(BaseConnector):
51
51
  logger.debug("Already connected to MCP implementation")
52
52
  return
53
53
 
54
- logger.info(f"Connecting to MCP implementation via HTTP/SSE: {self.base_url}")
54
+ logger.debug(f"Connecting to MCP implementation via HTTP/SSE: {self.base_url}")
55
55
  try:
56
56
  # Create the SSE connection URL
57
57
  sse_url = f"{self.base_url}"
@@ -68,7 +68,7 @@ class HttpConnector(BaseConnector):
68
68
 
69
69
  # Mark as connected
70
70
  self._connected = True
71
- logger.info(
71
+ logger.debug(
72
72
  f"Successfully connected to MCP implementation via HTTP/SSE: {self.base_url}"
73
73
  )
74
74
 
@@ -49,7 +49,7 @@ class StdioConnector(BaseConnector):
49
49
  logger.debug("Already connected to MCP implementation")
50
50
  return
51
51
 
52
- logger.info(f"Connecting to MCP implementation: {self.command}")
52
+ logger.debug(f"Connecting to MCP implementation: {self.command}")
53
53
  try:
54
54
  # Create server parameters
55
55
  server_params = StdioServerParameters(
@@ -66,7 +66,7 @@ class StdioConnector(BaseConnector):
66
66
 
67
67
  # Mark as connected
68
68
  self._connected = True
69
- logger.info(f"Successfully connected to MCP implementation: {self.command}")
69
+ logger.debug(f"Successfully connected to MCP implementation: {self.command}")
70
70
 
71
71
  except Exception as e:
72
72
  logger.error(f"Failed to connect to MCP implementation: {e}")
@@ -57,7 +57,7 @@ class WebSocketConnector(BaseConnector):
57
57
  logger.debug("Already connected to MCP implementation")
58
58
  return
59
59
 
60
- logger.info(f"Connecting to MCP implementation via WebSocket: {self.url}")
60
+ logger.debug(f"Connecting to MCP implementation via WebSocket: {self.url}")
61
61
  try:
62
62
  # Create and start the connection manager
63
63
  self._connection_manager = WebSocketConnectionManager(self.url, self.headers)
@@ -70,7 +70,7 @@ class WebSocketConnector(BaseConnector):
70
70
 
71
71
  # Mark as connected
72
72
  self._connected = True
73
- logger.info(f"Successfully connected to MCP implementation via WebSocket: {self.url}")
73
+ logger.debug(f"Successfully connected to MCP implementation via WebSocket: {self.url}")
74
74
 
75
75
  except Exception as e:
76
76
  logger.error(f"Failed to connect to MCP implementation via WebSocket: {e}")
@@ -117,10 +117,10 @@ class WebSocketConnector(BaseConnector):
117
117
  logger.debug("Not connected to MCP implementation")
118
118
  return
119
119
 
120
- logger.info("Disconnecting from MCP implementation")
120
+ logger.debug("Disconnecting from MCP implementation")
121
121
  await self._cleanup_resources()
122
122
  self._connected = False
123
- logger.info("Disconnected from MCP implementation")
123
+ logger.debug("Disconnected from MCP implementation")
124
124
 
125
125
  async def _cleanup_resources(self) -> None:
126
126
  """Clean up all resources associated with this connector."""
@@ -199,14 +199,14 @@ class WebSocketConnector(BaseConnector):
199
199
 
200
200
  async def initialize(self) -> dict[str, Any]:
201
201
  """Initialize the MCP session and return session information."""
202
- logger.info("Initializing MCP session")
202
+ logger.debug("Initializing MCP session")
203
203
  result = await self._send_request("initialize")
204
204
 
205
205
  # Get available tools
206
206
  tools_result = await self.list_tools()
207
207
  self._tools = [Tool(**tool) for tool in tools_result]
208
208
 
209
- logger.info(f"MCP session initialized with {len(self._tools)} tools")
209
+ logger.debug(f"MCP session initialized with {len(self._tools)} tools")
210
210
  return result
211
211
 
212
212
  async def list_tools(self) -> list[dict[str, Any]]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-use
3
- Version: 1.0.3
3
+ Version: 1.1.5
4
4
  Summary: MCP Library for LLMs
5
5
  Author-email: Pietro Zullo <pietro.zullo@gmail.com>
6
6
  License: MIT
@@ -56,6 +56,19 @@ Description-Content-Type: text/markdown
56
56
 
57
57
  💡 Let developers easily connect any LLM to tools like web browsing, file operations, and more.
58
58
 
59
+ # Features
60
+
61
+ ## ✨ Key Features
62
+
63
+ | Feature | Description |
64
+ |---------|-------------|
65
+ | 🔄 **Ease of use** | Create your first MCP capable agent you need only 6 lines of code |
66
+ | 🤖 **LLM Flexibility** | Works with any langchain supported LLM that supports tool calling (OpenAI, Anthropic, Groq, LLama etc.) |
67
+ | 🌐 **HTTP Support** | Direct connection to MCP servers running on specific HTTP ports |
68
+ | 🧩 **Multi-Server Support** | Use multiple MCP servers simultaneously in a single agent |
69
+ | 🛡️ **Tool Restrictions** | Restrict potentially dangerous tools like file system or network access |
70
+
71
+
59
72
  # Quick start
60
73
 
61
74
  With pip:
@@ -72,7 +85,30 @@ cd mcp-use
72
85
  pip install -e .
73
86
  ```
74
87
 
75
- Spin up your agent:
88
+ ### Installing LangChain Providers
89
+
90
+ mcp_use works with various LLM providers through LangChain. You'll need to install the appropriate LangChain provider package for your chosen LLM. For example:
91
+
92
+ ```bash
93
+ # For OpenAI
94
+ pip install langchain-openai
95
+
96
+ # For Anthropic
97
+ pip install langchain-anthropic
98
+
99
+ # For other providers, check the [LangChain chat models documentation](https://python.langchain.com/docs/integrations/chat/)
100
+ ```
101
+
102
+ and add your API keys for the provider you want to use to your `.env` file.
103
+
104
+ ```bash
105
+ OPENAI_API_KEY=
106
+ ANTHROPIC_API_KEY=
107
+ ```
108
+
109
+ > **Important**: Only models with tool calling capabilities can be used with mcp_use. Make sure your chosen model supports function calling or tool use.
110
+
111
+ ### Spin up your agent:
76
112
 
77
113
  ```python
78
114
  import asyncio
@@ -85,8 +121,21 @@ async def main():
85
121
  # Load environment variables
86
122
  load_dotenv()
87
123
 
88
- # Create MCPClient from config file
89
- client = MCPClient.from_config_file("browser_mcp.json")
124
+ # Create configuration dictionary
125
+ config = {
126
+ "mcpServers": {
127
+ "playwright": {
128
+ "command": "npx",
129
+ "args": ["@playwright/mcp@latest"],
130
+ "env": {
131
+ "DISPLAY": ":1"
132
+ }
133
+ }
134
+ }
135
+ }
136
+
137
+ # Create MCPClient from configuration dictionary
138
+ client = MCPClient.from_dict(config)
90
139
 
91
140
  # Create LLM
92
141
  llm = ChatOpenAI(model="gpt-4o")
@@ -96,7 +145,7 @@ async def main():
96
145
 
97
146
  # Run the query
98
147
  result = await agent.run(
99
- "Find the best restaurant in San Francisco USING GOOGLE SEARCH",
148
+ "Find the best restaurant in San Francisco",
100
149
  )
101
150
  print(f"\nResult: {result}")
102
151
 
@@ -104,6 +153,14 @@ if __name__ == "__main__":
104
153
  asyncio.run(main())
105
154
  ```
106
155
 
156
+ You can also add the servers configuration from a config file like this:
157
+
158
+ ```python
159
+ client = MCPClient.from_config_file(
160
+ os.path.join("browser_mcp.json")
161
+ )
162
+ ```
163
+
107
164
  Example configuration file (`browser_mcp.json`):
108
165
 
109
166
  ```json
@@ -120,15 +177,9 @@ Example configuration file (`browser_mcp.json`):
120
177
  }
121
178
  ```
122
179
 
123
- Add your API keys for the provider you want to use to your `.env` file.
124
-
125
- ```bash
126
- OPENAI_API_KEY=
127
- ANTHROPIC_API_KEY=
128
- ```
129
-
130
180
  For other settings, models, and more, check out the documentation.
131
181
 
182
+
132
183
  # Example Use Cases
133
184
 
134
185
  ## Web Browsing with Playwright
@@ -286,6 +337,55 @@ if __name__ == "__main__":
286
337
  asyncio.run(main())
287
338
  ```
288
339
 
340
+ ## HTTP Connection Example
341
+
342
+ MCP-Use now 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.
343
+
344
+ Here's an example of how to use the HTTP connection feature:
345
+
346
+ ```python
347
+ import asyncio
348
+ import os
349
+ from dotenv import load_dotenv
350
+ from langchain_openai import ChatOpenAI
351
+ from mcp_use import MCPAgent, MCPClient
352
+
353
+ async def main():
354
+ """Run the example using a configuration file."""
355
+ # Load environment variables
356
+ load_dotenv()
357
+
358
+ config = {
359
+ "mcpServers": {
360
+ "http": {
361
+ "url": "http://localhost:8931/sse"
362
+ }
363
+ }
364
+ }
365
+
366
+ # Create MCPClient from config file
367
+ client = MCPClient.from_dict(config)
368
+
369
+ # Create LLM
370
+ llm = ChatOpenAI(model="gpt-4o")
371
+
372
+ # Create agent with the client
373
+ agent = MCPAgent(llm=llm, client=client, max_steps=30)
374
+
375
+ # Run the query
376
+ result = await agent.run(
377
+ "Find the best restaurant in San Francisco USING GOOGLE SEARCH",
378
+ max_steps=30,
379
+ )
380
+ print(f"\nResult: {result}")
381
+
382
+ if __name__ == "__main__":
383
+ # Run the appropriate example
384
+ asyncio.run(main())
385
+ ```
386
+
387
+ This example demonstrates how to connect to an MCP server running on a specific HTTP port. Make sure to start your MCP server before running this example.
388
+
289
389
  # Multi-Server Support
290
390
 
291
391
  MCP-Use supports working with multiple MCP servers simultaneously, allowing you to combine tools from different servers in a single agent. This is useful for complex tasks that require multiple capabilities, such as web browsing combined with file operations or 3D modeling.
@@ -1,24 +1,24 @@
1
1
  mcp_use/__init__.py,sha256=PSoxLAu1GPjfIDPcZiJyI3k66MMS3lcfx5kERUgFb1o,723
2
- mcp_use/client.py,sha256=0rvlJBwvPD19sjDRtXfnp15-F1VHJlXWxLQNt9cHwPA,8275
2
+ mcp_use/client.py,sha256=RoOOpCzMCjpqkkyAIEDOVc6Sn_HsET1rbn_J_J778q4,8278
3
3
  mcp_use/config.py,sha256=O9V4pa-shZ2mPokRTrd7KZQ2GpuTcYBGUslefl1fosw,1653
4
4
  mcp_use/logging.py,sha256=2-hSB7ZWcHEx_OFHNg8GIbSGCZx3MW4mZGGWxi2Ew3E,2690
5
5
  mcp_use/session.py,sha256=Z4EZTUnQUX0QyGMzkJIrMRTX4SDk6qQUoBld408LIJE,3449
6
6
  mcp_use/agents/__init__.py,sha256=ukchMTqCOID6ikvLmJ-6sldWTVFIzztGQo4BX6QeQr8,312
7
7
  mcp_use/agents/base.py,sha256=bfuldi_89AbSbNc8KeTiCArRT9V62CNxHOWYkLHWjyA,1605
8
- mcp_use/agents/langchain_agent.py,sha256=5fml081T3meLkZxA8o29eLuMmITyr5EfkKMPGy9UgHA,10165
9
- mcp_use/agents/mcpagent.py,sha256=YF-ApIGM2lM8mOdeopr-hPlMRuNRNMQpJpg4gm9u6Ns,14183
8
+ mcp_use/agents/langchain_agent.py,sha256=7gHTxZ5kIfHy0qRDMTGKiek0OOlU-7yLd8ruoJPzTyY,10168
9
+ mcp_use/agents/mcpagent.py,sha256=5n0FbLrx30dc1afH75UW2s_R0p3nSssE2BrXYNfbygo,14190
10
10
  mcp_use/agents/prompts/default.py,sha256=tnwt9vOiVBhdpu-lIHhwEJo3rvE6EobPfUgS9JURBzg,941
11
11
  mcp_use/connectors/__init__.py,sha256=jnd-7pPPJMb0UNJ6aD9lInj5Tlamc8lA_mFyG8RWJpo,385
12
- mcp_use/connectors/base.py,sha256=TCLVNJdt6qrflmphgXOZhD6xPKQQegbGqe5REmcLYg0,4813
13
- mcp_use/connectors/http.py,sha256=nkF3hcioYpglwLOTR69WhU8zzLJbZDakgtQ8MsK-cMI,2835
14
- mcp_use/connectors/stdio.py,sha256=36yEY7hbFXgM7zju5BtLJl4cKAZNCXVRrTaU6YOttBI,2606
15
- mcp_use/connectors/websocket.py,sha256=4xqxl9UncrfU6NitvKfB80Hk2g7o0Gc0G5sm6sY3RAk,9534
12
+ mcp_use/connectors/base.py,sha256=5TcXB-I5zrwPtedB6dShceNucsK3wHBeGC2yDVq8X48,4885
13
+ mcp_use/connectors/http.py,sha256=2ZG5JxcK1WZ4jkTfTir6bEQLMxXBTPHyi0s42RHGeFs,2837
14
+ mcp_use/connectors/stdio.py,sha256=MTzsqmVVihACUKngE-g5BignK3jAFds2CFv3aSzbJfs,2608
15
+ mcp_use/connectors/websocket.py,sha256=LeU53YI3zjbwKq5GzFRziqA_z9Dn5qACiNyxWDrn2ns,9540
16
16
  mcp_use/task_managers/__init__.py,sha256=4dgW5N61iiPLpwjU2rrn_uqrL8mmDJFDaF9Lukzk65A,486
17
17
  mcp_use/task_managers/base.py,sha256=ksNdxTwq8N-zqymxVoKGnWXq9iqkLYC61uB91o6Mh-4,4888
18
18
  mcp_use/task_managers/sse.py,sha256=WysmjwqRI3meXMZY_F4y9tSBMvSiUZfTJQfitM5l6jQ,2529
19
19
  mcp_use/task_managers/stdio.py,sha256=DEISpXv4mo3d5a-WT8lkWbrXJwUh7QW0nMT_IM3fHGg,2269
20
20
  mcp_use/task_managers/websocket.py,sha256=ZbCqdGgzCRtsXzRGFws-f2OzH8cPAkN4sJNDwEpRmCc,1915
21
- mcp_use-1.0.3.dist-info/METADATA,sha256=3HbO5h9azPZyPz6HmK0rWZEB7pdxh4U3jCSEQKtGdtc,11043
22
- mcp_use-1.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- mcp_use-1.0.3.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
24
- mcp_use-1.0.3.dist-info/RECORD,,
21
+ mcp_use-1.1.5.dist-info/METADATA,sha256=A-VlMFyFTy0oSs8RpWCEd7cfuo6ObqQrc4O4QdRf67Q,14004
22
+ mcp_use-1.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ mcp_use-1.1.5.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
24
+ mcp_use-1.1.5.dist-info/RECORD,,