Repository navigation
fix(mcp): validate MCP service server names and masked values on save - #37565
Conversation
An MCP service's servers are matched to their stored settings by name. Require server names to be unique, and refuse a masked value that has no stored value under the same server (e.g. after a rename), so the caller is asked to enter it again instead of the placeholder being kept.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
…r-name-validation
The unique-name check now runs when the servers list differs from the stored one in anything but the keys, order included, not only when the names change. A service saved with repeated server names keeps saving edits outside its servers.
…r-name-validation
…r-name-validation
Code Review ✅ Approved 🔴 High riskChanging service-connection secret restoration and MCP server-name validation could reject full-body updates that rename servers while retaining masked credentials. Tightens MCP service saves by rejecting duplicate server names and masked secret values with no stored value behind them, returning 400 instead of saving placeholders. No issues found. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| McpService stored = | ||
| update | ||
| ? findByNameOrNull(FullyQualifiedName.quoteName(service.getName()), Include.ALL) | ||
| : null; | ||
| if (stored == null || !servers.equals(serversWithoutKeys(stored))) { |
There was a problem hiding this comment.
Ignored name changes block edits
The lookup uses the patched service name before PATCH restores fields that cannot change. On a legacy service with duplicate server names, a PATCH containing /name and /description looks up the new name, finds nothing, and rejects the unchanged servers. Previously, the name was ignored and the description saved.
Use the stored ID for PATCH comparisons, with the name lookup as a fallback for PUT.
…#37565) * fix(mcp): validate MCP service server names and masked values on save An MCP service's servers are matched to their stored settings by name. Require server names to be unique, and refuse a masked value that has no stored value under the same server (e.g. after a rename), so the caller is asked to enter it again instead of the placeholder being kept. * fix(mcp): check server names whenever a service's servers change The unique-name check now runs when the servers list differs from the stored one in anything but the keys, order included, not only when the names change. A service saved with repeated server names keeps saving edits outside its servers. (cherry picked from commit 58f1774)
…ed in plain text (#38118) * Encrypt the connection secrets that are still saved in plain text - SSIS: type databaseConnection through the MSSQL converter, so its sslConfig and authType are typed and encrypted. - Qlik Sense certificates: its oneOf branches were inline definitions, which jsonschema2pojo generates no class for; move them to their own schema files (titles unchanged) and register a converter. - migrate now re-encrypts stored workflows (Test Connection requests) the way it does services; the unused updateWorkflow also saved through the wrong DAO. - The coverage test also checks typed connection properties whose own oneOf holds secrets, which is how SSIS slipped through. * Encrypt SAP S/4HANA authType secrets Its oneOf branches were inline definitions with no generated class; move them to dashboard/sapS4Hana/{basicAuth,oAuthCredentials}.json (titles and javaTypes unchanged) and register a converter. KNOWN_UNCONVERTIBLE is now empty. The generated Python classes move with them: Collate's SAP S/4HANA connector imports them, so it needs the matching import change. * Mask and encrypt secrets nested in collections Backport of the secrets part of #33477: the masker and the secrets manager now walk lists, so mcpConnection.servers[].apiKey is masked and encrypted, and awsSessionToken, Fivetran apiKey and GCP privateKeyId are password fields; the ingestion code that reads them unwraps the SecretStr. * Encrypt sample data storage and Delta Lake metastore secrets Both sat below a oneOf whose branches had no generated class, so they were saved in plain text and returned unmasked to editors. - dataStorageConfig moves out of connectionBasicType.json into its own schema; the converter factory wraps every connection that carries a sampleDataStorageConfig so its config, and the S3 credentials in it, are typed after the connection's own converter runs. - Delta Lake's metastore connection branches move to deltalake/metastore/*.json and get a converter. configSource tries StorageConfig first: both accept a connection, but only StorageConfig rejects the other kind. - The ingestion code imports the moved classes from their new modules. - KNOWN_UNCONVERTIBLE is now empty. - The new Qlik Sense and SAP S/4HANA schema files use draft-07, like 2.0. * Re-encrypt soft-deleted services and workflows, and record the oneOf split rule # Conflicts: # openmetadata-service/src/test/java/org/openmetadata/service/secrets/converter/NestedSecretConverterCoverageTest.java * Encrypt Delta Lake storage secrets saved as a metastore config * Test that migrate re-encrypts soft-deleted services and workflows (cherry picked from commit 80cd51f) * fix(mcp): validate MCP service server names and masked values on save (#37565) * fix(mcp): validate MCP service server names and masked values on save An MCP service's servers are matched to their stored settings by name. Require server names to be unique, and refuse a masked value that has no stored value under the same server (e.g. after a rename), so the caller is asked to enter it again instead of the placeholder being kept. * fix(mcp): check server names whenever a service's servers change The unique-name check now runs when the servers list differs from the stored one in anything but the keys, order included, not only when the names change. A service saved with repeated server names keeps saving edits outside its servers. (cherry picked from commit 58f1774) * Key collection secrets by position when names clash once cleaned into a secret id (cherry picked from commit b7cf316) * Cache sample data holders per class, and import the Delta Lake metastore candidates * Match masked list secrets by exact name, and keep only secret ids distinct once cleaned (cherry picked from commit c17a39c) * Test soft-deleted re-encryption on stored rows instead of mocks (cherry picked from commit 1358ee7) * Keep list secret ids stable when names clash once cleaned A position id moved when servers were reordered, so replacing or clearing one key wrote over, or deleted, the secret the other server still referenced. Such names now get an id from a hash of the exact name. * Use final locals, getFirst, a getter constant and immutable keys * Hash a name that looks like a hashed secret id too * Revert privateKeyId from password format back to plain string (#33889) * Revert privateKeyId from password format back to plain string an identifier, not a secret; restore it to a plain string in the spec, the generated UI schemas, and build_google_credentials_dict. * Update generated TypeScript types and dereferenced schemas --------- Co-authored-by: Rohit Jain <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Sort imports in the timescale sampler * Move a list secret to its element's own id when the element is renamed or moved A save kept an existing secret reference, so a renamed MCP server still read its old name's secret and a server later added under that name overwrote it. Before a list is written, a reference to another element's secret is read back into its value and stored under the element's own id. A reference that cannot be read is kept. * Put back a secret a move overwrote when the save fails A move read every source first, which protects a save that succeeds; one that failed part way could leave a server reading another's key. The value at the element's own id is now read as well and written back if the save fails, and a refused value is rejected before any key moves. * Revert "Put back a secret a move overwrote when the save fails" This reverts commit 69e14b9. * Revert "Move a list secret to its element's own id when the element is renamed or moved" This reverts commit 08529fa. * Question-form boolean names, one return in the masker walk, specific workflow catch * Five parameters at most in the masker walk, descriptive name in the element walk --------- Co-authored-by: sonika-shah <[email protected]> Co-authored-by: Rohit Jain <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Describe your changes:
Tracking: open-metadata/openmetadata-collate#7962
An MCP service's
serversare matched back to their stored settings by server name. This makes saving an MCP service stricter about the two cases where that match is ambiguous:serverschange in anything but their keys (order included), with two servers sharing anamenow returns 400. An update that leavesserversas stored is not checked, so existing services stay editable outside their servers.*********for a field where no stored value exists under the same key (e.g. a server renamed in a full-body PUT) now returns 400 asking for the actual value, instead of saving the placeholder.Decision record:
ADR:2026-11-11-mcp-service-server-names-are-unique-and-masks-need-a-stored-valueType of change:
High-level design:
N/A — small change (masker + MCP service repository + tests + decision record).
Tests:
Use cases covered
Unit tests
PasswordEntityMaskerTest.testMaskedSecretWithNoStoredValueIsRejected— fails onmain(nothing thrown), passes here.Backend integration tests
McpServiceResourceIT.post_mcpServiceWithDuplicateServerNames_400McpServiceResourceIT.put_renamedServerWithMaskedApiKey_400_keepsStoredKeyMcpServiceResourceIT.put_reorderedStoredServersWithSameName_400_otherEditsStillSave— fails on the previous commit (the reorder saves), passes here.Run locally (MySQL + Elasticsearch 9.3, embedded server):
McpServiceResourceIT— 213 run, 0 failures (35 skipped by the base class), at the head commit.PasswordEntityMaskerTest— 28 run, 0 failures, at the head commit; withConnectionSecretsGuardTest, 58 run, 0 failures, at the previous commit.Checklist:
Fixes <issue-number>: <short explanation>— not applicable, tracked internally.Details
PasswordEntityMasker.unmaskServiceConnectionConfigwalks the incoming config with the same traversal used to build the stored-value map; a masked field with no entry under its key throwsEntityMaskExceptionwith status 400. Both PUT (ServiceEntityResource.unmask) and PATCH (restorePatchSecrets) surface it as 400.McpServiceRepository.preparechecks server-name uniqueness on create, and on update whenever the servers differ from the stored service apart from theirapiKey, order included (the stored service is looked up by name, since a PUT reachespreparebefore the stored id is applied).The PR appears safe to merge, with two non-blocking update edge cases worth fixing.
Findings
Summary
This PR rejects duplicate MCP server names when servers change and rejects masked credentials without a matching stored value.
Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile