mcp-use 1.3.8__py3-none-any.whl → 1.3.10__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 +6 -3
- mcp_use/adapters/base.py +3 -3
- mcp_use/adapters/langchain_adapter.py +5 -4
- mcp_use/agents/mcpagent.py +101 -17
- mcp_use/agents/remote.py +102 -14
- mcp_use/cli.py +581 -0
- mcp_use/client.py +15 -1
- mcp_use/config.py +10 -8
- mcp_use/connectors/base.py +100 -15
- mcp_use/connectors/http.py +13 -2
- mcp_use/connectors/sandbox.py +12 -6
- mcp_use/connectors/stdio.py +11 -2
- mcp_use/errors/__init__.py +1 -0
- mcp_use/errors/error_formatting.py +29 -0
- mcp_use/logging.py +27 -12
- mcp_use/managers/base.py +36 -0
- mcp_use/managers/server_manager.py +3 -8
- mcp_use/managers/tools/connect_server.py +2 -1
- mcp_use/managers/tools/disconnect_server.py +2 -1
- mcp_use/managers/tools/list_servers_tool.py +2 -0
- mcp_use/observability/__init__.py +2 -1
- mcp_use/observability/callbacks_manager.py +162 -0
- mcp_use/observability/laminar.py +24 -3
- mcp_use/observability/langfuse.py +27 -3
- mcp_use/session.py +70 -0
- mcp_use/telemetry/telemetry.py +1 -4
- {mcp_use-1.3.8.dist-info → mcp_use-1.3.10.dist-info}/METADATA +73 -48
- mcp_use-1.3.10.dist-info/RECORD +55 -0
- mcp_use-1.3.10.dist-info/entry_points.txt +2 -0
- mcp_use-1.3.8.dist-info/RECORD +0 -49
- {mcp_use-1.3.8.dist-info → mcp_use-1.3.10.dist-info}/WHEEL +0 -0
- {mcp_use-1.3.8.dist-info → mcp_use-1.3.10.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Observability callbacks manager for MCP-use.
|
|
3
|
+
|
|
4
|
+
This module provides a centralized manager for handling observability callbacks
|
|
5
|
+
from various platforms (Langfuse, Laminar, etc.) in a clean and extensible way.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ObservabilityManager:
|
|
14
|
+
"""
|
|
15
|
+
Manages observability callbacks for MCP agents.
|
|
16
|
+
|
|
17
|
+
This class provides a centralized way to collect and manage callbacks
|
|
18
|
+
from various observability platforms (Langfuse, Laminar, etc.).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, custom_callbacks: list | None = None):
|
|
22
|
+
"""
|
|
23
|
+
Initialize the ObservabilityManager.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
custom_callbacks: Optional list of custom callbacks to use instead of defaults.
|
|
27
|
+
"""
|
|
28
|
+
self.custom_callbacks = custom_callbacks
|
|
29
|
+
self._available_handlers = []
|
|
30
|
+
self._handler_names = []
|
|
31
|
+
self._initialized = False
|
|
32
|
+
|
|
33
|
+
def _collect_available_handlers(self) -> None:
|
|
34
|
+
"""Collect all available observability handlers from configured platforms."""
|
|
35
|
+
if self._initialized:
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
# Import handlers lazily to avoid circular imports
|
|
39
|
+
try:
|
|
40
|
+
from .langfuse import langfuse_handler
|
|
41
|
+
|
|
42
|
+
if langfuse_handler is not None:
|
|
43
|
+
self._available_handlers.append(langfuse_handler)
|
|
44
|
+
self._handler_names.append("Langfuse")
|
|
45
|
+
logger.debug("ObservabilityManager: Langfuse handler available")
|
|
46
|
+
except ImportError:
|
|
47
|
+
logger.debug("ObservabilityManager: Langfuse module not available")
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
from .laminar import laminar_initialized
|
|
51
|
+
|
|
52
|
+
if laminar_initialized:
|
|
53
|
+
# Laminar is initialized with automatic instrumentation only
|
|
54
|
+
self._handler_names.append("Laminar (auto-instrumentation)")
|
|
55
|
+
logger.debug("ObservabilityManager: Laminar auto-instrumentation active")
|
|
56
|
+
except ImportError:
|
|
57
|
+
logger.debug("ObservabilityManager: Laminar module not available")
|
|
58
|
+
|
|
59
|
+
# Future: Add more platforms here...
|
|
60
|
+
|
|
61
|
+
self._initialized = True
|
|
62
|
+
|
|
63
|
+
def get_callbacks(self) -> list:
|
|
64
|
+
"""
|
|
65
|
+
Get the list of callbacks to use.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
List of callbacks - either custom callbacks if provided,
|
|
69
|
+
or all available observability handlers.
|
|
70
|
+
"""
|
|
71
|
+
# If custom callbacks were provided, use those
|
|
72
|
+
if self.custom_callbacks is not None:
|
|
73
|
+
logger.debug(f"ObservabilityManager: Using {len(self.custom_callbacks)} custom callbacks")
|
|
74
|
+
return self.custom_callbacks
|
|
75
|
+
|
|
76
|
+
# Otherwise, collect and return all available handlers
|
|
77
|
+
self._collect_available_handlers()
|
|
78
|
+
|
|
79
|
+
if self._available_handlers:
|
|
80
|
+
logger.debug(f"ObservabilityManager: Using {len(self._available_handlers)} handlers")
|
|
81
|
+
else:
|
|
82
|
+
logger.debug("ObservabilityManager: No callbacks configured")
|
|
83
|
+
|
|
84
|
+
return self._available_handlers
|
|
85
|
+
|
|
86
|
+
def get_handler_names(self) -> list[str]:
|
|
87
|
+
"""
|
|
88
|
+
Get the names of available handlers.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
List of handler names (e.g., ["Langfuse", "Laminar"])
|
|
92
|
+
"""
|
|
93
|
+
if self.custom_callbacks is not None:
|
|
94
|
+
# For custom callbacks, try to get their class names
|
|
95
|
+
return [type(cb).__name__ for cb in self.custom_callbacks]
|
|
96
|
+
|
|
97
|
+
self._collect_available_handlers()
|
|
98
|
+
return self._handler_names
|
|
99
|
+
|
|
100
|
+
def has_callbacks(self) -> bool:
|
|
101
|
+
"""
|
|
102
|
+
Check if any callbacks are available.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
True if callbacks are available, False otherwise.
|
|
106
|
+
"""
|
|
107
|
+
callbacks = self.get_callbacks()
|
|
108
|
+
return len(callbacks) > 0
|
|
109
|
+
|
|
110
|
+
def add_callback(self, callback) -> None:
|
|
111
|
+
"""
|
|
112
|
+
Add a callback to the custom callbacks list.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
callback: The callback to add.
|
|
116
|
+
"""
|
|
117
|
+
if self.custom_callbacks is None:
|
|
118
|
+
self.custom_callbacks = []
|
|
119
|
+
self.custom_callbacks.append(callback)
|
|
120
|
+
logger.debug(f"ObservabilityManager: Added custom callback: {type(callback).__name__}")
|
|
121
|
+
|
|
122
|
+
def clear_callbacks(self) -> None:
|
|
123
|
+
"""Clear all custom callbacks."""
|
|
124
|
+
self.custom_callbacks = []
|
|
125
|
+
logger.debug("ObservabilityManager: Cleared all custom callbacks")
|
|
126
|
+
|
|
127
|
+
def __repr__(self) -> str:
|
|
128
|
+
"""String representation of the ObservabilityManager."""
|
|
129
|
+
handler_names = self.get_handler_names()
|
|
130
|
+
if handler_names:
|
|
131
|
+
return f"ObservabilityManager(handlers={handler_names})"
|
|
132
|
+
return "ObservabilityManager(no handlers)"
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# Singleton instance for easy access
|
|
136
|
+
_default_manager = None
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def get_default_manager() -> ObservabilityManager:
|
|
140
|
+
"""
|
|
141
|
+
Get the default ObservabilityManager instance.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
The default ObservabilityManager instance (singleton).
|
|
145
|
+
"""
|
|
146
|
+
global _default_manager
|
|
147
|
+
if _default_manager is None:
|
|
148
|
+
_default_manager = ObservabilityManager()
|
|
149
|
+
return _default_manager
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def create_manager(custom_callbacks: list | None = None) -> ObservabilityManager:
|
|
153
|
+
"""
|
|
154
|
+
Create a new ObservabilityManager instance.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
custom_callbacks: Optional list of custom callbacks.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
A new ObservabilityManager instance.
|
|
161
|
+
"""
|
|
162
|
+
return ObservabilityManager(custom_callbacks=custom_callbacks)
|
mcp_use/observability/laminar.py
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Laminar observability integration for MCP-use.
|
|
3
|
+
|
|
4
|
+
This module provides automatic instrumentation for Laminar AI observability platform.
|
|
5
|
+
"""
|
|
6
|
+
|
|
1
7
|
import logging
|
|
2
8
|
import os
|
|
3
9
|
|
|
@@ -6,6 +12,9 @@ logger = logging.getLogger(__name__)
|
|
|
6
12
|
# Check if Laminar is disabled via environment variable
|
|
7
13
|
_laminar_disabled = os.getenv("MCP_USE_LAMINAR", "").lower() == "false"
|
|
8
14
|
|
|
15
|
+
# Track if Laminar is initialized for other modules to check
|
|
16
|
+
laminar_initialized = False
|
|
17
|
+
|
|
9
18
|
# Only initialize if not disabled and API key is present
|
|
10
19
|
if _laminar_disabled:
|
|
11
20
|
logger.debug("Laminar tracing disabled via MCP_USE_LAMINAR environment variable")
|
|
@@ -13,9 +22,21 @@ elif not os.getenv("LAMINAR_PROJECT_API_KEY"):
|
|
|
13
22
|
logger.debug("Laminar API key not found - tracing disabled. Set LAMINAR_PROJECT_API_KEY to enable")
|
|
14
23
|
else:
|
|
15
24
|
try:
|
|
16
|
-
from lmnr import Laminar
|
|
25
|
+
from lmnr import Instruments, Laminar
|
|
26
|
+
|
|
27
|
+
# Initialize Laminar with LangChain instrumentation
|
|
28
|
+
logger.debug("Laminar: Initializing automatic instrumentation for LangChain")
|
|
29
|
+
|
|
30
|
+
# Initialize with specific instruments
|
|
31
|
+
instruments = {Instruments.LANGCHAIN, Instruments.OPENAI}
|
|
32
|
+
logger.debug(f"Laminar: Enabling instruments: {[i.name for i in instruments]}")
|
|
33
|
+
|
|
34
|
+
Laminar.initialize(project_api_key=os.getenv("LAMINAR_PROJECT_API_KEY"), instruments=instruments)
|
|
35
|
+
|
|
36
|
+
laminar_initialized = True
|
|
37
|
+
logger.debug("Laminar observability initialized successfully with LangChain instrumentation")
|
|
17
38
|
|
|
18
|
-
Laminar.initialize(project_api_key=os.getenv("LAMINAR_PROJECT_API_KEY"))
|
|
19
|
-
logger.debug("Laminar observability initialized successfully")
|
|
20
39
|
except ImportError:
|
|
21
40
|
logger.debug("Laminar package not installed - tracing disabled. Install with: pip install lmnr")
|
|
41
|
+
except Exception as e:
|
|
42
|
+
logger.error(f"Failed to initialize Laminar: {e}")
|
|
@@ -20,15 +20,39 @@ elif not os.getenv("LANGFUSE_PUBLIC_KEY") or not os.getenv("LANGFUSE_SECRET_KEY"
|
|
|
20
20
|
else:
|
|
21
21
|
try:
|
|
22
22
|
from langfuse import Langfuse
|
|
23
|
-
from langfuse.langchain import CallbackHandler
|
|
23
|
+
from langfuse.langchain import CallbackHandler as LangfuseCallbackHandler
|
|
24
|
+
|
|
25
|
+
# Create a custom CallbackHandler wrapper to add logging
|
|
26
|
+
class LoggingCallbackHandler(LangfuseCallbackHandler):
|
|
27
|
+
"""Custom Langfuse CallbackHandler that logs intercepted requests."""
|
|
28
|
+
|
|
29
|
+
def on_llm_start(self, *args, **kwargs):
|
|
30
|
+
"""Log when an LLM request is intercepted."""
|
|
31
|
+
logger.debug(f"Langfuse: LLM start args: {args}, kwargs: {kwargs}")
|
|
32
|
+
return super().on_llm_start(*args, **kwargs)
|
|
33
|
+
|
|
34
|
+
def on_chain_start(self, *args, **kwargs):
|
|
35
|
+
"""Log when a chain request is intercepted."""
|
|
36
|
+
logger.debug(f"Langfuse: Chain start args: {args}, kwargs: {kwargs}")
|
|
37
|
+
return super().on_chain_start(*args, **kwargs)
|
|
38
|
+
|
|
39
|
+
def on_tool_start(self, *args, **kwargs):
|
|
40
|
+
"""Log when a tool request is intercepted."""
|
|
41
|
+
logger.debug(f"Langfuse: Tool start args: {args}, kwargs: {kwargs}")
|
|
42
|
+
return super().on_tool_start(*args, **kwargs)
|
|
43
|
+
|
|
44
|
+
def on_retriever_start(self, *args, **kwargs):
|
|
45
|
+
"""Log when a retriever request is intercepted."""
|
|
46
|
+
logger.debug(f"Langfuse: Retriever start args: {args}, kwargs: {kwargs}")
|
|
47
|
+
return super().on_retriever_start(*args, **kwargs)
|
|
24
48
|
|
|
25
49
|
langfuse = Langfuse(
|
|
26
50
|
public_key=os.getenv("LANGFUSE_PUBLIC_KEY"),
|
|
27
51
|
secret_key=os.getenv("LANGFUSE_SECRET_KEY"),
|
|
28
52
|
host=os.getenv("LANGFUSE_HOST", "https://cloud.langfuse.com"),
|
|
29
53
|
)
|
|
30
|
-
langfuse_handler =
|
|
31
|
-
logger.debug("Langfuse observability initialized successfully")
|
|
54
|
+
langfuse_handler = LoggingCallbackHandler()
|
|
55
|
+
logger.debug("Langfuse observability initialized successfully with logging enabled")
|
|
32
56
|
except ImportError:
|
|
33
57
|
logger.debug("Langfuse package not installed - tracing disabled. Install with: pip install langfuse")
|
|
34
58
|
langfuse = None
|
mcp_use/session.py
CHANGED
|
@@ -5,8 +5,12 @@ This module provides a session manager for MCP connections,
|
|
|
5
5
|
which handles authentication, initialization, and tool discovery.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
from datetime import timedelta
|
|
8
9
|
from typing import Any
|
|
9
10
|
|
|
11
|
+
from mcp.types import CallToolResult, GetPromptResult, Prompt, ReadResourceResult, Resource, Tool
|
|
12
|
+
from pydantic import AnyUrl
|
|
13
|
+
|
|
10
14
|
from .connectors.base import BaseConnector
|
|
11
15
|
|
|
12
16
|
|
|
@@ -82,3 +86,69 @@ class MCPSession:
|
|
|
82
86
|
True if the connector is connected, False otherwise.
|
|
83
87
|
"""
|
|
84
88
|
return self.connector.is_connected
|
|
89
|
+
|
|
90
|
+
# Convenience methods for MCP operations
|
|
91
|
+
async def call_tool(
|
|
92
|
+
self, name: str, arguments: dict[str, Any], read_timeout_seconds: timedelta | None = None
|
|
93
|
+
) -> CallToolResult:
|
|
94
|
+
"""Call an MCP tool.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
name: The name of the tool to call.
|
|
98
|
+
arguments: The arguments to pass to the tool.
|
|
99
|
+
read_timeout_seconds: Optional timeout for the tool call.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
The result of the tool call.
|
|
103
|
+
|
|
104
|
+
Raises:
|
|
105
|
+
RuntimeError: If the connection is lost and cannot be reestablished.
|
|
106
|
+
"""
|
|
107
|
+
return await self.connector.call_tool(name, arguments, read_timeout_seconds)
|
|
108
|
+
|
|
109
|
+
async def list_tools(self) -> list[Tool]:
|
|
110
|
+
"""List all available tools from the MCP server.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
List of available tools.
|
|
114
|
+
"""
|
|
115
|
+
return await self.connector.list_tools()
|
|
116
|
+
|
|
117
|
+
async def list_resources(self) -> list[Resource]:
|
|
118
|
+
"""List all available resources from the MCP server.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
List of available resources.
|
|
122
|
+
"""
|
|
123
|
+
return await self.connector.list_resources()
|
|
124
|
+
|
|
125
|
+
async def read_resource(self, uri: AnyUrl) -> ReadResourceResult:
|
|
126
|
+
"""Read a resource by URI.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
uri: The URI of the resource to read.
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
The resource content.
|
|
133
|
+
"""
|
|
134
|
+
return await self.connector.read_resource(uri)
|
|
135
|
+
|
|
136
|
+
async def list_prompts(self) -> list[Prompt]:
|
|
137
|
+
"""List all available prompts from the MCP server.
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
List of available prompts.
|
|
141
|
+
"""
|
|
142
|
+
return await self.connector.list_prompts()
|
|
143
|
+
|
|
144
|
+
async def get_prompt(self, name: str, arguments: dict[str, Any] | None = None) -> GetPromptResult:
|
|
145
|
+
"""Get a prompt by name.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
name: The name of the prompt to get.
|
|
149
|
+
arguments: Optional arguments for the prompt.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
The prompt result with messages.
|
|
153
|
+
"""
|
|
154
|
+
return await self.connector.get_prompt(name, arguments)
|
mcp_use/telemetry/telemetry.py
CHANGED
|
@@ -11,10 +11,7 @@ from posthog import Posthog
|
|
|
11
11
|
from scarf import ScarfEventLogger
|
|
12
12
|
|
|
13
13
|
from mcp_use.logging import MCP_USE_DEBUG
|
|
14
|
-
from mcp_use.telemetry.events import
|
|
15
|
-
BaseTelemetryEvent,
|
|
16
|
-
MCPAgentExecutionEvent,
|
|
17
|
-
)
|
|
14
|
+
from mcp_use.telemetry.events import BaseTelemetryEvent, MCPAgentExecutionEvent
|
|
18
15
|
from mcp_use.telemetry.utils import get_package_version
|
|
19
16
|
from mcp_use.utils import singleton
|
|
20
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-use
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.10
|
|
4
4
|
Summary: MCP Library for LLMs
|
|
5
5
|
Author-email: Pietro Zullo <pietro.zullo@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -46,25 +46,31 @@ Description-Content-Type: text/markdown
|
|
|
46
46
|
<div align="center">
|
|
47
47
|
<div align="center" style="margin: 0 auto; max-width: 80%;">
|
|
48
48
|
<picture>
|
|
49
|
-
<source media="(prefers-color-scheme: dark)" srcset="static/
|
|
50
|
-
<source media="(prefers-color-scheme: light)" srcset="static/
|
|
51
|
-
<img alt="mcp use logo" src="./static/logo-
|
|
49
|
+
<source media="(prefers-color-scheme: dark)" srcset="static/logo-gh.jpg">
|
|
50
|
+
<source media="(prefers-color-scheme: light)" srcset="static/logo-gh.jpg">
|
|
51
|
+
<img alt="mcp use logo" src="./static/logo-gh.jpg" width="80%" style="margin: 20px auto;">
|
|
52
52
|
</picture>
|
|
53
53
|
</div>
|
|
54
54
|
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
<div align="center">
|
|
56
|
+
<h2>🎉 <strong>We're LIVE on Product Hunt!</strong> 🎉</h2>
|
|
57
|
+
<p><strong>Support us today and help us reach #1!</strong></p>
|
|
58
|
+
<a href="https://www.producthunt.com/products/mcp-use?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-mcp-use" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1002629&theme=neutral&t=1754609432704" alt="mcp-use - Open source SDK and infra for MCP servers & agents | Product Hunt" style="width: 220px; height: 54px;" width="250" height="54" /></a>
|
|
59
|
+
<p>👆 <em>Click to upvote and leave a comment!</em></p>
|
|
60
|
+
</div>
|
|
58
61
|
|
|
62
|
+
<h1 align="center">🚀 Create MCP Clients and Agents</h1>
|
|
59
63
|
<p align="center">
|
|
60
64
|
<a href="https://github.com/pietrozullo/mcp-use/stargazers" alt="GitHub stars">
|
|
61
65
|
<img src="https://img.shields.io/github/stars/pietrozullo/mcp-use?style=social" /></a>
|
|
66
|
+
<a href="https://pypi.org/project/mcp_use/" alt="PyPI Downloads">
|
|
67
|
+
<img src="https://static.pepy.tech/badge/mcp-use" /></a>
|
|
62
68
|
<a href="https://pypi.org/project/mcp_use/" alt="PyPI Version">
|
|
63
69
|
<img src="https://img.shields.io/pypi/v/mcp_use.svg"/></a>
|
|
70
|
+
<a href="https://github.com/mcp-use/mcp-use-ts" alt="TypeScript">
|
|
71
|
+
<img src="https://img.shields.io/badge/TypeScript-mcp--use-3178C6?logo=typescript&logoColor=white" /></a>
|
|
64
72
|
<a href="https://github.com/pietrozullo/mcp-use/blob/main/LICENSE" alt="License">
|
|
65
73
|
<img src="https://img.shields.io/github/license/pietrozullo/mcp-use" /></a>
|
|
66
|
-
<a href="https://pypi.org/project/mcp_use/" alt="PyPI Downloads">
|
|
67
|
-
<img src="https://static.pepy.tech/badge/mcp-use" /></a>
|
|
68
74
|
<a href="https://docs.mcp-use.com" alt="Documentation">
|
|
69
75
|
<img src="https://img.shields.io/badge/docs-mcp--use.com-blue" /></a>
|
|
70
76
|
<a href="https://mcp-use.com" alt="Website">
|
|
@@ -88,10 +94,10 @@ Description-Content-Type: text/markdown
|
|
|
88
94
|
- Visit the [mcp-use docs](https://docs.mcp-use.com/) to get started with mcp-use library
|
|
89
95
|
- For the TypeScript version, visit [mcp-use-ts](https://github.com/mcp-use/mcp-use-ts)
|
|
90
96
|
|
|
91
|
-
| Supports
|
|
92
|
-
|
|
|
97
|
+
| Supports | |
|
|
98
|
+
| :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
99
|
| **Primitives** | [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) |
|
|
94
|
-
| **Transports** | [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml)
|
|
100
|
+
| **Transports** | [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) [](https://github.com/pietrozullo/mcp-use/actions/workflows/tests.yml) |
|
|
95
101
|
|
|
96
102
|
## Features
|
|
97
103
|
|
|
@@ -149,7 +155,7 @@ pip install mcp-use
|
|
|
149
155
|
Or install from source:
|
|
150
156
|
|
|
151
157
|
```bash
|
|
152
|
-
git clone https://github.com/
|
|
158
|
+
git clone https://github.com/mcp-use/mcp-use.git
|
|
153
159
|
cd mcp-use
|
|
154
160
|
pip install -e .
|
|
155
161
|
```
|
|
@@ -417,29 +423,7 @@ if __name__ == "__main__":
|
|
|
417
423
|
asyncio.run(run_blender_example())
|
|
418
424
|
```
|
|
419
425
|
|
|
420
|
-
# Configuration
|
|
421
|
-
|
|
422
|
-
MCP-Use supports initialization from configuration files, making it easy to manage and switch between different MCP server setups:
|
|
423
|
-
|
|
424
|
-
```python
|
|
425
|
-
import asyncio
|
|
426
|
-
from mcp_use import create_session_from_config
|
|
427
|
-
|
|
428
|
-
async def main():
|
|
429
|
-
# Create an MCP session from a config file
|
|
430
|
-
session = create_session_from_config("mcp-config.json")
|
|
431
|
-
|
|
432
|
-
# Initialize the session
|
|
433
|
-
await session.initialize()
|
|
434
|
-
|
|
435
|
-
# Use the session...
|
|
436
|
-
|
|
437
|
-
# Disconnect when done
|
|
438
|
-
await session.disconnect()
|
|
439
|
-
|
|
440
|
-
if __name__ == "__main__":
|
|
441
|
-
asyncio.run(main())
|
|
442
|
-
```
|
|
426
|
+
# Configuration Support
|
|
443
427
|
|
|
444
428
|
## HTTP Connection Example
|
|
445
429
|
|
|
@@ -695,6 +679,47 @@ The `SandboxOptions` type provides configuration for the sandbox environment:
|
|
|
695
679
|
- **Consistent environment**: Ensure consistent behavior across different systems
|
|
696
680
|
- **Resource efficiency**: Offload resource-intensive tasks to cloud infrastructure
|
|
697
681
|
|
|
682
|
+
# Direct Tool Calls (Without LLM)
|
|
683
|
+
|
|
684
|
+
You can call MCP server tools directly without an LLM when you need programmatic control:
|
|
685
|
+
|
|
686
|
+
```python
|
|
687
|
+
import asyncio
|
|
688
|
+
from mcp_use import MCPClient
|
|
689
|
+
|
|
690
|
+
async def call_tool_example():
|
|
691
|
+
config = {
|
|
692
|
+
"mcpServers": {
|
|
693
|
+
"everything": {
|
|
694
|
+
"command": "npx",
|
|
695
|
+
"args": ["-y", "@modelcontextprotocol/server-everything"],
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
client = MCPClient.from_dict(config)
|
|
701
|
+
|
|
702
|
+
try:
|
|
703
|
+
await client.create_all_sessions()
|
|
704
|
+
session = client.get_session("everything")
|
|
705
|
+
|
|
706
|
+
# Call tool directly
|
|
707
|
+
result = await session.call_tool(
|
|
708
|
+
name="add",
|
|
709
|
+
arguments={"a": 1, "b": 2}
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
print(f"Result: {result.content[0].text}") # Output: 3
|
|
713
|
+
|
|
714
|
+
finally:
|
|
715
|
+
await client.close_all_sessions()
|
|
716
|
+
|
|
717
|
+
if __name__ == "__main__":
|
|
718
|
+
asyncio.run(call_tool_example())
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
See the complete example: [examples/direct_tool_call.py](examples/direct_tool_call.py)
|
|
722
|
+
|
|
698
723
|
# Build a Custom Agent:
|
|
699
724
|
|
|
700
725
|
You can also build your own custom agent using the LangChain adapter:
|
|
@@ -813,23 +838,27 @@ Thanks to all our amazing contributors!
|
|
|
813
838
|
</tr>
|
|
814
839
|
<tr>
|
|
815
840
|
<td><img src="https://avatars.githubusercontent.com/u/38653995?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/patchy631/ai-engineering-hub"><strong>patchy631/ai-engineering-hub</strong></a></td>
|
|
816
|
-
<td>⭐
|
|
841
|
+
<td>⭐ 17384</td>
|
|
817
842
|
</tr>
|
|
818
843
|
<tr>
|
|
819
844
|
<td><img src="https://avatars.githubusercontent.com/u/170207473?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/tavily-ai/meeting-prep-agent"><strong>tavily-ai/meeting-prep-agent</strong></a></td>
|
|
820
|
-
<td>⭐
|
|
845
|
+
<td>⭐ 131</td>
|
|
846
|
+
</tr>
|
|
847
|
+
<tr>
|
|
848
|
+
<td><img src="https://avatars.githubusercontent.com/u/164294848?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/buildfastwithai/gen-ai-experiments"><strong>buildfastwithai/gen-ai-experiments</strong></a></td>
|
|
849
|
+
<td>⭐ 100</td>
|
|
821
850
|
</tr>
|
|
822
851
|
<tr>
|
|
823
|
-
<td><img src="https://avatars.githubusercontent.com/u/187057607?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/hud-evals/hud-
|
|
824
|
-
<td>⭐
|
|
852
|
+
<td><img src="https://avatars.githubusercontent.com/u/187057607?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/hud-evals/hud-python"><strong>hud-evals/hud-python</strong></a></td>
|
|
853
|
+
<td>⭐ 78</td>
|
|
825
854
|
</tr>
|
|
826
855
|
<tr>
|
|
827
856
|
<td><img src="https://avatars.githubusercontent.com/u/20041231?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/krishnaik06/MCP-CRASH-Course"><strong>krishnaik06/MCP-CRASH-Course</strong></a></td>
|
|
828
|
-
<td>⭐
|
|
857
|
+
<td>⭐ 64</td>
|
|
829
858
|
</tr>
|
|
830
859
|
<tr>
|
|
831
860
|
<td><img src="https://avatars.githubusercontent.com/u/54944174?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/larksuite/lark-samples"><strong>larksuite/lark-samples</strong></a></td>
|
|
832
|
-
<td>⭐
|
|
861
|
+
<td>⭐ 35</td>
|
|
833
862
|
</tr>
|
|
834
863
|
<tr>
|
|
835
864
|
<td><img src="https://avatars.githubusercontent.com/u/892404?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/truemagic-coder/solana-agent-app"><strong>truemagic-coder/solana-agent-app</strong></a></td>
|
|
@@ -841,15 +870,11 @@ Thanks to all our amazing contributors!
|
|
|
841
870
|
</tr>
|
|
842
871
|
<tr>
|
|
843
872
|
<td><img src="https://avatars.githubusercontent.com/u/201161342?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/autometa-dev/whatsapp-mcp-voice-agent"><strong>autometa-dev/whatsapp-mcp-voice-agent</strong></a></td>
|
|
844
|
-
<td>⭐
|
|
873
|
+
<td>⭐ 23</td>
|
|
845
874
|
</tr>
|
|
846
875
|
<tr>
|
|
847
876
|
<td><img src="https://avatars.githubusercontent.com/u/100749943?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/Deniscartin/mcp-cli"><strong>Deniscartin/mcp-cli</strong></a></td>
|
|
848
|
-
<td>⭐
|
|
849
|
-
</tr>
|
|
850
|
-
<tr>
|
|
851
|
-
<td><img src="https://avatars.githubusercontent.com/u/6688805?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/innovaccer/Healthcare-MCP"><strong>innovaccer/Healthcare-MCP</strong></a></td>
|
|
852
|
-
<td>⭐ 15</td>
|
|
877
|
+
<td>⭐ 19</td>
|
|
853
878
|
</tr>
|
|
854
879
|
</table>
|
|
855
880
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
mcp_use/__init__.py,sha256=AEo6p1F4mSHLO3yKVWZbkr3OFuQwTxSYLGrFQkYb4io,1271
|
|
2
|
+
mcp_use/cli.py,sha256=d3_RqN-lca7igS-aZQIdNQidBOILVihyldywcf8GR-c,15602
|
|
3
|
+
mcp_use/client.py,sha256=4WnFrbBBa3YX3brfBgZrhb_OgAT8mMfVzLUHwnnKi8o,11701
|
|
4
|
+
mcp_use/config.py,sha256=yRgUPCMUzkFqROyccG2wjuhGxneCcbgnrHWHQ6z_hoc,3487
|
|
5
|
+
mcp_use/logging.py,sha256=bwZEDM3DZDVDVWmFlHCHEDAODix4_y8VSreRk-nRWuo,4971
|
|
6
|
+
mcp_use/session.py,sha256=DpH_z0a3xYemV9yWzlrf-IPZtpR27CI2S-gAm2jbCAc,4700
|
|
7
|
+
mcp_use/utils.py,sha256=QavJcVq2WxUUUCCpPCUeOB5bqIS0FFmpK-RAZkGc6aA,720
|
|
8
|
+
mcp_use/adapters/__init__.py,sha256=-xCrgPThuX7x0PHGFDdjb7M-mgw6QV3sKu5PM7ShnRg,275
|
|
9
|
+
mcp_use/adapters/base.py,sha256=8XB3xWZ6nJPhhmHwVtHT8-HO0D_9nnxzOkbVDP-fI3k,6940
|
|
10
|
+
mcp_use/adapters/langchain_adapter.py,sha256=zGEVMXLj_jpSXUMHOh5u-fxkkrK2zpSibOSGCy_VMr0,11033
|
|
11
|
+
mcp_use/agents/__init__.py,sha256=FzkntihbAqzixWdWe99zIrrcIfd4N3YWltNniutG9VA,267
|
|
12
|
+
mcp_use/agents/base.py,sha256=EN-dRbwOi9vIqofFg3jmi5yT2VKlwEr9Cwi1DZgB3eE,1591
|
|
13
|
+
mcp_use/agents/mcpagent.py,sha256=cdlGG4-TOzRr4gbzFW0kpirc7AqmRr7rhQCoaDDnpuk,50931
|
|
14
|
+
mcp_use/agents/remote.py,sha256=7wRGX4ucppWvZdSsxJ3TtrPXYrrwGf9oD5j0UtSYitI,14005
|
|
15
|
+
mcp_use/agents/prompts/system_prompt_builder.py,sha256=E86STmxcl2Ic763_114awNqFB2RyLrQlbvgRmJajQjI,4116
|
|
16
|
+
mcp_use/agents/prompts/templates.py,sha256=acg2Q-_uQDL-3q5ZUwwwFrP7wqqf-SEyq0XWDDHt69s,1906
|
|
17
|
+
mcp_use/connectors/__init__.py,sha256=cUF4yT0bNr8qeLkSzg28SHueiV5qDaHEB1l1GZ2K0dc,536
|
|
18
|
+
mcp_use/connectors/base.py,sha256=R1Qh9D6btullQUGiMBVZewP3M7d-0VrsIt4bSw3bHxI,17482
|
|
19
|
+
mcp_use/connectors/http.py,sha256=eiX5NAsT9mnzqWRAoxb6qG3nWxPiVyw5MVcwRY8D6lE,8436
|
|
20
|
+
mcp_use/connectors/sandbox.py,sha256=oXs4Q_1bQJ10XOrJLjFUBKvFy2VmWmyzLhotczl44Po,11804
|
|
21
|
+
mcp_use/connectors/stdio.py,sha256=4gXdXyaeA3B-ywAjPmbEEbHxP2Gg5cWsXNC2kHkubDA,3766
|
|
22
|
+
mcp_use/connectors/utils.py,sha256=zQ8GdNQx0Twz3by90BoU1RsWPf9wODGof4K3-NxPXeA,366
|
|
23
|
+
mcp_use/connectors/websocket.py,sha256=G7ZeLJNPVl9AG6kCmiNJz1N2Ing_QxT7pSswigTKi8Y,9650
|
|
24
|
+
mcp_use/errors/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
25
|
+
mcp_use/errors/error_formatting.py,sha256=17lhj5goGHuTbJ5oLCUXyJ2SuIbzsuSM1Wk8LPeqY9k,911
|
|
26
|
+
mcp_use/managers/__init__.py,sha256=FRTuJw5kYtY1Eo7wN9Aeqeqo1euiR5slvrx5Fl_SGvk,383
|
|
27
|
+
mcp_use/managers/base.py,sha256=fJA4ct6GIcACOzmCSQGga1HoHYjsauaMHZsXehCPQNA,1138
|
|
28
|
+
mcp_use/managers/server_manager.py,sha256=uO18wHUKFq3-YVg_S_SlQDbNF2H978BR28C2YU4X86A,5308
|
|
29
|
+
mcp_use/managers/tools/__init__.py,sha256=zcpm4HXsp8NUMRJeyT6DdB8cgIMDs46pBfoTD-odhGU,437
|
|
30
|
+
mcp_use/managers/tools/base_tool.py,sha256=Jbbp7SwmHKDk8jT_6yVIv7iNsn6KaV_PljWuhhLcbXg,509
|
|
31
|
+
mcp_use/managers/tools/connect_server.py,sha256=-PlqgJDSMzairK90aDg1WTDjpqrFMoTiyekwoPDWNrw,2964
|
|
32
|
+
mcp_use/managers/tools/disconnect_server.py,sha256=dLa5PH-QZ30Dw3n5lzqilyHA8PuQ6xvMkXd-T5EwpU8,1622
|
|
33
|
+
mcp_use/managers/tools/get_active_server.py,sha256=tCaib76gYU3L5G82tEOTq4Io2cuCXWjOjPselb-92i8,964
|
|
34
|
+
mcp_use/managers/tools/list_servers_tool.py,sha256=P_Z96Ab8ELLyo3GQfTMfyemTPJwt0VR1s_iMnWE1GCg,2037
|
|
35
|
+
mcp_use/managers/tools/search_tools.py,sha256=4vso7ln-AfG6lQAMq9FA_CyeVtSEDYEWlHtdHtfnLps,12911
|
|
36
|
+
mcp_use/observability/__init__.py,sha256=qJR51lpW6lVvhgNnUHBXYN6FKn4kDKbGVHUhPzrx324,348
|
|
37
|
+
mcp_use/observability/callbacks_manager.py,sha256=6jIcE6ofiLRxoi4fECaTlpnllTEFQdwB0IZ0ZkY0WAQ,5324
|
|
38
|
+
mcp_use/observability/laminar.py,sha256=eBY23B8rxQOW5ggHeGB0ZCpCSMnK4rC8fBOvDdbuoq4,1613
|
|
39
|
+
mcp_use/observability/langfuse.py,sha256=kOF05cbSEir7r3fibx_q6TfKzqmbjKLV7uNxBote9XY,2677
|
|
40
|
+
mcp_use/task_managers/__init__.py,sha256=LkXOjiDq5JcyB2tNJuSzyjbxZTl1Ordr_NKKD77Nb7g,557
|
|
41
|
+
mcp_use/task_managers/base.py,sha256=mvLFTVyOfvBWFmkx5l8DZVZUezbhsRARDDfMS2AuFLE,5031
|
|
42
|
+
mcp_use/task_managers/sse.py,sha256=nLKt99OiqoJxFT62zCeNwSZUmdPPg4SD7M1pCEPOa3c,2391
|
|
43
|
+
mcp_use/task_managers/stdio.py,sha256=MJcW03lUZUs_HEUxwFPaqy7m8QLbmdn6LagpcfZdjc8,2130
|
|
44
|
+
mcp_use/task_managers/streamable_http.py,sha256=Zky821Ston5CX0DQVyeRxc2uUqALD8soonRSe09cHcE,2683
|
|
45
|
+
mcp_use/task_managers/websocket.py,sha256=9JTw705rhYbP6x2xAPF6PwtNgF5yEWTQhx-dYSPMoaI,2154
|
|
46
|
+
mcp_use/telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
mcp_use/telemetry/events.py,sha256=K5xqbmkum30r4gM2PWtTiUWGF8oZzGZw2DYwco1RfOQ,3113
|
|
48
|
+
mcp_use/telemetry/telemetry.py,sha256=oM_QAbZwOStKkeccvEfKmJLKhL2neFkPn5yM5rL2qHc,11711
|
|
49
|
+
mcp_use/telemetry/utils.py,sha256=kDVTqt2oSeWNJbnTOlXOehr2yFO0PMyx2UGkrWkfJiw,1769
|
|
50
|
+
mcp_use/types/sandbox.py,sha256=opJ9r56F1FvaqVvPovfAj5jZbsOexgwYx5wLgSlN8_U,712
|
|
51
|
+
mcp_use-1.3.10.dist-info/METADATA,sha256=Gs4nltO9zcPhcQVsPKp7yX9FpJRAzGEsgatc0s-yQqw,34338
|
|
52
|
+
mcp_use-1.3.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
53
|
+
mcp_use-1.3.10.dist-info/entry_points.txt,sha256=3jzEN6xbVsMErm_cxlHpCzvM97gFgjvtOEEspUp1vK8,45
|
|
54
|
+
mcp_use-1.3.10.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
|
|
55
|
+
mcp_use-1.3.10.dist-info/RECORD,,
|