mcp-use 0.0.4__py3-none-any.whl → 0.0.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/__init__.py +5 -2
- mcp_use/agents/mcpagent.py +3 -1
- mcp_use/agents/prompts/default.py +15 -4
- mcp_use/config.py +0 -34
- {mcp_use-0.0.4.dist-info → mcp_use-0.0.6.dist-info}/METADATA +22 -57
- {mcp_use-0.0.4.dist-info → mcp_use-0.0.6.dist-info}/RECORD +8 -8
- {mcp_use-0.0.4.dist-info → mcp_use-0.0.6.dist-info}/WHEEL +0 -0
- {mcp_use-0.0.4.dist-info → mcp_use-0.0.6.dist-info}/licenses/LICENSE +0 -0
mcp_use/__init__.py
CHANGED
|
@@ -5,14 +5,17 @@ This library provides a unified interface for connecting different LLMs
|
|
|
5
5
|
to MCP tools through existing LangChain adapters.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
from importlib.metadata import version
|
|
9
|
+
|
|
8
10
|
from .agents.mcpagent import MCPAgent
|
|
9
11
|
from .client import MCPClient
|
|
10
|
-
from .config import
|
|
12
|
+
from .config import load_config_file
|
|
11
13
|
from .connectors import BaseConnector, HttpConnector, StdioConnector, WebSocketConnector
|
|
12
14
|
from .logging import logger
|
|
13
15
|
from .session import MCPSession
|
|
14
16
|
|
|
15
|
-
__version__ = "
|
|
17
|
+
__version__ = version("mcp-use")
|
|
18
|
+
|
|
16
19
|
__all__ = [
|
|
17
20
|
"MCPAgent",
|
|
18
21
|
"MCPClient",
|
mcp_use/agents/mcpagent.py
CHANGED
|
@@ -124,7 +124,9 @@ class MCPAgent:
|
|
|
124
124
|
# Generate tool descriptions
|
|
125
125
|
tool_descriptions = []
|
|
126
126
|
for tool in tools:
|
|
127
|
-
|
|
127
|
+
# Escape curly braces in the description by doubling them
|
|
128
|
+
# (sometimes e.g. blender mcp they are used in the description)
|
|
129
|
+
description = f"- {tool.name}: {tool.description.replace('{', '{{').replace('}', '}}')}"
|
|
128
130
|
tool_descriptions.append(description)
|
|
129
131
|
|
|
130
132
|
# Format the system prompt template with tool descriptions
|
|
@@ -3,9 +3,20 @@ DEFAULT_SYSTEM_PROMPT_TEMPLATE = """You are an assistant with access to these to
|
|
|
3
3
|
{tool_descriptions}
|
|
4
4
|
|
|
5
5
|
Proactively use these tools to:
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
6
|
+
- Retrieve and analyze information relevant to user requests
|
|
7
|
+
- Process and transform data in various formats
|
|
8
|
+
- Perform computations and generate insights
|
|
9
|
+
- Execute multi-step workflows by combining tools as needed
|
|
10
|
+
- Interact with external systems when authorized
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
When appropriate, use available tools rather than relying on your built-in knowledge alone.
|
|
13
|
+
Your tools enable you to perform tasks that would otherwise be beyond your capabilities.
|
|
14
|
+
|
|
15
|
+
For optimal assistance:
|
|
16
|
+
1. Identify when a tool can help address the user's request
|
|
17
|
+
2. Select the most appropriate tool(s) for the task
|
|
18
|
+
3. Apply tools in the correct sequence when multiple tools are needed
|
|
19
|
+
4. Clearly communicate your process and findings
|
|
20
|
+
|
|
21
|
+
Remember that you have real capabilities through your tools - use them confidently when needed.
|
|
11
22
|
"""
|
mcp_use/config.py
CHANGED
|
@@ -8,7 +8,6 @@ import json
|
|
|
8
8
|
from typing import Any
|
|
9
9
|
|
|
10
10
|
from .connectors import BaseConnector, HttpConnector, StdioConnector, WebSocketConnector
|
|
11
|
-
from .session import MCPSession
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
def load_config_file(filepath: str) -> dict[str, Any]:
|
|
@@ -58,36 +57,3 @@ def create_connector_from_config(server_config: dict[str, Any]) -> BaseConnector
|
|
|
58
57
|
)
|
|
59
58
|
|
|
60
59
|
raise ValueError("Cannot determine connector type from config")
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def create_session_from_config(
|
|
64
|
-
filepath: str,
|
|
65
|
-
server_name: str | None = None,
|
|
66
|
-
) -> MCPSession:
|
|
67
|
-
"""Create an MCPSession from a configuration file.
|
|
68
|
-
|
|
69
|
-
Args:
|
|
70
|
-
filepath: Path to the configuration file
|
|
71
|
-
server_name: Name of the server to use from config, uses first if None
|
|
72
|
-
|
|
73
|
-
Returns:
|
|
74
|
-
Configured MCPSession instance
|
|
75
|
-
"""
|
|
76
|
-
config = load_config_file(filepath)
|
|
77
|
-
|
|
78
|
-
# Get server config
|
|
79
|
-
servers = config.get("mcpServers", {})
|
|
80
|
-
if not servers:
|
|
81
|
-
raise ValueError("No MCP servers defined in config")
|
|
82
|
-
|
|
83
|
-
# If server_name not specified, use the first one
|
|
84
|
-
if not server_name:
|
|
85
|
-
server_name = next(iter(servers.keys()))
|
|
86
|
-
|
|
87
|
-
if server_name not in servers:
|
|
88
|
-
raise ValueError(f"Server '{server_name}' not found in config")
|
|
89
|
-
|
|
90
|
-
server_config = servers[server_name]
|
|
91
|
-
connector = create_connector_from_config(server_config)
|
|
92
|
-
|
|
93
|
-
return MCPSession(connector)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.0.
|
|
2
|
+
Name: mcp-use
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: MCP Library for LLMs
|
|
5
5
|
Author-email: Pietro Zullo <pietro.zullo@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -38,16 +38,20 @@ Requires-Dist: openai>=1.10.0; extra == 'openai'
|
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
39
|
|
|
40
40
|
<picture>
|
|
41
|
-
<
|
|
42
|
-
<source media="(prefers-color-scheme: light)" srcset="./static/mcp-use.png">
|
|
43
|
-
<img alt="Shows a black MCP-Use Logo in light color mode and a white one in dark color mode." src="./static/mcp-use.png" width="full">
|
|
41
|
+
<img alt="" src="./static/mcpusegrass.png" width="full">
|
|
44
42
|
</picture>
|
|
45
43
|
|
|
46
|
-
<h1 align="center">
|
|
44
|
+
<h1 align="center">Open Source MCP CLient Library </h1>
|
|
47
45
|
|
|
46
|
+
[](https://pypi.org/project/mcp_use/)
|
|
47
|
+
[](https://pypi.org/project/mcp_use/)
|
|
48
|
+
[](https://pypi.org/project/mcp_use/)
|
|
49
|
+
[](https://pypi.org/project/mcp_use/)
|
|
50
|
+
[](https://github.com/pietrozullo/mcp-use/blob/main/LICENSE)
|
|
51
|
+
[](https://github.com/astral-sh/ruff)
|
|
48
52
|
[](https://github.com/pietrozullo/mcp-use/stargazers)
|
|
49
53
|
|
|
50
|
-
🌐 MCP-Use is the
|
|
54
|
+
🌐 MCP-Use is the open source way to connect any LLM to MCP tools and build custom agents that have tool access, without using closed source or application clients.
|
|
51
55
|
|
|
52
56
|
💡 Let developers easily connect any LLM to tools like web browsing, file operations, and more.
|
|
53
57
|
|
|
@@ -56,14 +60,14 @@ Description-Content-Type: text/markdown
|
|
|
56
60
|
With pip:
|
|
57
61
|
|
|
58
62
|
```bash
|
|
59
|
-
pip install
|
|
63
|
+
pip install mcp-use
|
|
60
64
|
```
|
|
61
65
|
|
|
62
66
|
Or install from source:
|
|
63
67
|
|
|
64
68
|
```bash
|
|
65
|
-
git clone https://github.com/pietrozullo/
|
|
66
|
-
cd
|
|
69
|
+
git clone https://github.com/pietrozullo/mcp-use.git
|
|
70
|
+
cd mcp-use
|
|
67
71
|
pip install -e .
|
|
68
72
|
```
|
|
69
73
|
|
|
@@ -281,51 +285,12 @@ if __name__ == "__main__":
|
|
|
281
285
|
asyncio.run(main())
|
|
282
286
|
```
|
|
283
287
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
from langchain_anthropic import ChatAnthropic
|
|
291
|
-
from mcp_use import MCPAgent, MCPClient
|
|
292
|
-
|
|
293
|
-
async def main():
|
|
294
|
-
# Create a client from a config file
|
|
295
|
-
client = MCPClient.from_config_file("mcp-config.json")
|
|
296
|
-
|
|
297
|
-
# Or initialize with a config file path
|
|
298
|
-
# client = MCPClient("mcp-config.json")
|
|
299
|
-
|
|
300
|
-
# Or programmatically add servers
|
|
301
|
-
client.add_server(
|
|
302
|
-
"local-ws",
|
|
303
|
-
{
|
|
304
|
-
"command": "npx",
|
|
305
|
-
"args": ["@playwright/mcp@latest", "headless"]
|
|
306
|
-
}
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
# Create an LLM
|
|
310
|
-
llm = ChatAnthropic(model="claude-3-5-sonnet-20240620")
|
|
311
|
-
|
|
312
|
-
# Create an agent using the client
|
|
313
|
-
agent = MCPAgent(
|
|
314
|
-
llm=llm,
|
|
315
|
-
client=client,
|
|
316
|
-
server_name="playwright", # Optional, uses first server if not specified
|
|
317
|
-
max_steps=30
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
# Run a query
|
|
321
|
-
result = await agent.run("Your query here")
|
|
322
|
-
|
|
323
|
-
# Close all sessions
|
|
324
|
-
await client.close_all_sessions()
|
|
325
|
-
|
|
326
|
-
if __name__ == "__main__":
|
|
327
|
-
asyncio.run(main())
|
|
328
|
-
```
|
|
288
|
+
## Roadmap
|
|
289
|
+
<ul>
|
|
290
|
+
<li>[ ] Multiple Servers at once </li>
|
|
291
|
+
<li>[ ] Test remote connectors (http, ws)</li>
|
|
292
|
+
<li>[ ] ... </li>
|
|
293
|
+
</ul>
|
|
329
294
|
|
|
330
295
|
## Contributing
|
|
331
296
|
|
|
@@ -342,10 +307,10 @@ We love contributions! Feel free to open issues for bugs or feature requests.
|
|
|
342
307
|
If you use MCP-Use in your research or project, please cite:
|
|
343
308
|
|
|
344
309
|
```bibtex
|
|
345
|
-
@software{
|
|
310
|
+
@software{mcp_use2025,
|
|
346
311
|
author = {Zullo, Pietro},
|
|
347
312
|
title = {MCP-Use: MCP Library for Python},
|
|
348
|
-
year = {
|
|
313
|
+
year = {2025},
|
|
349
314
|
publisher = {GitHub},
|
|
350
315
|
url = {https://github.com/pietrozullo/mcp-use}
|
|
351
316
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
mcp_use/__init__.py,sha256=
|
|
1
|
+
mcp_use/__init__.py,sha256=PSoxLAu1GPjfIDPcZiJyI3k66MMS3lcfx5kERUgFb1o,723
|
|
2
2
|
mcp_use/client.py,sha256=7dBjkRPqyUlp-8NuLcYbW-4ctLDp329DsAvRM1HlVus,7807
|
|
3
|
-
mcp_use/config.py,sha256=
|
|
3
|
+
mcp_use/config.py,sha256=D9LuCuT1mFUSBiO2DUGa5Pnd-yjNcvM9u_v11N5UmK8,1624
|
|
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
8
|
mcp_use/agents/langchain_agent.py,sha256=RaQEo-tm3b4SBeu3DxE9YYdTuTAHBqEd5vSZ6Qi3g5Q,10320
|
|
9
|
-
mcp_use/agents/mcpagent.py,sha256=
|
|
10
|
-
mcp_use/agents/prompts/default.py,sha256=
|
|
9
|
+
mcp_use/agents/mcpagent.py,sha256=0iDbqmzKtj0k1Ge8bsddiwgNEN-YAUdpLItB7ldLYrE,12444
|
|
10
|
+
mcp_use/agents/prompts/default.py,sha256=tnwt9vOiVBhdpu-lIHhwEJo3rvE6EobPfUgS9JURBzg,941
|
|
11
11
|
mcp_use/connectors/__init__.py,sha256=jnd-7pPPJMb0UNJ6aD9lInj5Tlamc8lA_mFyG8RWJpo,385
|
|
12
12
|
mcp_use/connectors/base.py,sha256=caUaTfsODUOik8JF9mPtcZDyZhoIz2X12I_BhAfZK10,1616
|
|
13
13
|
mcp_use/connectors/http.py,sha256=KqVf0HXouFoeQ_bBUr6KQifiUjTo7K6EOCRkqVpFx4Q,7763
|
|
@@ -18,7 +18,7 @@ mcp_use/task_managers/base.py,sha256=ksNdxTwq8N-zqymxVoKGnWXq9iqkLYC61uB91o6Mh-4
|
|
|
18
18
|
mcp_use/task_managers/http.py,sha256=XhrF73RGRnVctBVW2FlFrFTJR2pIGXhtNvfJFiW0Olw,1881
|
|
19
19
|
mcp_use/task_managers/stdio.py,sha256=DEISpXv4mo3d5a-WT8lkWbrXJwUh7QW0nMT_IM3fHGg,2269
|
|
20
20
|
mcp_use/task_managers/websocket.py,sha256=SVgTLFogiynb48eyi6ZioWIKLLWiVBCNE59rXi6GrCM,1943
|
|
21
|
-
mcp_use-0.0.
|
|
22
|
-
mcp_use-0.0.
|
|
23
|
-
mcp_use-0.0.
|
|
24
|
-
mcp_use-0.0.
|
|
21
|
+
mcp_use-0.0.6.dist-info/METADATA,sha256=o4EFi3L21-zAhNssvaRK0y1HFz95FOJYKAHzqXanhIw,8528
|
|
22
|
+
mcp_use-0.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
23
|
+
mcp_use-0.0.6.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
|
|
24
|
+
mcp_use-0.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|