Skip to content

fix(mcp): validate MCP service server names and masked values on save - #37565

Merged
sonika-shah merged 5 commits into
mainfrom
fix/mcp-service-server-name-validation
Nov 16, 2026
Merged

sonika-shah merged 5 commits into
mainfrom
fix/mcp-service-server-name-validation

Conversation

@sonika-shah

@sonika-shah sonika-shah commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Tracking: open-metadata/openmetadata-collate#7962

An MCP service's servers are 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:

  • Duplicate server names — creating a service, or updating one so its servers change in anything but their keys (order included), with two servers sharing a name now returns 400. An update that leaves servers as stored is not checked, so existing services stay editable outside their servers.
  • A masked value with nothing stored behind it — a service connection update that sends ********* 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-value

Type of change:

  • Bug fix

High-level design:

N/A — small change (masker + MCP service repository + tests + decision record).

Tests:

Use cases covered

  • Create an MCP service with two servers of the same name → 400.
  • PUT an MCP service that renames a server and sends its key masked → 400, and the stored server and key are unchanged.
  • A service stored with two servers of the same name: a PUT that reorders them → 400; a PUT that changes only the description saves, and each server keeps its key.
  • Existing masker round-trips (rename-free edits, reorders with unique names, deletes, duplicates already stored) still restore every key.

Unit tests

  • PasswordEntityMaskerTest.testMaskedSecretWithNoStoredValueIsRejected — fails on main (nothing thrown), passes here.

Backend integration tests

  • McpServiceResourceIT.post_mcpServiceWithDuplicateServerNames_400
  • McpServiceResourceIT.put_renamedServerWithMaskedApiKey_400_keepsStoredKey
  • McpServiceResourceIT.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; with ConnectionSecretsGuardTest, 58 run, 0 failures, at the previous commit.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation> — not applicable, tracked internally.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: N/A.
  • I have added tests around the new logic.
Details
  • PasswordEntityMasker.unmaskServiceConnectionConfig walks the incoming config with the same traversal used to build the stored-value map; a masked field with no entry under its key throws EntityMaskException with status 400. Both PUT (ServiceEntityResource.unmask) and PATCH (restorePatchSecrets) surface it as 400.
  • Only service connections are affected. Ingestion pipelines, bots and test-connection workflows keep their current unmask behaviour.
  • A masked value is only ever produced from a stored non-null value, so a client that sends back what it read is unaffected unless the key it sits under changed.
  • McpServiceRepository.prepare checks server-name uniqueness on create, and on update whenever the servers differ from the stored service apart from their apiKey, order included (the stored service is looked up by name, since a PUT reaches prepare before the stored id is applied).

RetriggerView in GreptileConfidence Score: 4/5

The PR appears safe to merge, with two non-blocking update edge cases worth fixing.

Findings

  1. P2 Masks can become saved credentials ▶
  2. P2 Ignored name changes block edits ▶

Summary

This PR rejects duplicate MCP server names when servers change and rejects masked credentials without a matching stored value.

  • MCP services reject duplicate server names when their server lists change.
  • Service updates reject masked secrets that have no stored match.

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

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.
@sonika-shah
sonika-shah requested a review from a team as a code owner November 11, 2026 11:07
@sonika-shah
sonika-shah requested review from pmbrull and a balanced review from Copilot November 11, 2026 11:07
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 04:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 06:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 05:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 11:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@gitar-bot

gitar-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Changing 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.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Comment on lines +54 to +58
McpService stored =
update
? findByNameOrNull(FullyQualifiedName.quoteName(service.getName()), Include.ALL)
: null;
if (stored == null || !servers.equals(serversWithoutKeys(stored))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@sonika-shah
sonika-shah merged commit 58f1774 into main Nov 16, 2026
60 of 62 checks passed
@sonika-shah
sonika-shah deleted the fix/mcp-service-server-name-validation branch November 16, 2026 12:06
Khairajani pushed a commit that referenced this pull request Nov 19, 2026
…#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)
Khairajani added a commit that referenced this pull request Nov 20, 2026
…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>
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.

3 participants