Skip to content

Commit 2230ce8

Browse files
committed
update criteria
1 parent fead17e commit 2230ce8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/transports/streamableHttp.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ export class StreamableHttpRunner extends TransportRunnerBase {
206206
noRedaction: true,
207207
});
208208

209-
if (this.userConfig.httpHost === "0.0.0.0") {
209+
if (this.shouldWarnAboutHttpHost(this.userConfig.httpHost)) {
210210
this.logger.warning({
211211
id: LogId.streamableHttpTransportHttpHostWarning,
212212
context: "streamableHttpTransport",
213-
message: `Binding to \`0.0.0.0\` exposes the MCP Server to the entire local network, which allows other devices on the same network to potentially access the MCP Server. This is a security risk and could allow unauthorized access to your database context.`,
213+
message: `Binding to ${this.userConfig.httpHost} can expose the MCP Server to the entire local network, which allows other devices on the same network to potentially access the MCP Server. This is a security risk and could allow unauthorized access to your database context.`,
214214
noRedaction: true,
215215
});
216216
}
@@ -252,4 +252,10 @@ export class StreamableHttpRunner extends TransportRunnerBase {
252252
});
253253
};
254254
}
255+
256+
private shouldWarnAboutHttpHost(httpHost: string): boolean {
257+
const host = httpHost.trim();
258+
const safeHosts = new Set(["127.0.0.1", "localhost", "::1"]);
259+
return host === "0.0.0.0" || host === "::" || (!safeHosts.has(host) && host !== "");
260+
}
255261
}

0 commit comments

Comments
 (0)