fix(ui): use stored-credentials endpoint for tools fetch on MCP edit page - #26002
Conversation
…page The edit page was calling POST /mcp-rest/test/tools/list (the temp-session endpoint that requires inline credentials) on mount. Since fetchTools deliberately omits credentials from the request body, any server with auth_type api_key/bearer_token/basic/authorization would 422. Switch to GET /mcp-rest/tools/list?server_id=... which looks up stored credentials on the backend — no inline creds needed for saved servers.
Greptile SummaryThis PR fixes a 422 error on the MCP server edit page by replacing the on-mount tool fetch ( Confidence Score: 5/5Safe to merge — the change is narrowly scoped, replaces a broken endpoint call with a correct one, and all 94 tests pass. No P0 or P1 issues found. The logic is correct: the GET endpoint uses stored credentials server-side so no inline auth is needed; guards for URL/OAuth token are correctly removed since the backend handles those; error state is properly surfaced through toolsError. The OAuth UX regression (tools not auto-refreshing after interactive token receipt) was noted in a prior review thread and is intentionally out of scope here. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx | Switches on-mount tool fetch to GET /mcp-rest/tools/list via listMCPTools; removes unnecessary inline-credential guards; adds toolsError state and passes external tool state to MCPToolConfiguration |
| ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx | Updates mock from testMCPToolsListRequest to listMCPTools to match the production code change; existing test coverage and assertions are unaffected |
Sequence Diagram
sequenceDiagram
participant UI as MCPServerEdit (mount)
participant FT as fetchTools()
participant NET as listMCPTools()
participant BE as GET /mcp-rest/tools/list
UI->>FT: useEffect([mcpServer, accessToken])
FT->>NET: listMCPTools(accessToken, server_id)
NET->>BE: GET /mcp-rest/tools/list?server_id={id}
BE-->>NET: {tools:[...]}
NET-->>FT: {tools:[...], error:null}
FT->>UI: setTools(tools) / setToolsError(msg)
UI->>UI: MCPToolConfiguration externalTools={tools}
note over UI: useTestMCPConnection inside MCPToolConfiguration disabled (enabled=false) when externalTools provided
Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
| useEffect(() => { | ||
| // Don't fetch if server hasn't been saved yet (no permanent server_id) | ||
| if (!mcpServer.server_id || mcpServer.server_id.trim() === "") { | ||
| return; | ||
| } | ||
| fetchTools(); | ||
| }, [mcpServer, accessToken, oauthAccessToken]); | ||
| }, [mcpServer, accessToken]); |
There was a problem hiding this comment.
OAuth interactive flow: tools no longer refresh after token receive
Removing oauthAccessToken from the dep array is correct for the GET-based fetch, but as a side effect, interactive OAuth servers that complete the in-page OAuth flow (via "Authorize & Fetch Token") will no longer see an automatic tool refresh after the token arrives. Previously the effect re-ran with the new token and called the POST endpoint; now the user would need to save the server and re-open the edit page. This is a minor UX regression worth documenting, even if the "Test Connection" button covers the live-test use case.
|
@ryan-crabbe-berri — could you add a screenshot or short video showing that this change works as expected? It really helps reviewers verify the fix quickly. Thanks! |
Pass externalTools/externalIsLoading/externalError/externalCanFetch from the edit page so MCPToolConfiguration consumes the parent's GET fetch instead of firing its own POST /test/tools/list via useTestMCPConnection. Eliminates the spurious POST that caused the user-visible "Unable to load tools" error for api_key/bearer_token/basic/authorization servers.
…itellm_fix-edit-page-tools-fetch-422
Low: No security issuesThis PR refactors the MCP server edit page to fetch tools via the stored-credentials GET endpoint ( Status: 0 open Posted by Veria AI · 2026-04-26T00:13:24.523Z |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
d120ddf
into
litellm_internal_staging
…ools-fetch-422 fix(ui): use stored-credentials endpoint for tools fetch on MCP edit page
Summary
The MCP server edit page (
mcp_server_edit.tsx) was firing a spuriousPOST /mcp-rest/test/tools/liston mount to populate the Tool Configuration panel. That endpoint is the temp-session preview path — it requires inline credentials in the request body — but the on-mount fetch deliberately omitted them. For any saved server withauth_typeofapi_key/bearer_token/basic/authorization, the call hit the upstream MCP without auth and the panel surfaced "Unable to load tools — Failed to connect to MCP server."This PR redirects the edit page through the stored-credentials path:
Edit page's local fetch → switched from
testMCPToolsListRequest(POST/mcp-rest/test/tools/list) tolistMCPTools(GET/mcp-rest/tools/list?server_id=...), which looks up stored credentials on the backend byserver_id. No inline creds needed.Tool Configuration panel → now consumes the parent's GET-fetched tools via the existing
externalTools/externalIsLoading/externalError/externalCanFetchprops onMCPToolConfiguration, so its internaluseTestMCPConnectionhook (which still POSTs without creds) is bypassed on the edit flow. Without this second wiring the spurious POST and the user-visible "Unable to load tools" error would still happen — see commitebffbd1a.The
POST /test/tools/listendpoint anduseTestMCPConnectionhook remain in use for the live "Test Connection" path (testing unsaved config in the create flow), which is unchanged.screenshots
before

after

Test plan
vitest run src/components/mcp_tools/)X-API-Keyauth:demo_api_key_serverregistered with storedcredentials.auth_valuematching the mock's expected keypingtool with "1 of 1 tool enabled for user access" (previously: red "Unable to load tools")GET /mcp-rest/tools/list?server_id=...→ 200 (previously: also firedPOST /mcp-rest/test/tools/listthat failed)useTestMCPConnection→POST /test/tools/listwith inline creds from the form)