feat: support ?autoConnect=true query param to connect on page load#1195
Open
KeWang0622 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat: support ?autoConnect=true query param to connect on page load#1195KeWang0622 wants to merge 1 commit intomodelcontextprotocol:mainfrom
?autoConnect=true query param to connect on page load#1195KeWang0622 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
When present, the Inspector calls connectMcpServer() once after the initial connection state has been hydrated from the URL. The param is consumed on first use and stripped from the URL via history.replaceState, so refreshes and disconnect/reconnect cycles don't re-trigger it. This lets external tools (docker-compose sidecars, editor extensions, CI smoke tests) build deep-links that drop the user directly into a connected Inspector session without requiring a manual "Connect" click. Composable with existing pre-fill params (?transport, ?serverUrl, ?serverCommand, ?MCP_PROXY_AUTH_TOKEN). Closes modelcontextprotocol#1183
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.
Summary
Adds a new
?autoConnect=truequery param that triggers an automatic connection on page load, removing the need for a manual "Connect" click when the URL already contains all the information needed to connect.Closes #1183
Changes
client/src/utils/configUtils.ts— AddedgetAutoConnect()(reads the param) andstripAutoConnectParam()(removes it from the URL viahistory.replaceStateafter consumption)client/src/App.tsx— Added a one-shotuseEffectthat callsconnectMcpServer()on mount when the param is presentclient/src/__tests__/App.autoConnect.test.tsx— 3 tests covering: auto-connect fires, param is stripped, no-op when absentBehavior
?transport,?serverUrl,?serverCommand,?MCP_PROXY_AUTH_TOKEN).Example deep-link:
Test plan
npm test)