Skip to content

Fix MCP Knowledge Page creation - #32209

Merged
Vishnuujain merged 3 commits into
mainfrom
fix/mcp-create-entity-knowledge-page
Aug 28, 2026
Merged

Vishnuujain merged 3 commits into
mainfrom
fix/mcp-create-entity-knowledge-page

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #32198

  • Support Knowledge Center pages through create_entity.
  • Preserve upsert authorization and use patch_entity for partial updates.
  • Resolve name-only parent references.

Greptile Summary

The PR adds Knowledge Center Page creation to the generic MCP entity tool while making that tool create-only and directing edits through JSON Patch.

  • Adds Page-specific input validation, defaults, and name-based parent resolution.
  • Uses the repository create lifecycle and converts database uniqueness failures into actionable MCP errors.
  • Aligns the advertised create and patch tool contracts with their implemented behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java Routes generic entity creation through the create-only repository lifecycle, adds Page defaults, and provides duplicate-name guidance.
openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/EntityCreationSpec.java Adds Page support while excluding Page fields maintained by relationships or background processing.
openmetadata-mcp/src/main/resources/json/data/mcp/tools.json Aligns create_entity and patch_entity descriptions and schemas with their implemented create-only and raw-patch contracts.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KnowledgePageRepository.java Resolves name-only parent references before storing the Page containment relationship.
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/KnowledgePageParentResolutionTest.java Covers resolution of name-only Page parents and preservation of already resolved references.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[MCP create_entity input] --> B[Validate fields and references]
  B --> C[Authorize CREATE]
  C --> D[Repository create lifecycle]
  D --> E{Unique name?}
  E -->|Yes| F[Persist entity and relationships]
  F --> G[Return ENTITY_CREATED]
  E -->|No| H[Return existing-name guidance]
  H --> I[Use patch_entity for edits]
Loading

Reviews (4): Last reviewed commit: "fix(mcp): report create conflicts cleanl..." | Re-trigger Greptile

Context used:

@Vishnuujain
Vishnuujain requested a review from a team as a code owner August 28, 2026 05:16
@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Aug 28, 2026
@Vishnuujain
Vishnuujain force-pushed the fix/mcp-create-entity-knowledge-page branch from 1ff826a to 6acbe82 Compare August 28, 2026 05:40
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 532126e92cac3c8646f2eda276cf794fcf5c5bea in Playwright run 33151076871, attempt 1.

✅ 726 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 55m 34s

⏱️ Max setup 4m 51s · max shard execution 17m 41s · max shard-job elapsed before upload 20m 46s · reporting 5s

🌐 200.54 requests/attempt · 2.66 app boots/UI scenario · 16.31% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 16.31% (convergence target: at most 15%).
  • Browser traffic was 200.54 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.66 per UI scenario (2066 boots / 776 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 134 0 0 0 0 0
✅ Shard chromium-02 168 0 0 0 0 0
✅ Shard chromium-03 133 0 0 0 0 0
✅ Shard chromium-04 137 0 0 0 0 0
✅ Shard data-asset-rules-01 63 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 33 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
🟡 Shard search-rbac-01 28 0 1 0 0 0
🟡 1 flaky test(s) (passed on retry)
  • Flow/SearchRBAC.spec.ts › the browse tree only shows the asset-type categories a user can access (shard search-rbac-01, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@gitar-bot

gitar-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 resolved / 3 findings

Fixes MCP Knowledge Page creation by making create_entity strictly create-only, adding Page-specific validation and defaults, and resolving name-only parent references before persistence. Addressed parent resolution with soft-deleted entities and tightened required-object validation to prevent unintended loosening across all entity types.

✅ 3 resolved
✅ Edge Case: Parent resolution uses NON_DELETED, breaking updates with soft-deleted parent

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KnowledgePageRepository.java:386-390
KnowledgePageRepository.prepare() now unconditionally resolves the parent via Entity.getEntityReference(parent, Include.NON_DELETED) on the shared prepare path used by both MCP and the REST resource for creates and updates. Entity.getEntityReference throws EntityNotFoundException when the reference cannot be resolved, so any update to a page whose parent has been soft-deleted will now fail where it previously did not. If page updates should tolerate a soft-deleted parent, use Include.ALL (or only resolve when the parent lacks an id).

✅ Quality: Removing empty-Map check loosens required-object validation for all types

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java:320-332
isAbsent() no longer treats an empty Map as absent, so a required object attribute supplied as {} now passes requireFields() for every entity type, not just Page. This is intended for the required page: {} field, but it also lets an empty object satisfy other required object attributes and reach the repository, producing a less clear downstream error. The Metric case is still caught only because validateMetric() re-checks it; other types with required object fields have no such fallback. Consider gating the relaxation to the specific field(s) that legitimately accept an empty object.

✅ Edge Case: Page upsert resets votes and relatedEntities on existing pages

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java:119-128 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CreateEntityTool.java:226-233
When create_entity is called with a name already taken, persist() routes to createOrUpdate() (a full PUT-style upsert). applyPageDefaults() unconditionally sets votes to 0/0 and, when relatedEntities is empty, replaces it with the Organization team. On an existing page this can silently reset accumulated vote counts and overwrite the documented assets, since these MCP-owned fields cannot be supplied by the caller to preserve them. Consider applying these defaults only on the create path (or having applyPageDefaults skip fields already set when overwriting), consistent with the PR's guidance to use patch_entity for partial updates.

Options

Display: compact → Showing less information.

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

@Vishnuujain
Vishnuujain enabled auto-merge August 28, 2026 07:59
@Vishnuujain
Vishnuujain added this pull request to the merge queue Aug 28, 2026
Merged via the queue into main with commit 5b603f8 Aug 28, 2026
115 checks passed
@Vishnuujain
Vishnuujain deleted the fix/mcp-create-entity-knowledge-page branch August 28, 2026 09:15
Vishnuujain added a commit that referenced this pull request Sep 2, 2026
* fix(mcp): support Knowledge Page creation

* fix(mcp): make create_entity create-only

* fix(mcp): report create conflicts cleanly

(cherry picked from commit 5b603f8)

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: create Knowledge Center articles through create_entity

2 participants