Repository navigation
Conversation
3 of 5 tasks
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.
Fixes #45210
Summary
When modifying an existing MCP Server's configuration (such as server name, identifier, icon, timeout, or headers), the frontend submits the masked
client_id(e.g.,ba****c2) andclient_secret(******) in the authentication payload.Prior to this change:
_merge_credentials_with_maskedinMCPToolManageServicelooked forclient_idandclient_secretat the top level ofexisting_decrypted, where they are absent because credentials are saved under nestedclient_information(with secrets encrypted). As a result, the lookup failed and returned the masked placeholder string._process_credentialsunconditionally called_build_and_encrypt_credentials, which rewroteencrypted_credentialsto a minimal dictionary withis_dynamic_registration: False, overwriting the real UUID with the masked placeholder (ba****c2), discarding dynamic client registration metadata, and erasing active OAuth tokens."Client not found".Changes Made:
services/tools/mcp_tools_manage_service.py:_merge_credentials_with_maskedto extract existing unmasked credentials frommcp_provider_entity.retrieve_client_information()(or fallback to top-level if present), correctly restoring unmaskedclient_idand decryptedclient_secretwhen masked placeholders are submitted._process_credentialsto detect when credentials have not changed and preserve existingmcp_provider.encrypted_credentialsintact (maintaining active access/refresh tokens, DCR metadata, and dynamic registration flags).update_providerto preserveauthedstatus and tools when credentials are unchanged, and resetauthed = Falsewithtools = EMPTY_TOOLS_JSONonly when credentials actually change.core/mcp/auth/auth_flow.py:client_informationcontains asterisks inclient_id(from past corrupted edits) and authorization code exchange is not in progress (authorization_code is None), dynamically re-registers the client with the OAuth server to acquire and persist a fresh valid client ID.tests/unit_tests/services/tools/test_mcp_tools_manage_service.pyverifying masked credentials restoration, unchanged credentials preservation, parameter updates without breaking active OAuth credentials/tools, and credential change resets.tests/unit_tests/core/mcp/auth/test_auth_flow.pyverifying self-healing of corrupted masked client IDs and code exchange rejection.Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods