Commit 58acdbb
committed
fix(mcp): pass bind host to streamable_http_app and close caller-owned http client
- runtime.py: pass host=server_config.host to streamable_http_app(). Without
it the v2 SDK defaults host to 127.0.0.1 and auto-applies a localhost-only
DNS rebinding allowlist when transport_security is None, causing HTTP 421 on
every non-localhost request for servers bound to 0.0.0.0.
- client.py: enter the caller-provided httpx.AsyncClient into the exit stack.
The v2 SDK does not close a caller-provided client, so it leaked on every
connection attempt. Entered before the transport so LIFO teardown fires the
terminate_on_close DELETE while the client is still open.
- test_runtime_coverage.py: set _transport_security on object.__new__ servers
that bypass __init__, now required after dropping the getattr fallback.
Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>1 parent 7a72951 commit 58acdbb
3 files changed
Lines changed: 14 additions & 1 deletion
File tree
- cpex/framework/external/mcp
- server
- tests/unit/cpex/framework/external/mcp/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
379 | 384 | | |
380 | 385 | | |
381 | 386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
391 | 394 | | |
392 | 395 | | |
393 | 396 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| |||
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
| 290 | + | |
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
| |||
315 | 319 | | |
316 | 320 | | |
317 | 321 | | |
| 322 | + | |
318 | 323 | | |
319 | 324 | | |
320 | 325 | | |
| |||
0 commit comments