Repository navigation
feat: add Test connection for MCP servers on cloud backends - #366
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
tofarr
left a comment
There was a problem hiding this comment.
Code Review — Test connection for MCP servers on cloud backends
Reviewed the full diff (backend route, frontend hook/form/route, API layer, i18n, and tests). Overall this is well-structured, thoughtfully-designed work: the backend reuses the SDK probe with an identical response contract, the frontend mirrors the save serialization so the test exercises real credentials, secrets are restored and scrubbed with the same rules as the save endpoint, and tests cover both layers. Notably clean for a feature touching auth, secrets, and network calls.
Below are the points worth discussing before merge.
🟡 Design / Architecture
1. Importing private (_-prefixed) symbols across module boundaries
mcp_test_router.py imports _probe_mcp_server from openhands.agent_server.mcp_router and _preserve_redacted_mcp_secrets from settings_models. These are convention-private; reaching across modules couples this route to internals that can change without notice. Consider either promoting them to public helpers (drop the underscore) in their owning modules, or adding a thin shared helper module that both the save path and this route consume. Not a blocker, but worth a conscious decision.
2. Request body typed as dict[str, Any] instead of a Pydantic model
The route accepts payload: dict[str, Any] and manually calls MCPTestRequest.model_validate(payload). The stated reason (restore redacted secrets from stored settings before validation so the SDK model doesn't reject/transform the ********** marker) is legitimate, but the cost is:
- The OpenAPI request schema becomes a generic
object— the frontend'sMCPTestRequesttype inmcp-service.types.tsis hand-maintained and could drift from the backend contract. - FastAPI's automatic 422 on malformed bodies is lost and re-implemented manually.
A cleaner pattern: define a small MCPTestRequestBody Pydantic model whose server field is the raw dict and let a @model_validator/Depends pre-processor do the restore, keeping schema generation and validation. If the restore ordering genuinely prevents this, a comment explaining why the dict is intentional would help.
3. OAuth2 returns error_kind='unknown'
if resolved_server.oauth_auth is not None: return MCPTestFailure(..., error_kind='unknown'). There's no oauth/unsupported kind, so the frontend maps it to the generic "Connection failed" message, which is slightly misleading for a server that can connect but can't be probed from the UI. Consider a dedicated error_kind (e.g. 'unsupported') or a more accurate user-facing message ("This server uses OAuth and can only be tested from a conversation").
🔒 Security
4. SSRF / network reachability from the app-server pod (most important point)
The PR description explicitly notes the probe originates from the app-server pod, not the sandbox. This is the key security consideration: an authenticated user can now make the app-server pod issue outbound HTTP/SSE requests to arbitrary URLs — including internal/metadata endpoints (e.g. 169.254.169.254, internal services, cloud metadata IMDS). Unlike the sandbox probe, this runs on a more privileged pod, and the test endpoint makes probing trivial and side-effect-free, which lowers the bar for abuse.
Mitigations to consider (at minimum, document the threat model):
- URL scheme allow-listing (only
http/https, reject169.254.x.x,127.0.0.1, RFC1918 ranges — depending on whether internal servers are a legitimate target). - A configurable outbound allow-list / proxy or a network policy constraining egress from the app-server pod.
- Per-user rate limiting to prevent port-scanning via repeated
timeoutvsconnectionresponses.
This deserves a deliberate decision, not just an acknowledged note.
5. Secret scrubbing robustness
_scrub_secrets replaces secret substrings via plain str.replace. The test (test_scrubs_secrets_from_failure_text) asserts both STORED_TOKEN not in body['error'] and REDACTED in body['error'] — good. Edge case: if an upstream server echoes a secret with encoding/escaping (URL-encoded, JSON-escaped, or split across lines), str.replace won't catch it. Low likelihood for bearer tokens in error text, but if secrets can appear in tool_result.text (e.g. a tool echoing a header), consider normalizing or scrubbing common encodings. Not a blocker.
6. _collect_secret_values uses zip(..., strict=False)
Walking the plaintext dump against the redacted dump with strict=False means mismatched list lengths silently skip secrets. Since both dumps come from the same MCPServer model the structure should match, but if a future variant emits different-length redacted vs plaintext arrays, secrets could be missed. strict=True would be safer if structures are guaranteed identical; otherwise assert length equality in tests. Low risk.
🟢 Frontend
7. use-test-mcp-server.ts serialization mirrors the save path — excellent. Reusing updatedRemoteServer and withExplicitMcpAuthClear from the update hook guarantees the test payload == the save payload. The tests assert this explicitly ("unchanged redacted credential" and "key removed" cases).
8. Double guard for stdio — the form hides the button (canTest = sse|shttp) and the hook throws on stdio. Defensive and correct; keep both.
9. testMessage memo + resetTest — resetTest() is called on closeServerModal, handleEditClick, and the add button, preventing stale error/success messages from a previous test leaking into a new server edit. Good.
10. server.url! non-null assertion in the hook — relies on the form's validateForm. Currently safe (only called from the validated form), but a defensive if (!server.url) throw at the top of mutationFn would make the contract explicit if handleTestServer is ever called from a path that skips validation.
11. MCPTestRequest.server: Record<string, unknown> — loose frontend typing mirrors the backend dict[str, Any]. If the backend is tightened to a Pydantic model (point 2), generate or share the type from it.
🧪 Tests
12. Coverage is strong — backend: success, secret restore, redaction-drop-without-stored-server, stdio rejection, OAuth unsupported, invalid request, secret scrubbing in both failure and tool-result text. Frontend: button visibility by type, validation-before-test, payload shape for new/edited/key-removed, inline result without save, failure messaging.
13. Missing case: the timeout error_kind path — the frontend testMessage switch handles timeout/connection/default; there's a test for connection, but none asserting the timeout branch renders SETTINGS$MCP_TEST_ERROR_TIMEOUT. Minor.
14. No test for concurrent/repeated test clicks — isTestPending disables the button, but there's no test asserting the button is disabled mid-flight. Minor.
📝 Misc
15. i18n — 6 new keys across all 15 locales. Structure and interpolation ({{count}} / {{-error}}) are consistent. {{-error}} correctly uses the unescaped form since error text may contain formatting.
16. Docstring quality — the mcp_test_router.py module docstring clearly explains the differences from the sandbox endpoint. Exactly the kind of context that belongs here.
17. loop.run_in_executor(None, ...) — uses the unbounded default ThreadPoolExecutor. Fine for a settings-page action, but if this route is ever exposed more broadly, consider a bounded executor or an async probe. Low priority.
Verdict
Solid, mergeable feature work. Two items I'd want addressed before merge:
- #4 (SSRF): at minimum a documented threat-model note + ideally an egress/RFC1918 consideration, since this runs on the app-server pod for an enterprise product.
- #2 (typed request body): improve the OpenAPI contract and reduce manual validation, or add a comment explaining why the dict is intentional.
Everything else is non-blocking polish.
This review was created by an AI agent (OpenHands) on behalf of the reviewer.
Address review feedback on POST /api/v1/mcp/test: - Reject probe targets that must never be reached from the app-server pod: only http/https URLs are accepted, and hosts that resolve to loopback, link-local (instance metadata), unspecified, multicast or reserved addresses, including IPv4-mapped IPv6 forms, are refused with 422. Private networks stay reachable because self-hosted deployments run their MCP servers there. MCP_TEST_ALLOW_LOCAL_TARGETS=true disables the address check for local development. The threat model is documented in the module docstring. - Accept a typed MCPTestRequestBody so the OpenAPI schema documents the request and FastAPI validates the top-level fields; the server entry stays an untyped map so redacted secrets can be restored before the SDK validates it. - Walk the secret dumps with zip(strict=True) and also scrub URL-encoded and JSON-escaped forms of restored secrets from the response text. - Require a server URL explicitly in the frontend test hook and document the request type. - Cover the new target guard, encoded-secret scrubbing, every failure kind's message, and the disabled buttons while a test is pending.
|
Hello @tofarr, I have updated the code based on your feedback. Thank you very much for taking the time to review and provide your valuable feedback! 🙏 |
The "PR Artifacts" workflow's cleanup-on-approval job runs `git rm -rf .pr/` on approval, so approving this PR deleted `.pr/neo-theme-component-audit.md` (commit 1fcc5a4). That file is design-update's, inherited from the base branch, not an artifact of this PR, and deleting it is unrelated to the MCP test route. Restore it from design-update.
#174) * feat(frontend): add OpenHands-Neo theme tokens and scoped UI root Wire agent-canvas-style --oh-* / cool-grey tokens, AgentServerUIRoot, and neo palette application so the SaaS shell can share the same theme foundation. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): add shared settings and form layout class helpers Port agent-canvas layout utilities so settings-like pages can reuse the same form, list, and sidebar spacing classes. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): restyle settings navigation for OpenHands-Neo Match agent-canvas settings chrome with tokenized nav links, logo header, bottom user menu, and settings-owned gutters. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): tokenize organization settings pages for neo theme Restyle org management, members list, and git org rows with shared settings list/form tokens and updated mocks/tests. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): tokenize budgets and usage dashboard for neo theme Replace hardcoded greys with base/surface/muted/primary tokens so budgets and usage monitoring match agent-canvas. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): tokenize shared chrome components for neo theme Update spinners, badges, chips, context menus, and related shell controls to use --oh-* / muted tokens instead of hardcoded greys. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): align toast handlers with agent-canvas Use neo toast tokens, custom CircleX error layout, loading helper, and route call sites through the shared handlers. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(openhands-ui): restyle toasterMessages for neo theme Replace the pill toast chrome with agent-canvas-aligned surface, border, radius, and status icon colors. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: add neo theme component audit notes Track remaining hardcoded hex surfaces for follow-up tokenization work. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): align settings shell and neo theme chrome Restyle the settings rail (sidebar, drawer, white brand mark), forms, integrations, and related surfaces to match OpenHands-Neo tokens and agent-canvas patterns. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): polish settings nav scope and continue neo UI work Clarify Personal settings as org-scoped (This org chip), fold Integrations and Skills into that section, and move User/Application to the bottom. Continue settings shell, credits, MCP, and chrome alignment. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): refine neo skeletons and select-style dropdown toggle Improve loading skeleton fidelity and stagger, and let non-searchable dropdowns click-open/click-close like other selects. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(frontend): stop LLM profile rows clipping on mobile Override the shared fixed list-row height and keep the Default badge inline with the profile name so stacked mobile content no longer overflows the overflow-hidden profiles list. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(frontend): align settings tests with neo UI behavior Update frontend tests for neo chrome (toasts, dropdowns, budgets, git settings) and show the org-wide badge on budgets/credits. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(frontend): rename settings nav brand label to Account Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): land on Agent Canvas instead of settings Agent Canvas is served at /canvas next to the enterprise app, so the root route (and therefore the default post-login destination) should open it rather than the settings shell. - replace the settings index redirect with a landing route that does a document-level replace to /canvas (a router redirect would bounce through the SPA's own canvas/* route and leave / in history) - keep the route inside the root layout so auth, guards and the login_method callback still run before leaving the app - keep invitation links (/?invitation_token=...) in the settings shell so the token is captured and auto-accepted instead of dropped * fix: scope LLM API key query by organization ID (#282) * fix: hide quota reset timer for unlimited quotas (#280) * fix: honor ?org= deep link to sync the active org on settings pages (#281) * fix(frontend): OHE-3216 display the user profile avatar in the settings nav (#307) The settings-nav user menu rendered UserAvatar without the git user's avatar_url or fetch state, so it always showed the placeholder icon even when a profile picture was available. This restores the wiring dropped in 77bb8f2, matching the legacy sidebar: show the picture when present, the placeholder otherwise, and a spinner while the profile is being fetched. Extend the user-menu tests to cover the avatar, placeholder, and loading states. * fix(frontend): OHE-3247 hide quota settings entry when daily limit is unlimited (#343) The Quota entry in the Settings navigation rendered for every SaaS-mode deployment, including self-hosted enterprise installs where no daily conversation limit is configured. The page then only showed "Unlimited" plus a request-increase link. Gate the nav item on the quota status: hide it when `daily_limit` is null, keep it whenever a finite limit is in effect. The status query is only enabled in SaaS mode so OSS builds never call the enterprise-only endpoint from the navigation hook. Includes regression tests for both the configured-limit and unlimited cases. * fix(frontend): OHE-3242 replace history entries on settings guard redirects (#342) Loader redirects in the settings shell (the ?org= strip, the /settings -> /settings/org-defaults hop and the permission fallback) were history pushes, so entering Settings from Agent Canvas in the same tab and pressing Back re-ran the loader and bounced forward again. They now use React Router's replace() so one Back returns to the canvas. * feat: add Test connection for MCP servers on cloud backends (#366) * feat: add Test connection for MCP servers on cloud backends * fix(mcp): harden the MCP test route and type its request body Address review feedback on POST /api/v1/mcp/test: - Reject probe targets that must never be reached from the app-server pod: only http/https URLs are accepted, and hosts that resolve to loopback, link-local (instance metadata), unspecified, multicast or reserved addresses, including IPv4-mapped IPv6 forms, are refused with 422. Private networks stay reachable because self-hosted deployments run their MCP servers there. MCP_TEST_ALLOW_LOCAL_TARGETS=true disables the address check for local development. The threat model is documented in the module docstring. - Accept a typed MCPTestRequestBody so the OpenAPI schema documents the request and FastAPI validates the top-level fields; the server entry stays an untyped map so redacted secrets can be restored before the SDK validates it. - Walk the secret dumps with zip(strict=True) and also scrub URL-encoded and JSON-escaped forms of restored secrets from the response text. - Require a server URL explicitly in the frontend test hook and document the request type. - Cover the new target guard, encoded-secret scrubbing, every failure kind's message, and the disabled buttons while a test is pending. * chore: Remove PR-only artifacts [automated] * chore: restore the design-update PR artifact this branch deleted The "PR Artifacts" workflow's cleanup-on-approval job runs `git rm -rf .pr/` on approval, so approving this PR deleted `.pr/neo-theme-component-audit.md` (commit 1fcc5a4). That file is design-update's, inherited from the base branch, not an artifact of this PR, and deleting it is unrelated to the MCP test route. Restore it from design-update. --------- Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com> * fix(frontend): align budgets and user-actions tests with neo UI and quota polling The budgets override test added on main selected the row action by its old "Edit" text. The neo UI renders it as an icon button labelled "Edit budget for <name>", so use that accessible name, matching the sibling override test. The user-actions menu close delay tests drained timers with runAllTimersAsync. The settings nav hook now polls the quota status, which puts a refetch interval in the UserActions tree, so draining all timers never terminates. Flush only the pending timers instead. * chore: Remove PR-only artifacts [automated] * chore: re-trigger PR checks after automated artifact cleanup The automated .pr/ cleanup commit was pushed with the workflow token, so the pull_request_target title lint never ran on it and the required check stayed unreported. This empty commit re-triggers it. --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: hieptl <hieptl.developer@gmail.com> Co-authored-by: Hiep Le <69354317+hieptl@users.noreply.github.com> Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com>
* feat(frontend): add OpenHands-Neo theme tokens and scoped UI root Wire agent-canvas-style --oh-* / cool-grey tokens, AgentServerUIRoot, and neo palette application so the SaaS shell can share the same theme foundation. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): add shared settings and form layout class helpers Port agent-canvas layout utilities so settings-like pages can reuse the same form, list, and sidebar spacing classes. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): restyle settings navigation for OpenHands-Neo Match agent-canvas settings chrome with tokenized nav links, logo header, bottom user menu, and settings-owned gutters. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): tokenize organization settings pages for neo theme Restyle org management, members list, and git org rows with shared settings list/form tokens and updated mocks/tests. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): tokenize budgets and usage dashboard for neo theme Replace hardcoded greys with base/surface/muted/primary tokens so budgets and usage monitoring match agent-canvas. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): tokenize shared chrome components for neo theme Update spinners, badges, chips, context menus, and related shell controls to use --oh-* / muted tokens instead of hardcoded greys. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): align toast handlers with agent-canvas Use neo toast tokens, custom CircleX error layout, loading helper, and route call sites through the shared handlers. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(openhands-ui): restyle toasterMessages for neo theme Replace the pill toast chrome with agent-canvas-aligned surface, border, radius, and status icon colors. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: add neo theme component audit notes Track remaining hardcoded hex surfaces for follow-up tokenization work. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): align settings shell and neo theme chrome Restyle the settings rail (sidebar, drawer, white brand mark), forms, integrations, and related surfaces to match OpenHands-Neo tokens and agent-canvas patterns. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): polish settings nav scope and continue neo UI work Clarify Personal settings as org-scoped (This org chip), fold Integrations and Skills into that section, and move User/Application to the bottom. Continue settings shell, credits, MCP, and chrome alignment. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): refine neo skeletons and select-style dropdown toggle Improve loading skeleton fidelity and stagger, and let non-searchable dropdowns click-open/click-close like other selects. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(frontend): stop LLM profile rows clipping on mobile Override the shared fixed list-row height and keep the Default badge inline with the profile name so stacked mobile content no longer overflows the overflow-hidden profiles list. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(frontend): align settings tests with neo UI behavior Update frontend tests for neo chrome (toasts, dropdowns, budgets, git settings) and show the org-wide badge on budgets/credits. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(frontend): rename settings nav brand label to Account Co-authored-by: Cursor <cursoragent@cursor.com> * feat(frontend): land on Agent Canvas instead of settings Agent Canvas is served at /canvas next to the enterprise app, so the root route (and therefore the default post-login destination) should open it rather than the settings shell. - replace the settings index redirect with a landing route that does a document-level replace to /canvas (a router redirect would bounce through the SPA's own canvas/* route and leave / in history) - keep the route inside the root layout so auth, guards and the login_method callback still run before leaving the app - keep invitation links (/?invitation_token=...) in the settings shell so the token is captured and auto-accepted instead of dropped * fix: scope LLM API key query by organization ID (#282) * fix: hide quota reset timer for unlimited quotas (#280) * fix: honor ?org= deep link to sync the active org on settings pages (#281) * fix(frontend): OHE-3216 display the user profile avatar in the settings nav (#307) The settings-nav user menu rendered UserAvatar without the git user's avatar_url or fetch state, so it always showed the placeholder icon even when a profile picture was available. This restores the wiring dropped in 77bb8f2, matching the legacy sidebar: show the picture when present, the placeholder otherwise, and a spinner while the profile is being fetched. Extend the user-menu tests to cover the avatar, placeholder, and loading states. * fix(frontend): OHE-3247 hide quota settings entry when daily limit is unlimited (#343) The Quota entry in the Settings navigation rendered for every SaaS-mode deployment, including self-hosted enterprise installs where no daily conversation limit is configured. The page then only showed "Unlimited" plus a request-increase link. Gate the nav item on the quota status: hide it when `daily_limit` is null, keep it whenever a finite limit is in effect. The status query is only enabled in SaaS mode so OSS builds never call the enterprise-only endpoint from the navigation hook. Includes regression tests for both the configured-limit and unlimited cases. * fix(frontend): OHE-3242 replace history entries on settings guard redirects (#342) Loader redirects in the settings shell (the ?org= strip, the /settings -> /settings/org-defaults hop and the permission fallback) were history pushes, so entering Settings from Agent Canvas in the same tab and pressing Back re-ran the loader and bounced forward again. They now use React Router's replace() so one Back returns to the canvas. * feat: add Test connection for MCP servers on cloud backends (#366) * feat: add Test connection for MCP servers on cloud backends * fix(mcp): harden the MCP test route and type its request body Address review feedback on POST /api/v1/mcp/test: - Reject probe targets that must never be reached from the app-server pod: only http/https URLs are accepted, and hosts that resolve to loopback, link-local (instance metadata), unspecified, multicast or reserved addresses, including IPv4-mapped IPv6 forms, are refused with 422. Private networks stay reachable because self-hosted deployments run their MCP servers there. MCP_TEST_ALLOW_LOCAL_TARGETS=true disables the address check for local development. The threat model is documented in the module docstring. - Accept a typed MCPTestRequestBody so the OpenAPI schema documents the request and FastAPI validates the top-level fields; the server entry stays an untyped map so redacted secrets can be restored before the SDK validates it. - Walk the secret dumps with zip(strict=True) and also scrub URL-encoded and JSON-escaped forms of restored secrets from the response text. - Require a server URL explicitly in the frontend test hook and document the request type. - Cover the new target guard, encoded-secret scrubbing, every failure kind's message, and the disabled buttons while a test is pending. * chore: Remove PR-only artifacts [automated] * chore: restore the design-update PR artifact this branch deleted The "PR Artifacts" workflow's cleanup-on-approval job runs `git rm -rf .pr/` on approval, so approving this PR deleted `.pr/neo-theme-component-audit.md` (commit 1fcc5a4). That file is design-update's, inherited from the base branch, not an artifact of this PR, and deleting it is unrelated to the MCP test route. Restore it from design-update. --------- Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com> * feat(mcp): run OAuth MCP installs from the app server OAuth-based MCP servers (Atlassian Rovo, GitLab, Figma and ~20 more catalog entries) could only be installed against a local agent-server. Its OAuth client publishes a loopback redirect URI, http://localhost:<port>/callback, and serves that callback from its own process, so a browser talking to a hosted backend can never complete the handshake. Agent Canvas refused the install outright with "OAuth authorization requires a reachable local backend." Add the hosted counterpart: - POST /api/v1/mcp/oauth/start validates the candidate server exactly like POST /api/v1/mcp/test (redacted-secret restore, remote transports only, SSRF guard), then runs the SDK probe on a worker thread with an OAuth client whose redirect URI is this server's own public callback, and answers with the provider's authorization URL. - GET /api/v1/mcp/oauth/status/{job_id} reports progress and, on success, the OAuth state the caller persists in settings. Unknown, expired and other users' jobs are indistinguishable 404s. - GET /api/v1/mcp/oauth/callback receives the provider's redirect and hands the authorization code to the waiting probe. It is unauthenticated and allowlisted in SetAuthCookieMiddleware because the cross-site navigation carries no session cookie (production cookies are SameSite=strict); the single-use state parameter generated by the MCP client identifies the job. Jobs live in Redis under a 15-minute TTL so the callback and the status polls can land on any app server replica while the probe thread stays on the replica that started it. The stored probe result carries OAuth tokens and is encrypted at rest with the app server's JWT service. Request preparation shared with the connection-test route moves into prepare_probe_request; POST /api/v1/mcp/test behaviour is unchanged. Part of OHE-3249. * fix: remove .pr --------- Co-authored-by: FraterCCCLXIII <panentheum@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com>
HUMAN:
AGENT:
Why
When a user adds an MCP server through Settings → MCP on a cloud or self-hosted enterprise deployment, nothing tells them whether it connects. A misconfigured server (wrong URL, bad token, unreachable host) is silently skipped when the conversation starts — the fastmcp composite client swallows per-server failures and the built-in
defaultserver keeps the conversation alive — so the server's tools are just absent, with no error or guidance (OHE-2479, raised by C24 via CS-3 ahead of onboarding ~150 engineers).The root cause is that the cloud backend has no MCP test endpoint: the only prober (
POST /api/mcp/test) lives inside the sandbox agent-server, which the settings page cannot reach because no conversation or sandbox exists there. The bundled settings UI had no test affordance at all.Summary
POST /api/v1/mcp/test(openhands/app_server/mcp/mcp_test_router.py) that reuses the SDK's single-server probe in-process with the same response contract as the sandbox endpoint: remote transports only (stdio → 422), redacted secrets restored from the stored server before probing (same rules asPOST /api/v1/settings) and scrubbed from the response, OAuth2 servers answered with a structured failure.use-test-mcp-server.ts,mcp-server-form.tsx,mcp-server-modal.tsx,routes/mcp-settings.tsx, sixSETTINGS$MCP_TEST_*keys in all 15 locales).Issue Number
https://linear.app/all-hands-ai/issue/OHE-2479/ohe-improve-mcp-setup-feedback-when-a-server-cannot-connect
How to Test
poetry install, thenpoetry run pytest -q tests/unit/app_server/test_mcp_test_router.py.cd frontend && npm run dev, open Settings → MCP → Add Server (or Edit an existing SSE/SHTTP server), fill the URL, click Test connection. Expect "Connected — N tool(s) available" or a timeout/connection/unknown message inline; the modal stays open and nothing is saved. Editing a stored server and testing with the key field left as**********uses the stored credential. Switching the type to stdio hides the button.cd frontend && npm run lint && npx vitest run __tests__/routes/mcp-settings.test.tsx __tests__/components/features/settings/mcp-settings __tests__/hooks/mutation/use-mcp-server-mutations.test.tsx.Video/Screenshots
N/A.
Type
Enterprise server image for this PR: