mcp-use 1.3.4__tar.gz → 1.3.5__tar.gz

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.

Files changed (151) hide show
  1. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/release-drafter.yml +2 -2
  2. {mcp_use-1.3.4 → mcp_use-1.3.5}/PKG-INFO +1 -1
  3. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/client.py +1 -3
  4. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/base.py +16 -12
  5. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/http.py +26 -1
  6. {mcp_use-1.3.4 → mcp_use-1.3.5}/pyproject.toml +1 -1
  7. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_client.py +3 -4
  8. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_http_connector.py +34 -4
  9. {mcp_use-1.3.4 → mcp_use-1.3.5}/.env.example +0 -0
  10. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  11. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/pull_request_template.md +0 -0
  12. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/changelog.yml +0 -0
  13. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/claude.yml +0 -0
  14. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/publish.yml +0 -0
  15. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/release-drafter.yml +0 -0
  16. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/stale.yml +0 -0
  17. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/transportstests.yml +0 -0
  18. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/unittests.yml +0 -0
  19. {mcp_use-1.3.4 → mcp_use-1.3.5}/.github/workflows/update-readme.yml +0 -0
  20. {mcp_use-1.3.4 → mcp_use-1.3.5}/.gitignore +0 -0
  21. {mcp_use-1.3.4 → mcp_use-1.3.5}/.pre-commit-config.yaml +0 -0
  22. {mcp_use-1.3.4 → mcp_use-1.3.5}/CHANGELOG.md +0 -0
  23. {mcp_use-1.3.4 → mcp_use-1.3.5}/CLAUDE.md +0 -0
  24. {mcp_use-1.3.4 → mcp_use-1.3.5}/CODE_OF_CONDUCT.md +0 -0
  25. {mcp_use-1.3.4 → mcp_use-1.3.5}/CONTRIBUTING.md +0 -0
  26. {mcp_use-1.3.4 → mcp_use-1.3.5}/LICENSE +0 -0
  27. {mcp_use-1.3.4 → mcp_use-1.3.5}/README.md +0 -0
  28. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/README.md +0 -0
  29. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/api-reference/adapters.mdx +0 -0
  30. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/api-reference/introduction.mdx +0 -0
  31. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/api-reference/mcpagent.mdx +0 -0
  32. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/api-reference/mcpclient.mdx +0 -0
  33. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/changelog.mdx +0 -0
  34. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/community/showcase.mdx +0 -0
  35. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/development/observability.mdx +0 -0
  36. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/development/telemetry.mdx +0 -0
  37. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/development.mdx +0 -0
  38. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/docs.json +0 -0
  39. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/essentials/agent-configuration.mdx +0 -0
  40. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/essentials/client-configuration.mdx +0 -0
  41. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/essentials/configuration.mdx +0 -0
  42. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/essentials/connection-types.mdx +0 -0
  43. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/essentials/llm-integration.mdx +0 -0
  44. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/essentials/server-manager.mdx +0 -0
  45. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/favicon.svg +0 -0
  46. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/fonts.css +0 -0
  47. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/guides/building-custom-agents.mdx +0 -0
  48. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/guides/logging.mdx +0 -0
  49. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/guides/multi-server-setup.mdx +0 -0
  50. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/guides/security.mdx +0 -0
  51. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/guides/streaming.mdx +0 -0
  52. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/01.png +0 -0
  53. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/02.png +0 -0
  54. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/configuration-dark.png +0 -0
  55. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/configuration-light.png +0 -0
  56. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/examples-dark.png +0 -0
  57. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/examples-light.png +0 -0
  58. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/hero-dark.png +0 -0
  59. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/hero-light.png +0 -0
  60. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/installation-dark.png +0 -0
  61. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/installation-light.png +0 -0
  62. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/quickstart-dark.png +0 -0
  63. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/images/quickstart-light.png +0 -0
  64. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/index.mdx +0 -0
  65. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/installation.mdx +0 -0
  66. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/logo/dark.svg +0 -0
  67. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/logo/light.svg +0 -0
  68. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/logo/react.svg +0 -0
  69. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/quickstart.mdx +0 -0
  70. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/snippets/snippet-intro.mdx +0 -0
  71. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/snippets/youtube-embed.mdx +0 -0
  72. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/troubleshooting/common-issues.mdx +0 -0
  73. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/troubleshooting/connection-errors.mdx +0 -0
  74. {mcp_use-1.3.4 → mcp_use-1.3.5}/docs/troubleshooting/performance.mdx +0 -0
  75. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/airbnb_mcp.json +0 -0
  76. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/airbnb_use.py +0 -0
  77. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/blender_use.py +0 -0
  78. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/browser_mcp.json +0 -0
  79. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/browser_use.py +0 -0
  80. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/chat_example.py +0 -0
  81. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/filesystem_use.py +0 -0
  82. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/http_example.py +0 -0
  83. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/mcp_everything.py +0 -0
  84. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/multi_server_example.py +0 -0
  85. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/sandbox_everything.py +0 -0
  86. {mcp_use-1.3.4 → mcp_use-1.3.5}/examples/stream_example.py +0 -0
  87. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/__init__.py +0 -0
  88. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/adapters/__init__.py +0 -0
  89. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/adapters/base.py +0 -0
  90. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/adapters/langchain_adapter.py +0 -0
  91. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/agents/__init__.py +0 -0
  92. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/agents/base.py +0 -0
  93. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/agents/mcpagent.py +0 -0
  94. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/agents/prompts/system_prompt_builder.py +0 -0
  95. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/agents/prompts/templates.py +0 -0
  96. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/config.py +0 -0
  97. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/__init__.py +0 -0
  98. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/sandbox.py +0 -0
  99. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/stdio.py +0 -0
  100. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/utils.py +0 -0
  101. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/connectors/websocket.py +0 -0
  102. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/logging.py +0 -0
  103. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/__init__.py +0 -0
  104. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/server_manager.py +0 -0
  105. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/__init__.py +0 -0
  106. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/base_tool.py +0 -0
  107. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/connect_server.py +0 -0
  108. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/disconnect_server.py +0 -0
  109. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/get_active_server.py +0 -0
  110. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/list_servers_tool.py +0 -0
  111. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/search_tools.py +0 -0
  112. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/managers/tools/use_tool.py +0 -0
  113. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/observability/__init__.py +0 -0
  114. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/observability/laminar.py +0 -0
  115. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/observability/langfuse.py +0 -0
  116. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/session.py +0 -0
  117. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/task_managers/__init__.py +0 -0
  118. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/task_managers/base.py +0 -0
  119. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/task_managers/sse.py +0 -0
  120. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/task_managers/stdio.py +0 -0
  121. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/task_managers/streamable_http.py +0 -0
  122. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/task_managers/websocket.py +0 -0
  123. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/telemetry/__init__.py +0 -0
  124. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/telemetry/events.py +0 -0
  125. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/telemetry/telemetry.py +0 -0
  126. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/telemetry/utils.py +0 -0
  127. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/types/sandbox.py +0 -0
  128. {mcp_use-1.3.4 → mcp_use-1.3.5}/mcp_use/utils.py +0 -0
  129. {mcp_use-1.3.4 → mcp_use-1.3.5}/pytest.ini +0 -0
  130. {mcp_use-1.3.4 → mcp_use-1.3.5}/ruff.toml +0 -0
  131. {mcp_use-1.3.4 → mcp_use-1.3.5}/static/logo_black.svg +0 -0
  132. {mcp_use-1.3.4 → mcp_use-1.3.5}/static/logo_white.svg +0 -0
  133. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/conftest.py +0 -0
  134. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/__init__.py +0 -0
  135. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/servers_for_testing/__init__.py +0 -0
  136. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/servers_for_testing/custom_streaming_server.py +0 -0
  137. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/servers_for_testing/simple_server.py +0 -0
  138. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/servers_for_testing/timeout_test_server.py +0 -0
  139. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/transports/customStreaming/__init__.py +0 -0
  140. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/transports/customStreaming/test_custom_streaming_integration.py +0 -0
  141. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/transports/sse/test_connection_state_tracking.py +0 -0
  142. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/transports/sse/test_sse_integration.py +0 -0
  143. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/transports/stdio/test_stdio_integration.py +0 -0
  144. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/integration/transports/streamableHttp/test_streamable_http_integration.py +0 -0
  145. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_config.py +0 -0
  146. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_logging.py +0 -0
  147. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_sandbox_connector.py +0 -0
  148. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_search_tools_issue_138.py +0 -0
  149. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_session.py +0 -0
  150. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_stdio_connector.py +0 -0
  151. {mcp_use-1.3.4 → mcp_use-1.3.5}/tests/unit/test_websocket_connection_manager.py +0 -0
@@ -1,5 +1,5 @@
1
- name-template: 'v$RESOLVED_VERSION 🌈'
2
- tag-template: 'v$RESOLVED_VERSION'
1
+ name-template: 'Release v$RESOLVED_VERSION 🌈'
2
+ tag-template: 'Releasev$RESOLVED_VERSION'
3
3
  categories:
4
4
  - title: '🚀 Features'
5
5
  labels:
@@ -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
@@ -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
  [project]
2
2
  name = "mcp-use"
3
- version = "1.3.4"
3
+ version = "1.3.5"
4
4
  description = "MCP Library for LLMs"
5
5
  authors = [
6
6
  {name = "Pietro Zullo", email = "pietro.zullo@gmail.com"}
@@ -456,10 +456,9 @@ class TestMCPClientSessionManagement:
456
456
  assert mock_create_connector.call_count == 2
457
457
  assert mock_session_class.call_count == 2
458
458
 
459
- # In the implementation, initialize is called twice for each session:
460
- # Once in create_session and once in the explicit initialize call
461
- assert mock_session1.initialize.call_count == 2
462
- assert mock_session2.initialize.call_count == 2
459
+ # Initialize is called once per session during create_session
460
+ assert mock_session1.initialize.call_count == 1
461
+ assert mock_session2.initialize.call_count == 1
463
462
 
464
463
  # Verify state changes
465
464
  assert len(client.sessions) == 2
@@ -128,7 +128,17 @@ class TestHttpConnectorConnection(IsolatedAsyncioTestCase):
128
128
  mock_instance.initialize.side_effect = McpError(ErrorData(code=1, message="Connection closed"))
129
129
  else:
130
130
  # Second call (SSE) - succeeds
131
- mock_instance.initialize.return_value = EmptyResult()
131
+ mock_init_result = MagicMock()
132
+ mock_init_result.capabilities = MagicMock(tools=True, resources=True, prompts=True)
133
+ mock_instance.initialize.return_value = mock_init_result
134
+
135
+ # Add mocks for list_tools, list_resources, and list_prompts since HttpConnector calls these
136
+ mock_instance.list_tools = AsyncMock()
137
+ mock_instance.list_tools.return_value = MagicMock(tools=[MagicMock(spec=Tool)])
138
+ mock_instance.list_resources = AsyncMock()
139
+ mock_instance.list_resources.return_value = MagicMock(resources=[MagicMock(spec=Resource)])
140
+ mock_instance.list_prompts = AsyncMock()
141
+ mock_instance.list_prompts.return_value = MagicMock(prompts=[MagicMock(spec=Prompt)])
132
142
 
133
143
  return mock_instance
134
144
 
@@ -163,7 +173,18 @@ class TestHttpConnectorConnection(IsolatedAsyncioTestCase):
163
173
  mock_client_session_instance = MagicMock()
164
174
  mock_client_session_instance.__aenter__ = AsyncMock()
165
175
  mock_client_session_instance.initialize = AsyncMock()
166
- mock_client_session_instance.initialize.return_value = EmptyResult() # Success
176
+ mock_init_result = MagicMock()
177
+ mock_init_result.capabilities = MagicMock(tools=True, resources=True, prompts=True)
178
+ mock_client_session_instance.initialize.return_value = mock_init_result
179
+
180
+ # Add mocks for list_tools, list_resources, and list_prompts since HttpConnector calls these
181
+ mock_client_session_instance.list_tools = AsyncMock()
182
+ mock_client_session_instance.list_tools.return_value = MagicMock(tools=[MagicMock(spec=Tool)])
183
+ mock_client_session_instance.list_resources = AsyncMock()
184
+ mock_client_session_instance.list_resources.return_value = MagicMock(resources=[MagicMock(spec=Resource)])
185
+ mock_client_session_instance.list_prompts = AsyncMock()
186
+ mock_client_session_instance.list_prompts.return_value = MagicMock(prompts=[MagicMock(spec=Prompt)])
187
+
167
188
  mock_client_session_class.return_value = mock_client_session_instance
168
189
 
169
190
  # Test connect with streamable HTTP
@@ -178,10 +199,19 @@ class TestHttpConnectorConnection(IsolatedAsyncioTestCase):
178
199
  mock_client_session_instance.__aenter__.assert_called_once()
179
200
  mock_client_session_instance.initialize.assert_called_once()
180
201
 
202
+ # Verify tools/resources/prompts were populated during connect
203
+ mock_client_session_instance.list_tools.assert_called_once()
204
+ mock_client_session_instance.list_resources.assert_called_once()
205
+ mock_client_session_instance.list_prompts.assert_called_once()
206
+
181
207
  # Verify final state
182
208
  self.assertEqual(self.connector.client_session, mock_client_session_instance)
183
209
  self.assertEqual(self.connector._connection_manager, mock_cm_instance)
184
210
  self.assertTrue(self.connector._connected)
211
+ self.assertTrue(self.connector._initialized)
212
+ self.assertEqual(len(self.connector._tools), 1)
213
+ self.assertEqual(len(self.connector._resources), 1)
214
+ self.assertEqual(len(self.connector._prompts), 1)
185
215
 
186
216
  @patch("mcp_use.connectors.http.StreamableHttpConnectionManager")
187
217
  async def test_sse_connect_already_connected(self, mock_cm_class, _):
@@ -300,7 +330,7 @@ class TestHttpConnectorOperations(IsolatedAsyncioTestCase):
300
330
  mock_init_result.capabilities = MagicMock(tools=True, resources=True, prompts=True)
301
331
  self.connector.client_session.initialize.return_value = mock_init_result
302
332
 
303
- # Setup mocks for list_tools, list_resources, and list_prompts
333
+ # Setup mocks for client session methods directly (not connector wrapper methods)
304
334
  self.connector.client_session.list_tools.return_value = MagicMock(tools=[MagicMock(spec=Tool)])
305
335
  self.connector.client_session.list_resources.return_value = MagicMock(resources=[MagicMock(spec=Resource)])
306
336
  self.connector.client_session.list_prompts.return_value = MagicMock(prompts=[MagicMock(spec=Prompt)])
@@ -308,7 +338,7 @@ class TestHttpConnectorOperations(IsolatedAsyncioTestCase):
308
338
  # Initialize
309
339
  result_session_info = await self.connector.initialize()
310
340
 
311
- # Verify calls
341
+ # Verify calls to client session methods directly
312
342
  self.connector.client_session.initialize.assert_called_once()
313
343
  self.connector.client_session.list_tools.assert_called_once()
314
344
  self.connector.client_session.list_resources.assert_called_once()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes