mcp-use 1.3.1__py3-none-any.whl → 1.3.3__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 +2 -0
- mcp_use/adapters/base.py +2 -6
- mcp_use/adapters/langchain_adapter.py +4 -11
- mcp_use/agents/base.py +1 -3
- mcp_use/agents/mcpagent.py +19 -42
- mcp_use/agents/prompts/system_prompt_builder.py +1 -3
- mcp_use/client.py +1 -3
- mcp_use/connectors/base.py +9 -3
- mcp_use/connectors/http.py +4 -12
- mcp_use/connectors/sandbox.py +5 -15
- mcp_use/connectors/stdio.py +1 -3
- mcp_use/connectors/websocket.py +1 -3
- mcp_use/logging.py +1 -1
- mcp_use/managers/server_manager.py +5 -16
- mcp_use/managers/tools/disconnect_server.py +1 -3
- mcp_use/managers/tools/get_active_server.py +1 -4
- mcp_use/managers/tools/search_tools.py +29 -36
- mcp_use/managers/tools/use_tool.py +5 -18
- mcp_use/observability/__init__.py +8 -0
- mcp_use/observability/laminar.py +21 -0
- mcp_use/observability/langfuse.py +35 -0
- mcp_use/telemetry/telemetry.py +306 -0
- {mcp_use-1.3.1.dist-info → mcp_use-1.3.3.dist-info}/METADATA +12 -5
- mcp_use-1.3.3.dist-info/RECORD +49 -0
- mcp_use/telemetry/posthog.py +0 -214
- mcp_use-1.3.1.dist-info/RECORD +0 -46
- {mcp_use-1.3.1.dist-info → mcp_use-1.3.3.dist-info}/WHEEL +0 -0
- {mcp_use-1.3.1.dist-info → mcp_use-1.3.3.dist-info}/licenses/LICENSE +0 -0
mcp_use/telemetry/posthog.py
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
import platform
|
|
4
|
-
import uuid
|
|
5
|
-
from collections.abc import Callable
|
|
6
|
-
from functools import wraps
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from typing import Any
|
|
9
|
-
|
|
10
|
-
from posthog import Posthog
|
|
11
|
-
|
|
12
|
-
from mcp_use.logging import MCP_USE_DEBUG
|
|
13
|
-
from mcp_use.telemetry.events import (
|
|
14
|
-
BaseTelemetryEvent,
|
|
15
|
-
MCPAgentExecutionEvent,
|
|
16
|
-
)
|
|
17
|
-
from mcp_use.telemetry.utils import get_package_version
|
|
18
|
-
from mcp_use.utils import singleton
|
|
19
|
-
|
|
20
|
-
logger = logging.getLogger(__name__)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def requires_telemetry(func: Callable) -> Callable:
|
|
24
|
-
"""Decorator that skips function execution if telemetry is disabled"""
|
|
25
|
-
|
|
26
|
-
@wraps(func)
|
|
27
|
-
def wrapper(self, *args, **kwargs):
|
|
28
|
-
if not self._posthog_client:
|
|
29
|
-
return None
|
|
30
|
-
return func(self, *args, **kwargs)
|
|
31
|
-
|
|
32
|
-
return wrapper
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def get_cache_home() -> Path:
|
|
36
|
-
"""Get platform-appropriate cache directory."""
|
|
37
|
-
# XDG_CACHE_HOME for Linux and manually set envs
|
|
38
|
-
env_var: str | None = os.getenv("XDG_CACHE_HOME")
|
|
39
|
-
if env_var and (path := Path(env_var)).is_absolute():
|
|
40
|
-
return path
|
|
41
|
-
|
|
42
|
-
system = platform.system()
|
|
43
|
-
if system == "Windows":
|
|
44
|
-
appdata = os.getenv("LOCALAPPDATA") or os.getenv("APPDATA")
|
|
45
|
-
if appdata:
|
|
46
|
-
return Path(appdata)
|
|
47
|
-
return Path.home() / "AppData" / "Local"
|
|
48
|
-
elif system == "Darwin": # macOS
|
|
49
|
-
return Path.home() / "Library" / "Caches"
|
|
50
|
-
else: # Linux or other Unix
|
|
51
|
-
return Path.home() / ".cache"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
@singleton
|
|
55
|
-
class Telemetry:
|
|
56
|
-
"""
|
|
57
|
-
Service for capturing anonymized telemetry data.
|
|
58
|
-
If the environment variable `MCP_USE_ANONYMIZED_TELEMETRY=false`, telemetry will be disabled.
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
USER_ID_PATH = str(get_cache_home() / "mcp_use" / "telemetry_user_id")
|
|
62
|
-
PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI"
|
|
63
|
-
HOST = "https://eu.i.posthog.com"
|
|
64
|
-
UNKNOWN_USER_ID = "UNKNOWN_USER_ID"
|
|
65
|
-
|
|
66
|
-
_curr_user_id = None
|
|
67
|
-
|
|
68
|
-
def __init__(self):
|
|
69
|
-
telemetry_disabled = os.getenv("MCP_USE_ANONYMIZED_TELEMETRY", "true").lower() == "false"
|
|
70
|
-
|
|
71
|
-
if telemetry_disabled:
|
|
72
|
-
self._posthog_client = None
|
|
73
|
-
logger.debug("Telemetry disabled")
|
|
74
|
-
else:
|
|
75
|
-
logger.info(
|
|
76
|
-
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
77
|
-
)
|
|
78
|
-
try:
|
|
79
|
-
self._posthog_client = Posthog(
|
|
80
|
-
project_api_key=self.PROJECT_API_KEY,
|
|
81
|
-
host=self.HOST,
|
|
82
|
-
disable_geoip=False,
|
|
83
|
-
enable_exception_autocapture=True,
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
# Silence posthog's logging unless debug mode (level 2)
|
|
87
|
-
if MCP_USE_DEBUG < 2:
|
|
88
|
-
posthog_logger = logging.getLogger("posthog")
|
|
89
|
-
posthog_logger.disabled = True
|
|
90
|
-
|
|
91
|
-
except Exception as e:
|
|
92
|
-
logger.warning(f"Failed to initialize telemetry: {e}")
|
|
93
|
-
self._posthog_client = None
|
|
94
|
-
|
|
95
|
-
@property
|
|
96
|
-
def user_id(self) -> str:
|
|
97
|
-
"""Get or create a persistent anonymous user ID"""
|
|
98
|
-
if self._curr_user_id:
|
|
99
|
-
return self._curr_user_id
|
|
100
|
-
|
|
101
|
-
try:
|
|
102
|
-
if not os.path.exists(self.USER_ID_PATH):
|
|
103
|
-
os.makedirs(os.path.dirname(self.USER_ID_PATH), exist_ok=True)
|
|
104
|
-
with open(self.USER_ID_PATH, "w") as f:
|
|
105
|
-
new_user_id = str(uuid.uuid4())
|
|
106
|
-
f.write(new_user_id)
|
|
107
|
-
self._curr_user_id = new_user_id
|
|
108
|
-
else:
|
|
109
|
-
with open(self.USER_ID_PATH) as f:
|
|
110
|
-
self._curr_user_id = f.read().strip()
|
|
111
|
-
except Exception as e:
|
|
112
|
-
logger.debug(f"Failed to get/create user ID: {e}")
|
|
113
|
-
self._curr_user_id = self.UNKNOWN_USER_ID
|
|
114
|
-
|
|
115
|
-
return self._curr_user_id
|
|
116
|
-
|
|
117
|
-
@requires_telemetry
|
|
118
|
-
def capture(self, event: BaseTelemetryEvent) -> None:
|
|
119
|
-
"""Capture a telemetry event"""
|
|
120
|
-
try:
|
|
121
|
-
# Add package version to all events
|
|
122
|
-
properties = event.properties.copy()
|
|
123
|
-
properties["mcp_use_version"] = get_package_version()
|
|
124
|
-
|
|
125
|
-
self._posthog_client.capture(
|
|
126
|
-
distinct_id=self.user_id, event=event.name, properties=properties
|
|
127
|
-
)
|
|
128
|
-
except Exception as e:
|
|
129
|
-
logger.debug(f"Failed to track event {event.name}: {e}")
|
|
130
|
-
|
|
131
|
-
@requires_telemetry
|
|
132
|
-
def track_event(self, event_name: str, properties: dict[str, Any] | None = None) -> None:
|
|
133
|
-
"""Track a telemetry event with optional properties (legacy method)"""
|
|
134
|
-
try:
|
|
135
|
-
# Add package version to all events
|
|
136
|
-
event_properties = (properties or {}).copy()
|
|
137
|
-
event_properties["mcp_use_version"] = get_package_version()
|
|
138
|
-
|
|
139
|
-
self._posthog_client.capture(
|
|
140
|
-
distinct_id=self.user_id, event=event_name, properties=event_properties
|
|
141
|
-
)
|
|
142
|
-
except Exception as e:
|
|
143
|
-
logger.debug(f"Failed to track event {event_name}: {e}")
|
|
144
|
-
|
|
145
|
-
@requires_telemetry
|
|
146
|
-
def track_agent_execution(
|
|
147
|
-
self,
|
|
148
|
-
execution_method: str,
|
|
149
|
-
query: str,
|
|
150
|
-
success: bool,
|
|
151
|
-
model_provider: str,
|
|
152
|
-
model_name: str,
|
|
153
|
-
server_count: int,
|
|
154
|
-
server_identifiers: list[dict[str, str]],
|
|
155
|
-
total_tools_available: int,
|
|
156
|
-
tools_available_names: list[str],
|
|
157
|
-
max_steps_configured: int,
|
|
158
|
-
memory_enabled: bool,
|
|
159
|
-
use_server_manager: bool,
|
|
160
|
-
max_steps_used: int | None,
|
|
161
|
-
manage_connector: bool,
|
|
162
|
-
external_history_used: bool,
|
|
163
|
-
steps_taken: int | None = None,
|
|
164
|
-
tools_used_count: int | None = None,
|
|
165
|
-
tools_used_names: list[str] | None = None,
|
|
166
|
-
response: str | None = None,
|
|
167
|
-
execution_time_ms: int | None = None,
|
|
168
|
-
error_type: str | None = None,
|
|
169
|
-
conversation_history_length: int | None = None,
|
|
170
|
-
) -> None:
|
|
171
|
-
"""Track comprehensive agent execution"""
|
|
172
|
-
event = MCPAgentExecutionEvent(
|
|
173
|
-
execution_method=execution_method,
|
|
174
|
-
query=query,
|
|
175
|
-
success=success,
|
|
176
|
-
model_provider=model_provider,
|
|
177
|
-
model_name=model_name,
|
|
178
|
-
server_count=server_count,
|
|
179
|
-
server_identifiers=server_identifiers,
|
|
180
|
-
total_tools_available=total_tools_available,
|
|
181
|
-
tools_available_names=tools_available_names,
|
|
182
|
-
max_steps_configured=max_steps_configured,
|
|
183
|
-
memory_enabled=memory_enabled,
|
|
184
|
-
use_server_manager=use_server_manager,
|
|
185
|
-
max_steps_used=max_steps_used,
|
|
186
|
-
manage_connector=manage_connector,
|
|
187
|
-
external_history_used=external_history_used,
|
|
188
|
-
steps_taken=steps_taken,
|
|
189
|
-
tools_used_count=tools_used_count,
|
|
190
|
-
tools_used_names=tools_used_names,
|
|
191
|
-
response=response,
|
|
192
|
-
execution_time_ms=execution_time_ms,
|
|
193
|
-
error_type=error_type,
|
|
194
|
-
conversation_history_length=conversation_history_length,
|
|
195
|
-
)
|
|
196
|
-
self.capture(event)
|
|
197
|
-
|
|
198
|
-
@requires_telemetry
|
|
199
|
-
def flush(self) -> None:
|
|
200
|
-
"""Flush any queued telemetry events"""
|
|
201
|
-
try:
|
|
202
|
-
self._posthog_client.flush()
|
|
203
|
-
logger.debug("PostHog client telemetry queue flushed")
|
|
204
|
-
except Exception as e:
|
|
205
|
-
logger.debug(f"Failed to flush PostHog client: {e}")
|
|
206
|
-
|
|
207
|
-
@requires_telemetry
|
|
208
|
-
def shutdown(self) -> None:
|
|
209
|
-
"""Shutdown telemetry client and flush remaining events"""
|
|
210
|
-
try:
|
|
211
|
-
self._posthog_client.shutdown()
|
|
212
|
-
logger.debug("PostHog client shutdown successfully")
|
|
213
|
-
except Exception as e:
|
|
214
|
-
logger.debug(f"Error shutting down telemetry: {e}")
|
mcp_use-1.3.1.dist-info/RECORD
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
mcp_use/__init__.py,sha256=FikKagS6u8mugJOeslN3xfSA-tBLhjOywZSEcQ-y23g,1006
|
|
2
|
-
mcp_use/client.py,sha256=wQLpd5pRL3D4w9IqUTAr8-vndLtxXnpQqZrFF1K7n_s,9498
|
|
3
|
-
mcp_use/config.py,sha256=jRjTVNMxi7pkqFHMJhzSWpwukE4PbdYU8Pe_IZ33sYI,2433
|
|
4
|
-
mcp_use/logging.py,sha256=UhQdMx0H0q08-ZPjY_hAJVErkEUAkU1oahHqwdfdK_U,4274
|
|
5
|
-
mcp_use/session.py,sha256=4kwcB_IkTt_3FiBSTI1H17KhL1W_6N5oai3HTxFrTH4,2496
|
|
6
|
-
mcp_use/utils.py,sha256=QavJcVq2WxUUUCCpPCUeOB5bqIS0FFmpK-RAZkGc6aA,720
|
|
7
|
-
mcp_use/adapters/__init__.py,sha256=-xCrgPThuX7x0PHGFDdjb7M-mgw6QV3sKu5PM7ShnRg,275
|
|
8
|
-
mcp_use/adapters/base.py,sha256=bPVjHERySX6Vw16mEmgFaJuy4Yc_sM8JPtOAqJrP6Rg,7164
|
|
9
|
-
mcp_use/adapters/langchain_adapter.py,sha256=nrsOYDQu-nlLw14f2uNHM-pH8l-yQfZelWXZLhBSMeQ,11008
|
|
10
|
-
mcp_use/agents/__init__.py,sha256=N3eVYP2PxqNO2KcQv5fY8UMUX2W3eLTNkkzuFIJ1DUA,261
|
|
11
|
-
mcp_use/agents/base.py,sha256=bfuldi_89AbSbNc8KeTiCArRT9V62CNxHOWYkLHWjyA,1605
|
|
12
|
-
mcp_use/agents/mcpagent.py,sha256=do2eUtBLYATZV6SbXcpUuTrTUYcaenuKIQ_RP73gKdE,31351
|
|
13
|
-
mcp_use/agents/prompts/system_prompt_builder.py,sha256=GH5Pvl49IBpKpZA9YTI83xMsdYSkRN_hw4LFHkKtxbg,4122
|
|
14
|
-
mcp_use/agents/prompts/templates.py,sha256=AZKrGWuI516C-PmyOPvxDBibNdqJtN24sOHTGR06bi4,1933
|
|
15
|
-
mcp_use/connectors/__init__.py,sha256=cUF4yT0bNr8qeLkSzg28SHueiV5qDaHEB1l1GZ2K0dc,536
|
|
16
|
-
mcp_use/connectors/base.py,sha256=5l5KrfCYCXdbSUMRlT9nvNLMwvZMSDP-C7vK0P4xlYY,12229
|
|
17
|
-
mcp_use/connectors/http.py,sha256=g6FJJDTpGpBZ5JGrK1mgb2t8_woFxLo7LpCWPZQ_vN0,6416
|
|
18
|
-
mcp_use/connectors/sandbox.py,sha256=PtSPHC6rPErAl5GBhnS-f1IWeyEYZY_dQ-UyExKRm0A,11102
|
|
19
|
-
mcp_use/connectors/stdio.py,sha256=h9PQ2vn4q4VXroL42USRqOf5y789l1raIFDsJxZCt7M,2821
|
|
20
|
-
mcp_use/connectors/utils.py,sha256=zQ8GdNQx0Twz3by90BoU1RsWPf9wODGof4K3-NxPXeA,366
|
|
21
|
-
mcp_use/connectors/websocket.py,sha256=pcv1g9JnJLc8kY5IlZkCCGZngCucYG6NBLXxIGeYrPQ,9680
|
|
22
|
-
mcp_use/managers/__init__.py,sha256=rzsJbOhtlmxNQLGcdmtmHaiExEXmiQiUuzPrAgKhAJw,439
|
|
23
|
-
mcp_use/managers/server_manager.py,sha256=YVl5ciNIQfVzP-BR9hA0ac6YSwq0WChpA_Lxvh2e9HE,3984
|
|
24
|
-
mcp_use/managers/tools/__init__.py,sha256=JrA5iTRdtbgwROJE8pQ7GH1sYnqBRcgj4NzFVADKbQ4,510
|
|
25
|
-
mcp_use/managers/tools/base_tool.py,sha256=Jbbp7SwmHKDk8jT_6yVIv7iNsn6KaV_PljWuhhLcbXg,509
|
|
26
|
-
mcp_use/managers/tools/connect_server.py,sha256=MGYQCl11q-w6gSIYuT44dDk7ILV3Oh7kGAJ4fsNXbso,2923
|
|
27
|
-
mcp_use/managers/tools/disconnect_server.py,sha256=4487QlLbXAh9JyfGioc6DMWd0n_dkaa8RLMvsoNZv3E,1602
|
|
28
|
-
mcp_use/managers/tools/get_active_server.py,sha256=LRcHbKZopMl1PiO4D4JS4s0fwtrvtMtvb4kpnoAE8fQ,1015
|
|
29
|
-
mcp_use/managers/tools/list_servers_tool.py,sha256=OPDSMNe-VuAhlUyhDnR4CiuZFpoMhnhWpAablwO5S0k,1897
|
|
30
|
-
mcp_use/managers/tools/search_tools.py,sha256=sT2fe66IyOeASTGjdTsjyzSpqkIGKLVXBF8wXUtWXd4,12055
|
|
31
|
-
mcp_use/managers/tools/use_tool.py,sha256=r7k7uMYzrk353qw7M5h1utu_IR2G85uMZkrNcg2RyZA,6824
|
|
32
|
-
mcp_use/task_managers/__init__.py,sha256=LkXOjiDq5JcyB2tNJuSzyjbxZTl1Ordr_NKKD77Nb7g,557
|
|
33
|
-
mcp_use/task_managers/base.py,sha256=mvLFTVyOfvBWFmkx5l8DZVZUezbhsRARDDfMS2AuFLE,5031
|
|
34
|
-
mcp_use/task_managers/sse.py,sha256=nLKt99OiqoJxFT62zCeNwSZUmdPPg4SD7M1pCEPOa3c,2391
|
|
35
|
-
mcp_use/task_managers/stdio.py,sha256=MJcW03lUZUs_HEUxwFPaqy7m8QLbmdn6LagpcfZdjc8,2130
|
|
36
|
-
mcp_use/task_managers/streamable_http.py,sha256=Zky821Ston5CX0DQVyeRxc2uUqALD8soonRSe09cHcE,2683
|
|
37
|
-
mcp_use/task_managers/websocket.py,sha256=9JTw705rhYbP6x2xAPF6PwtNgF5yEWTQhx-dYSPMoaI,2154
|
|
38
|
-
mcp_use/telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
-
mcp_use/telemetry/events.py,sha256=K5xqbmkum30r4gM2PWtTiUWGF8oZzGZw2DYwco1RfOQ,3113
|
|
40
|
-
mcp_use/telemetry/posthog.py,sha256=oJNBK3UoXXoqkq7MBIH32b3tgBB7Ai4tu3ZT6ZzjdMw,7592
|
|
41
|
-
mcp_use/telemetry/utils.py,sha256=kDVTqt2oSeWNJbnTOlXOehr2yFO0PMyx2UGkrWkfJiw,1769
|
|
42
|
-
mcp_use/types/sandbox.py,sha256=opJ9r56F1FvaqVvPovfAj5jZbsOexgwYx5wLgSlN8_U,712
|
|
43
|
-
mcp_use-1.3.1.dist-info/METADATA,sha256=FpGowckufkEfTnIE4Cex1arG4sOAJcWmeh3HQpjnPAo,28515
|
|
44
|
-
mcp_use-1.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
45
|
-
mcp_use-1.3.1.dist-info/licenses/LICENSE,sha256=7Pw7dbwJSBw8zH-WE03JnR5uXvitRtaGTP9QWPcexcs,1068
|
|
46
|
-
mcp_use-1.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|