chuk-tool-processor 0.6.5__py3-none-any.whl → 0.6.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 chuk-tool-processor might be problematic. Click here for more details.
- chuk_tool_processor/mcp/transport/sse_transport.py +41 -3
- {chuk_tool_processor-0.6.5.dist-info → chuk_tool_processor-0.6.6.dist-info}/METADATA +1 -1
- {chuk_tool_processor-0.6.5.dist-info → chuk_tool_processor-0.6.6.dist-info}/RECORD +5 -5
- {chuk_tool_processor-0.6.5.dist-info → chuk_tool_processor-0.6.6.dist-info}/WHEEL +0 -0
- {chuk_tool_processor-0.6.5.dist-info → chuk_tool_processor-0.6.6.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# chuk_tool_processor/mcp/transport/sse_transport.py
|
|
2
2
|
"""
|
|
3
3
|
Fixed SSE transport that matches your server's actual behavior.
|
|
4
|
-
Based on your working debug script.
|
|
4
|
+
Based on your working debug script with smart URL detection.
|
|
5
5
|
"""
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
@@ -26,13 +26,21 @@ class SSETransport(MCPBaseTransport):
|
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
def __init__(self, url: str, api_key: Optional[str] = None,
|
|
29
|
+
headers: Optional[Dict[str, str]] = None,
|
|
29
30
|
connection_timeout: float = 30.0, default_timeout: float = 30.0):
|
|
30
31
|
"""Initialize SSE transport."""
|
|
31
32
|
self.url = url.rstrip('/')
|
|
32
33
|
self.api_key = api_key
|
|
34
|
+
self.configured_headers = headers or {}
|
|
33
35
|
self.connection_timeout = connection_timeout
|
|
34
36
|
self.default_timeout = default_timeout
|
|
35
37
|
|
|
38
|
+
# DEBUG: Log what we received
|
|
39
|
+
logger.debug("SSE Transport initialized with:")
|
|
40
|
+
logger.debug(" URL: %s", self.url)
|
|
41
|
+
logger.debug(" API Key: %s", "***" if api_key else None)
|
|
42
|
+
logger.debug(" Headers: %s", {k: v[:10] + "..." if len(v) > 10 else v for k, v in self.configured_headers.items()})
|
|
43
|
+
|
|
36
44
|
# State
|
|
37
45
|
self.session_id = None
|
|
38
46
|
self.message_url = None
|
|
@@ -48,11 +56,41 @@ class SSETransport(MCPBaseTransport):
|
|
|
48
56
|
self.sse_response = None
|
|
49
57
|
self.sse_stream_context = None
|
|
50
58
|
|
|
59
|
+
def _construct_sse_url(self, base_url: str) -> str:
|
|
60
|
+
"""
|
|
61
|
+
Construct the SSE endpoint URL from the base URL.
|
|
62
|
+
|
|
63
|
+
Smart detection to avoid double-appending /sse if already present.
|
|
64
|
+
"""
|
|
65
|
+
# Remove trailing slashes
|
|
66
|
+
base_url = base_url.rstrip('/')
|
|
67
|
+
|
|
68
|
+
# Check if URL already ends with /sse
|
|
69
|
+
if base_url.endswith('/sse'):
|
|
70
|
+
# Already has /sse, use as-is
|
|
71
|
+
logger.debug("URL already contains /sse endpoint: %s", base_url)
|
|
72
|
+
return base_url
|
|
73
|
+
|
|
74
|
+
# Append /sse to the base URL
|
|
75
|
+
sse_url = f"{base_url}/sse"
|
|
76
|
+
logger.debug("Appending /sse to base URL: %s -> %s", base_url, sse_url)
|
|
77
|
+
return sse_url
|
|
78
|
+
|
|
51
79
|
def _get_headers(self) -> Dict[str, str]:
|
|
52
80
|
"""Get headers with auth if available."""
|
|
53
81
|
headers = {}
|
|
82
|
+
|
|
83
|
+
# Add configured headers first
|
|
84
|
+
if self.configured_headers:
|
|
85
|
+
headers.update(self.configured_headers)
|
|
86
|
+
|
|
87
|
+
# Add API key as Bearer token if provided (this will override any Authorization header)
|
|
54
88
|
if self.api_key:
|
|
55
89
|
headers['Authorization'] = f'Bearer {self.api_key}'
|
|
90
|
+
|
|
91
|
+
# DEBUG: Log what headers we're sending
|
|
92
|
+
logger.debug("Sending headers: %s", {k: v[:10] + "..." if len(v) > 10 else v for k, v in headers.items()})
|
|
93
|
+
|
|
56
94
|
return headers
|
|
57
95
|
|
|
58
96
|
async def initialize(self) -> bool:
|
|
@@ -68,8 +106,8 @@ class SSETransport(MCPBaseTransport):
|
|
|
68
106
|
self.stream_client = httpx.AsyncClient(timeout=self.connection_timeout)
|
|
69
107
|
self.send_client = httpx.AsyncClient(timeout=self.default_timeout)
|
|
70
108
|
|
|
71
|
-
# Connect to SSE stream
|
|
72
|
-
sse_url =
|
|
109
|
+
# Connect to SSE stream with smart URL construction
|
|
110
|
+
sse_url = self._construct_sse_url(self.url)
|
|
73
111
|
logger.debug("Connecting to SSE: %s", sse_url)
|
|
74
112
|
|
|
75
113
|
self.sse_stream_context = self.stream_client.stream(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chuk-tool-processor
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.6
|
|
4
4
|
Summary: Async-native framework for registering, discovering, and executing tools referenced in LLM responses
|
|
5
5
|
Author-email: CHUK Team <chrishayuk@somejunkmailbox.com>
|
|
6
6
|
Maintainer-email: CHUK Team <chrishayuk@somejunkmailbox.com>
|
|
@@ -26,7 +26,7 @@ chuk_tool_processor/mcp/stream_manager.py,sha256=DN58d76J3Xkg9DI3f6EFe9qAG-ZsFa4
|
|
|
26
26
|
chuk_tool_processor/mcp/transport/__init__.py,sha256=0DX7m_VvlXPxijc-88_QTLhq4ZqAgUgzBjSMGL9C_lM,963
|
|
27
27
|
chuk_tool_processor/mcp/transport/base_transport.py,sha256=bqId34OMQMxzMXtrKq_86sot0_x0NS_ecaIllsCyy6I,3423
|
|
28
28
|
chuk_tool_processor/mcp/transport/http_streamable_transport.py,sha256=3I3tNYU8r4YqCbNhMCkoucvZc6VS2ulzeUjDe2FbcRk,19108
|
|
29
|
-
chuk_tool_processor/mcp/transport/sse_transport.py,sha256=
|
|
29
|
+
chuk_tool_processor/mcp/transport/sse_transport.py,sha256=s8an1sHLFsIJwqxUcdSvY6bYBkdyNQ-LkQMqzD5okdI,17253
|
|
30
30
|
chuk_tool_processor/mcp/transport/stdio_transport.py,sha256=DPXLR_OxuCJ2bgwYDuT_iYC_CDcUIySvLNO7JzyiPyc,9099
|
|
31
31
|
chuk_tool_processor/models/__init__.py,sha256=TC__rdVa0lQsmJHM_hbLDPRgToa_pQT_UxRcPZk6iVw,40
|
|
32
32
|
chuk_tool_processor/models/execution_strategy.py,sha256=UVW35YIeMY2B3mpIKZD2rAkyOPayI6ckOOUALyf0YiQ,2115
|
|
@@ -54,7 +54,7 @@ chuk_tool_processor/registry/providers/__init__.py,sha256=eigwG_So11j7WbDGSWaKd3
|
|
|
54
54
|
chuk_tool_processor/registry/providers/memory.py,sha256=6cMtUwLO6zrk3pguQRgxJ2CReHAzewgZsizWZhsoStk,5184
|
|
55
55
|
chuk_tool_processor/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
56
|
chuk_tool_processor/utils/validation.py,sha256=V5N1dH9sJlHepFIbiI2k2MU82o7nvnh0hKyIt2jdgww,4136
|
|
57
|
-
chuk_tool_processor-0.6.
|
|
58
|
-
chuk_tool_processor-0.6.
|
|
59
|
-
chuk_tool_processor-0.6.
|
|
60
|
-
chuk_tool_processor-0.6.
|
|
57
|
+
chuk_tool_processor-0.6.6.dist-info/METADATA,sha256=xjCU03q8dyRa8VbmtEO5ZjLiJbWzid6ccy5TItWokSo,23463
|
|
58
|
+
chuk_tool_processor-0.6.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
59
|
+
chuk_tool_processor-0.6.6.dist-info/top_level.txt,sha256=7lTsnuRx4cOW4U2sNJWNxl4ZTt_J1ndkjTbj3pHPY5M,20
|
|
60
|
+
chuk_tool_processor-0.6.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|