Skip to content

toolmark-monorepo / @toolmark/mcp / isAllowedUpgrade

Function: isAllowedUpgrade() ​

isAllowedUpgrade(req, o): boolean

Defined in: packages/mcp/src/pairing/upgrade.ts:14

Decides whether an HTTP upgrade may become a pairing WebSocket (spec §11.3, §14): the peer is loopback (127.0.0.1, ::1, ::ffff:127.0.0.1), Host is 127.0.0.1:<port> or localhost:<port> (DNS-rebinding guard), and Origin is present and exactly one of allowOrigins.

Parameters ​

req ​

IncomingMessage

The upgrade request.

o ​

The allowed origins and the port the server listens on.

allowOrigins ​

readonly string[]

port ​

number

Returns ​

boolean

true when the upgrade may proceed.