fix: skip MCP preflight content-type probe on reconnect when already ready (#40604)
Closes #40366. Salvaged from #40548; re-verified on main, tightened, tested. Co-authored-by: mohamedorigami-jpg <mohamedorigami-jpg@users.noreply.github.com>
This commit is contained in:
co-authored by
mohamedorigami-jpg
parent
76f01780f0
commit
af08c43f3e
+6
-1
@@ -1800,7 +1800,12 @@ class MCPServerTask:
|
||||
# before surfacing an opaque CancelledError. Probing here — once,
|
||||
# outside the SDK task group — fails fast and non-retryably with
|
||||
# an actionable message, mirroring the URL-validation path above.
|
||||
if config.get("transport") != "sse":
|
||||
# Skip the probe when _ready is already set: that only happens
|
||||
# after a prior successful connect, so this run() invocation is a
|
||||
# reconnect (OAuth recovery / manual refresh). The endpoint was
|
||||
# already validated once; re-probing burns a redundant network
|
||||
# round-trip against a known-good server on every reconnect.
|
||||
if config.get("transport") != "sse" and not self._ready.is_set():
|
||||
try:
|
||||
_probe_headers = dict(config.get("headers") or {})
|
||||
await self._preflight_content_type(
|
||||
|
||||
Reference in New Issue
Block a user