Commit d309029
authored
* feat(ai): configurable MCP transport host-allowlist for cloud deploy behind a proxy (#12371)
MCP HTTP/SSE servers (knowledge-base + memory-core) behind a reverse proxy on a real public
hostname were rejected with `-32000 Invalid Host: <host>` for every request: TransportService
called the SDK's `createMcpExpressApp()` with no options, so it defaulted to localhost-only
DNS-rebinding protection. The public Host the proxy forwards was never allowlisted.
`TransportService.computeAllowedHosts(aiConfig)` now builds the list passed to
`createMcpExpressApp({allowedHosts})`:
['localhost','127.0.0.1','[::1]'] ∪ (publicUrl hostname) ∪ (NEO_MCP_ALLOWED_HOSTS, comma-split).
- The localhost set is ALWAYS included — the container healthcheck hits `http://127.0.0.1:<port>`;
dropping it would fail the healthcheck (restart loop). Localhost-only deployments are unchanged
(the computed list equals the prior default), so zero regression.
- Reuses the existing `NEO_PUBLIC_URL` leaf (derives its hostname).
- New `allowedHosts` leaf -> `NEO_MCP_ALLOWED_HOSTS` (comma-separated) for multi-hostname or
Host != publicUrl cases, declared in the base + both per-server templates (kb + mc each declare
their transport block independently).
Both servers share TransportService, so one logic change covers kb + mc.
Tests: 16/16 TransportService unit specs pass (11 existing + 5 new computeAllowedHosts cases:
localhost-always/healthcheck-safe, publicUrl-derived, NEO_MCP_ALLOWED_HOSTS-extra+trim,
de-dup, unparseable-publicUrl-ignored).
Resolves #12371
Co-Authored-By: neo-opus-4-7 <neo-opus-4-7@neomjs.com>
* docs(ai): fix computeAllowedHosts JSDoc — instance method, not static (#12371)
1 parent af3a189 commit d309029
5 files changed
Lines changed: 103 additions & 2 deletions
File tree
- ai
- mcp/server
- knowledge-base
- memory-core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
88 | 123 | | |
89 | 124 | | |
90 | 125 | | |
| |||
101 | 136 | | |
102 | 137 | | |
103 | 138 | | |
104 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
105 | 144 | | |
106 | 145 | | |
107 | 146 | | |
| |||
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
309 | 344 | | |
0 commit comments