bohr-agent-sdk 0.1.112__py3-none-any.whl → 0.1.113__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.112
3
+ Version: 0.1.113
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -62,7 +62,7 @@ dp/agent/device/device/__init__.py,sha256=w7_1S16S1vWUq0RGl0GFgjq2vFkc5oNvy8cQTn
62
62
  dp/agent/device/device/device.py,sha256=9ZRIJth-4qMO-i-u_b_cO3d6a4eTbTQjPaxFsV_zEkc,9643
63
63
  dp/agent/device/device/types.py,sha256=JuxB-hjf1CjjvfBxCLwRAXVFlYS-nPEdiJpBWLFVCzo,1924
64
64
  dp/agent/server/__init__.py,sha256=rckaYd8pbYyB4ENEhgjXKeGMXjdnrgcJpdM1gu5u1Wc,508
65
- dp/agent/server/calculation_mcp_server.py,sha256=dMIFUQttO7yZyivcuf4BWEZra0Fkh7M7fB2b8tpFix0,17203
65
+ dp/agent/server/calculation_mcp_server.py,sha256=a0hKNVz-WoUbL8y9GhDx1hO830frvmdtvXTBf7V40lI,18478
66
66
  dp/agent/server/preprocessor.py,sha256=XUWu7QOwo_sIDMYS2b1OTrM33EXEVH_73vk-ju1Ok8A,1264
67
67
  dp/agent/server/utils.py,sha256=cIKaAg8UaP5yMwvIVTgUVBjy-B3S16bEdnucUf4UDIM,2055
68
68
  dp/agent/server/executor/__init__.py,sha256=s95M5qKQk39Yi9qaVJZhk_nfj54quSf7EDghR3OCFUA,248
@@ -75,8 +75,8 @@ dp/agent/server/storage/bohrium_storage.py,sha256=EsKX4dWWvZTn2TEhZv4zsvihfDK0mm
75
75
  dp/agent/server/storage/http_storage.py,sha256=KiySq7g9-iJr12XQCKKyJLn8wJoDnSRpQAR5_qPJ1ZU,1471
76
76
  dp/agent/server/storage/local_storage.py,sha256=t1wfjByjXew9ws3PuUxWxmZQ0-Wt1a6t4wmj3fW62GI,1352
77
77
  dp/agent/server/storage/oss_storage.py,sha256=pgjmi7Gir3Y5wkMDCvU4fvSls15fXT7Ax-h9MYHFPK0,3359
78
- bohr_agent_sdk-0.1.112.dist-info/METADATA,sha256=qnbHAl8Ey0kVMpxD_3Q6qWhOZCC0uocIZXwUQZk11_s,11070
79
- bohr_agent_sdk-0.1.112.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
80
- bohr_agent_sdk-0.1.112.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
81
- bohr_agent_sdk-0.1.112.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
82
- bohr_agent_sdk-0.1.112.dist-info/RECORD,,
78
+ bohr_agent_sdk-0.1.113.dist-info/METADATA,sha256=66soACYq7kToAXVjiDX4A_jRkddvoSOLah9QPFrUBxs,11070
79
+ bohr_agent_sdk-0.1.113.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
80
+ bohr_agent_sdk-0.1.113.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
81
+ bohr_agent_sdk-0.1.113.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
82
+ bohr_agent_sdk-0.1.113.dist-info/RECORD,,
@@ -17,6 +17,7 @@ from mcp.server.fastmcp.utilities.func_metadata import (
17
17
  ArgModelBase,
18
18
  func_metadata,
19
19
  )
20
+ from mcp.server.sse import SseServerTransport
20
21
  from pydantic import BaseModel, Field, create_model
21
22
  from starlette.responses import JSONResponse
22
23
  from starlette.routing import Route
@@ -267,9 +268,35 @@ class SubmitResult(BaseModel):
267
268
  extra_info: dict | None = None
268
269
 
269
270
 
271
+ def patch_mcp_close_connection():
272
+ _mock_orig_handle_post_message = SseServerTransport.handle_post_message
273
+
274
+ async def _mock_handle_post_message_with_close(self, scope, receive, send):
275
+ async def _send(message):
276
+ if message.get("type") == "http.response.start":
277
+ headers = list(message.get("headers", []))
278
+ headers = [
279
+ (name, value)
280
+ for name, value in headers
281
+ if name.lower() != b"connection"
282
+ ]
283
+ headers.append((b"connection", b"close"))
284
+ message["headers"] = headers
285
+ elif message.get("type") == "http.response.body":
286
+ message["more_body"] = False
287
+ await send(message)
288
+ await _mock_orig_handle_post_message(self, scope, receive, _send)
289
+
290
+ if not getattr(SseServerTransport.handle_post_message,
291
+ "__patched_close__", False):
292
+ SseServerTransport.handle_post_message = \
293
+ _mock_handle_post_message_with_close
294
+ SseServerTransport.handle_post_message.__patched_close__ = True
295
+
296
+
270
297
  class CalculationMCPServer:
271
298
  def __init__(self, *args, preprocess_func=None, fastmcp_mode=False,
272
- **kwargs):
299
+ patch_close_connection=False, **kwargs):
273
300
  """
274
301
  Args:
275
302
  preprocess_func: The preprocess function for all tools
@@ -277,6 +304,8 @@ class CalculationMCPServer:
277
304
  """
278
305
  self.preprocess_func = preprocess_func
279
306
  self.fastmcp_mode = fastmcp_mode
307
+ if patch_close_connection:
308
+ patch_mcp_close_connection()
280
309
  self.mcp = FastMCP(*args, **kwargs)
281
310
  self.fn_metadata_map = {}
282
311