Repository navigation
WIP: add MCP Client with conversation tracking and chat UI - #26343
Conversation
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Implement an MCP Client in OpenMetadata that allows users to interact with the existing MCP Server tools through a chat UI, with full conversation and message persistence. Backend: - JSON schemas for McpConversation, McpMessage, and content types - SQL migrations for mcp_conversation and mcp_message tables (MySQL + PostgreSQL) - McpClientConfiguration for LLM provider settings (OpenAI/Anthropic) - LLM client abstraction with OpenAI and Anthropic implementations - McpConversationRepository and McpMessageRepository for CRUD - McpClientService orchestrator with tool call loop - McpClientResource REST API at /v1/mcp-client - MCP tool executor registration from openmetadata-mcp module Frontend: - mcpClientAPI.ts REST client for chat, conversations, and messages - McpChatPage with conversation sidebar, message list, and chat input - MUI-based components with markdown rendering and tool call display - Route, sidebar navigation, and i18n labels Co-Authored-By: Claude Opus 4.6 <[email protected]>
…eaming Introduce the foundational types for server-sent event streaming in the MCP chat feature. ChatEvent is a Java record with static factory methods for each event type (conversation_created, text, tool_call_start, tool_call_end, message_complete, error, done). ChatEventEmitter is a functional interface consumed by the streaming chat method. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add a new chatStream() method that mirrors the existing chat() logic but emits ChatEvent events via a ChatEventEmitter callback instead of accumulating results and returning a ChatResponse. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add POST /v1/mcp-client/chat/stream endpoint that returns text/event-stream using Jersey StreamingOutput. Each ChatEvent is written as an SSE frame with event name and JSON data. Includes writeSseEvent helper method and proper error handling with Cache-Control and X-Accel-Buffering headers. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add ChatStreamEvent discriminated union type, ChatStreamCallbacks interface, and streamChatMessage function that uses native fetch to consume the /chat/stream SSE endpoint with proper auth and SSE parsing. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace sendChatMessage with streamChatMessage for progressive UI updates. Shows assistant text and tool calls incrementally as SSE events arrive. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The method signature was missing the content parameter, causing compilation errors in McpClientService. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Sidebar title: "MCP Chat" → "Chat" - Empty state: clean centered heading + pill-shaped input with send icon - ChatInput: replace separate Button with Send01 icon inside TextField - Update i18n: mcp-chat-empty, mcp-chat-placeholder Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Human message bubbles: grey[200] bg with dark text (was unreadable white-on-primary-blue) - Assistant bubbles: white bg with border (was grey[100]) - Trash icon: only visible on conversation hover - Remove message count subtitle from conversation list - Simplify token display color Co-Authored-By: Claude Opus 4.6 <[email protected]>
Show a CircularProgress spinner with "Thinking..." text when the assistant message has no content yet (during streaming before the first text or tool_call event arrives). Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Create McpChatApplication as a separate installable app (marketplace only, not auto-installed) - Move LLM config from openmetadata.yaml to app configuration (provided at install time) - McpClientResource dynamically looks up McpChatApplication from ApplicationContext - Simplify ToolExecutor interface (authorizer/limits captured in McpServer closure) - Add McpChatPlugin for conditional Chat sidebar item (only shown when app is installed) - Add UI application schema for install form (LLM provider, API key, model, endpoint, system prompt) Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 82 out of 98 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (5)
openmetadata-ui/src/main/resources/ui/src/pages/McpChatPage/NavItem.tsx:62
- Hardcoded color value
tw:bg-blue-50is used for the active state instead of a theme token. Per the project's UI guidelines, theme tokens (from openmetadata-ui-core-components / MUI) should be used rather than hardcoded color classes so theming/dark-mode/branding stays consistent. The badge below also hardcodestw:bg-blue-50andtw:text-blue-600.
openmetadata-ui/src/main/resources/ui/src/rest/mcpClientAPI.ts:162 - Dynamic
import()ofSwTokenStorageUtilsandHistoryUtilsis performed on every call tostreamChatMessage. While modules are cached after the first call, the awaited promise still adds latency to every chat send. Prefer top-level static imports for these utilities since they are already part of the UI bundle.
openmetadata-ui/src/main/resources/ui/src/rest/mcpClientAPI.ts:225 - The SSE parser only looks at lines starting with
event:anddata:and ignores SSE comments /id:/ multi-linedata:continuations. Per the SSE spec, a single event can have multipledata:lines that should be concatenated with newlines. If the backend ever emits a multi-line JSON payload split acrossdata:lines, the JSON.parse will silently fail (caught by the emptycatch {}) and the event will be dropped without any log, making this very hard to debug. Consider concatenating multipledata:lines and at minimum logging parse errors.
openmetadata-ui/src/main/resources/ui/src/rest/mcpClientAPI.ts:234 - When the fetch is aborted via
signal, thereader.read()loop throws anAbortErrorthat is forwarded tocallbacks.onError. Consumers typically expect aborted requests to be silent (since the abort was user-initiated). Consider distinguishingAbortErrorfrom real errors and not invokingonErrorin that case.
openmetadata-ui/src/main/resources/ui/src/rest/mcpClientAPI.ts:222 - The cast
as ChatStreamEventsilently coerces any server event name into the typed union. If the backend emits an event name not in the union, downstream code treats it as a valid event and may crash. ValidateeventNameagainst the known set before casting, or at least log/skip unknown events explicitly.
| export interface NavItemProps { | ||
| icon: ComponentType<SVGProps<SVGSVGElement>>; | ||
| label: string; | ||
| badge?: string; | ||
| active?: boolean; | ||
| dataTestId?: string; | ||
| onClick: () => void; | ||
| } |
| /* | ||
| * Copyright 2024 Collate. | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ |
| { | ||
| "title": "Anthropic (AWS Bedrock)", | ||
| "properties": { | ||
| "llmProvider": { | ||
| "title": "LLM Provider", | ||
| "type": "string", | ||
| "const": "anthropic", | ||
| "default": "anthropic" | ||
| }, |
| "enabled": { | ||
| "title": "Enable IAM Auth", | ||
| "description": "Enable AWS IAM authentication. When enabled, uses the default credential provider chain (environment variables, instance profile, etc.).", | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "region": { | ||
| "title": "AWS Region", | ||
| "description": "AWS Region where Bedrock is enabled (e.g., us-east-1).", | ||
| "type": "string" | ||
| }, | ||
| "accessKeyId": { | ||
| "title": "AWS Access Key ID", | ||
| "description": "AWS Access Key ID. Falls back to default credential provider chain if not set.", | ||
| "type": "string" | ||
| }, | ||
| "secretAccessKey": { | ||
| "title": "AWS Secret Access Key", | ||
| "description": "AWS Secret Access Key. Falls back to default credential provider chain if not set.", | ||
| "type": "string", | ||
| "format": "password" | ||
| }, | ||
| "sessionToken": { | ||
| "title": "AWS Session Token", | ||
| "description": "AWS Session Token for temporary credentials.", | ||
| "type": "string" |
| const MemoizedMessageBubble = memo<{ message: McpMessage }>(({ message }) => ( | ||
| <MessageBubble message={message} /> | ||
| )); | ||
|
|
||
| MemoizedMessageBubble.displayName = 'MemoizedMessageBubble'; | ||
|
|
||
| const MessageList: React.FC<MessageListProps> = memo( | ||
| ({ messages, isLoading, containerRef, endRef }) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| const renderedMessages = useMemo( | ||
| () => | ||
| messages.map((message) => ( | ||
| <MemoizedMessageBubble key={message.id} message={message} /> | ||
| )), | ||
| [messages] | ||
| ); |
| "llmModel": { | ||
| "title": "Model", | ||
| "description": "The model to use. For example: gpt-4o, gpt-4o-mini.", | ||
| "type": "string", | ||
| "default": "gpt-4o" | ||
| }, |
|
@copilot translate the new keys added to locales in their respective languages |
Done in commit Keys translated:
Languages updated: ar-sa, de-de, es-es, fr-fr, gl-es, he-he, ja-jp, ko-kr, mr-in, nl-nl, pr-pr (Persian), pt-br, pt-pt, ru-ru, th-th, tr-tr, zh-cn, zh-tw Also restored |
… of https://github.com/open-metadata/OpenMetadata into task/implement-mcp-client-with-message-tracki-9d9ca8a4
…i-9d9ca8a4
Resolve conflicts:
- McpTestBase.java: keep both sides' HTTP helpers (getResponse + get
delegating to it from this branch; put + patch from main)
- locale/languages/*.json: union both key sets (branch MCP Chat keys +
main's new keys), preserving main's OpenMetadata->{{brandName}} rename;
all 19 locales kept keyset-consistent with en-us
- yarn.lock: keep main's added dependency entries
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
❌ 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 |
…chat backend Migrations: - Move mcp_conversation/mcp_message DDL from native/1.13.0 to native/2.0.0 (mysql + postgres), verbatim. Docs: - Remove implementation-plan markdown that was committed under docs/. Backend review fixes: - Dispatch LlmClientFactory by provider (openai/anthropic/bedrock) via a new LlmProvider enum. AnthropicLlmClient was unreachable dead code and "anthropic" wrongly mapped to Bedrock (NPE for api-key-only configs). Fail fast on missing credentials and disable chat instead of crashing app install on bad config. - Build the LLM context and the initial conversation load from the most recent messages instead of the oldest N (listRecentByConversation). - Collapse chat/chatStream into one flow with focused helpers; replace catch(Exception) with typed LlmException / ClientDisconnectedException / RuntimeException handling. - Detect client disconnect on SSE writes, stop the tool loop, and stop double-writing to a broken stream; close the HTTP error stream on non-200 streaming responses (no InputStream leak). - Share the configured JsonUtils ObjectMapper across all LLM clients. - Validate the chat message with @NotBlank/@SiZe. - Run async title generation on a bounded, named executor instead of the common ForkJoinPool and shut it down on close(). - Preserve partial output and log a warning when the tool-call limit is hit. - Remove dead repository/DAO methods (getById, updateContent). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Resolve 2.0.0 schemaChanges.sql conflicts (mysql + postgres): keep both the Task System Redesign / activity-stream migrations and the per-entity name indexes from main, and the MCP conversation/message tables from this branch.
…ture flag LLM provider and credentials previously lived in McpChatAppConfig (per-app). Move them to a platform-wide llmConfiguration in openmetadata.yaml so any feature can consume LLM completions, not just MCP chat. - Add openmetadata-spec configuration/llmConfiguration.json (enabled, provider enum, per-provider openai/anthropic/bedrock/google blocks). - Bind llmConfiguration in OpenMetadataApplicationConfig; publish via LlmConfigHolder at startup. - Repoint the tool-calling LlmClient stack (factory + provider clients) from McpChatAppConfig to LLMConfiguration; drop the redundant LlmProvider enum. - McpClientService.isChatEnabled() now gates on llmConfiguration.enabled + credentials. - Strip McpChatAppConfig to systemPrompt only; update marketplace def and UI install form. - Update McpChatResourceIT for the new shape. Generated Python/UI-TS artifacts (llmConfiguration models, bundled schemas) still need a toolchain regen: make generate && make update_typescript_types && yarn parse-schema. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
…m install schema Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…l config The trimmed McpChatAppConfig schema (additionalProperties:false) rejects llmProvider/llmApiKey/llmModel; the install POST now sends only systemPrompt. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
|
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Gitar



Fixes https://github.com/open-metadata/ai-platform/issues/429
Summary
mcp_conversationandmcp_messagetablesmcpClientConfigurationinopenmetadata.yaml/v1/mcp-clientfor chat, conversation CRUD, and message listingChanges
Backend
McpConversation,McpMessage,MessageBlock,ToolCall,TokenUsage,ChatContentTypemcp_conversationandmcp_messagetables for MySQL and PostgreSQL with generated columns and indexesMcpClientConfigurationwithenabled,provider,apiKey,model,apiEndpoint,systemPromptLlmClient,LlmResponse,LlmMessage,LlmToolCall) with OpenAI and Anthropic implementationsMcpConversationDAOandMcpMessageDAOinCollectionDAOMcpConversationRepositoryandMcpMessageRepositoryfor CRUD operationsMcpClientServiceorchestrator with tool call loop (user message → LLM → tool calls → tool execution → LLM response)McpClientResourcewith endpoints for chat, conversations, and messagesopenmetadata-mcpmodule viaMcpServerFrontend
mcpClientAPI.tswith typed interfaces for all MCP client operationsMcpChatPagewith conversation sidebar, message list, chat input, and tool call accordion display/mcp-chatroute with sidebar navigation entryTest plan
mcpClientConfigurationinopenmetadata.yamlwith a valid LLM provider and API keySummary by Gitar
MCP Chatand related UI strings for regional consistency.pin-conversation,pinned-chat, andunpin-conversationkeys to i18n files for conversation management.This will update automatically on new commits.