Skip to content

feat: support ?autoConnect=true query param to connect on page load#1195

Open
KeWang0622 wants to merge 1 commit intomodelcontextprotocol:mainfrom
KeWang0622:feat/auto-connect-query-param
Open

feat: support ?autoConnect=true query param to connect on page load#1195
KeWang0622 wants to merge 1 commit intomodelcontextprotocol:mainfrom
KeWang0622:feat/auto-connect-query-param

Conversation

@KeWang0622
Copy link
Copy Markdown

Summary

Adds a new ?autoConnect=true query 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 — Added getAutoConnect() (reads the param) and stripAutoConnectParam() (removes it from the URL via history.replaceState after consumption)
  • client/src/App.tsx — Added a one-shot useEffect that calls connectMcpServer() on mount when the param is present
  • client/src/__tests__/App.autoConnect.test.tsx — 3 tests covering: auto-connect fires, param is stripped, no-op when absent

Behavior

  • Opt-in. Default behavior is unchanged.
  • One-shot. The param is consumed on first use and stripped from the URL, so refreshes and disconnect/reconnect cycles don't re-trigger.
  • Composable. Works alongside the existing pre-fill params (?transport, ?serverUrl, ?serverCommand, ?MCP_PROXY_AUTH_TOKEN).

Example deep-link:

http://localhost:6274?transport=streamable-http&serverUrl=http://localhost:3001/mcp&autoConnect=true

Test plan

  • All 518 existing tests pass (npm test)
  • Prettier and ESLint pass
  • 3 new tests for autoConnect behavior
  • Pre-commit hooks pass

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ?autoConnect=true query param to connect on page load

2 participants