Repository navigation
fix: validate the MCP server port instead of throwing on a bad one - #2437
Merged
Merged
Conversation
new WebSocket() throws a SyntaxError for a port outside 1-65535. The MCP popover took any integer from its port field (parseInt), so a typo such as 520000 for 52000 threw out of the Connect click handler, left the status stuck on "connecting" with no socket, and reported the error to Sentry. It also stored the bad port and connected=true before connecting, so the auto-reconnect retried it, and threw again, on every reload. parsePort() accepts only whole numbers from 1 to 65535. The popover shows "Enter a port from 1 to 65535" and neither stores nor connects; a bad stored port falls back to the default; and MCPConnection.connect() refuses an invalid port with a logged error rather than throwing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Instead of waiting for Connect, the popover checks the port on every edit: the field shows its error state, the "Enter a port from 1 to 65535" hint turns red, and Connect stays disabled until the port is valid. It listens to the DOM input event rather than PCUI's keyChange (keyup), so paste, autofill and mobile keyboards are caught too. Cancel and Disconnect stay enabled whatever the field holds. Both placements keep the error outline while the field is focused: the toolbar's red ring over PCUI's orange focus ring, and the projects page's red border over its orange focus border. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An empty field used to mean the default port, so CONNECT stayed enabled on a blank field and silently connected to 52000. It now counts as invalid like any other bad value: CONNECT is disabled and the hint asks for a port. The field still starts filled with 52000. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PCUI's Escape handler puts the pre-edit value back without firing input or change (change only with keyChange), so after appending a digit to 52000 and pressing Escape the field showed 52000 with the error hint still up and CONNECT disabled. Revalidate on PCUI's keydown event for Escape, which it emits after restoring the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
playcanvas-bot Bot
pushed a commit
that referenced
this pull request
Oct 26, 2026
…2437) * fix: validate the MCP server port instead of throwing on a bad one new WebSocket() throws a SyntaxError for a port outside 1-65535. The MCP popover took any integer from its port field (parseInt), so a typo such as 520000 for 52000 threw out of the Connect click handler, left the status stuck on "connecting" with no socket, and reported the error to Sentry. It also stored the bad port and connected=true before connecting, so the auto-reconnect retried it, and threw again, on every reload. parsePort() accepts only whole numbers from 1 to 65535. The popover shows "Enter a port from 1 to 65535" and neither stores nor connects; a bad stored port falls back to the default; and MCPConnection.connect() refuses an invalid port with a logged error rather than throwing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: validate the MCP port as it is typed Instead of waiting for Connect, the popover checks the port on every edit: the field shows its error state, the "Enter a port from 1 to 65535" hint turns red, and Connect stays disabled until the port is valid. It listens to the DOM input event rather than PCUI's keyChange (keyup), so paste, autofill and mobile keyboards are caught too. Cancel and Disconnect stay enabled whatever the field holds. Both placements keep the error outline while the field is focused: the toolbar's red ring over PCUI's orange focus ring, and the projects page's red border over its orange focus border. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: treat an empty MCP port field as invalid An empty field used to mean the default port, so CONNECT stayed enabled on a blank field and silently connected to 52000. It now counts as invalid like any other bad value: CONNECT is disabled and the hint asks for a port. The field still starts filled with 52000. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: revalidate the MCP port after Escape restores it PCUI's Escape handler puts the pre-edit value back without firing input or change (change only with keyChange), so after appending a digit to 52000 and pressing Escape the field showed 52000 with the error hint still up and CONNECT disabled. Revalidate on PCUI's keydown event for Escape, which it emits after restoring the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Will Eastcott <weastcott@snapchat.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c135df3)
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's Changed
inputevent rather than PCUI'skeyChange(keyup), so paste, autofill and mobile keyboards are covered too. Cancel and Disconnect stay enabled whatever the field holds.MCPConnection.connect()refuses an invalid port with a logged[MCP]error instead of throwing, whoever callsmcp:connect.parsePort()helper insrc/editor/mcp/port.ts, with tests.Why:
new WebSocket()throws aSyntaxErrorfor a port outside 1–65535. The popover read its field withparseInt(value) || 52000, which accepts any integer, so a typo such as520000threw out of the Connect click handler. The error landed in error reporting, and the status was left on "Connecting" with no socket behind it. The popover had already storededitor:mcp:connected = trueand the bad port before connecting, so the auto-reconnect retried it, and threw again, on every reload until the user noticed.Testing:
npm test: the newparsePorttests pass, including520000,400000,65536,0,-1, empty,52000abc,5e4and52000.5.eslintandstylelintreport no errors in the changed files.popover.ts,connection.tsandport.tsagainst the compilededitor.scss, with a stubeditorglobal:520000into the toolbar popover turns on the error ring (red even while focused), shows the red hint and disables CONNECT. Clicking CONNECT then stores nothing and doesn't connect.52001removes the error and re-enables CONNECT. (Clearing the field now disables CONNECT; that change is covered by theparsePort('')test, not re-run in the browser.)52000, appending0makes it invalid, and Escape brings back52000with the error cleared and CONNECT enabled; before the fix the error and the disabled CONNECT stuck. From a committed65536, deleting a digit makes it valid (6553), and Escape brings back65536with the error back on.400000gives the red border, the hint and a disabled Connect.editor:mcp:connected = trueandeditor:mcp:port = 520000already stored shows52000in the field and auto-connects tows://127.0.0.1:52000.Checks
🤖 Generated with Claude Code