Repository navigation
Description
Motivation
MCP Apps provides interactive HTML interfaces inside ChatGPT, Claude and other supporting MCP hosts. Tools bind to a UI resource, the host obtains its HTML via resources/read, and the sandboxed component communicates with the host over the MCP Apps bridge. A separate application web server is not required for self-contained components.
Keep application data, logic and UI assets in ClickHouse; keep Altinity MCP a generic stateless protocol adapter.
This is the presentation layer of the database-defined application architecture described in PR #201. It complements database-defined read/write tools, write responses (#199), Skills (#200) and Events (#198).
Dependency
Use #202, the generic ClickHouse-backed Resources provider, for all UI content and resource metadata. In the reference deployment (#205), UI bundles are ordinary kind = 'resource' rows in the single physical app.mcp_catalog table, exposed through the app.mcp_resources ordinary view. The provider accepts any compatible table/view; no dedicated UI table is required. Do not introduce a separate filesystem/HTML provider or require an external website.
Proposed implementation
1. Serve a UI component from ClickHouse
Publish a complete self-contained HTML/CSS/JS bundle using the shared logical resource contract in #202. Example logical row (the physical catalog stores its URI in id and the publisher assigns revision):
uri: ui://analytics/dashboard-v1.html
name: Analytics dashboard
mime_type: text/html;profile=mcp-app
content: <complete HTML bundle>
metadata: validated MCP Apps resource metadata
The logical ui:// URI is resolved over MCP, not fetched over HTTP as a URL. The HTML is stored in a ClickHouse String, served through the ordinary authorized resources/read method, and rendered by the host in a sandboxed iframe.
Use the standard MCP Apps extension first, including negotiated capability discovery, resource MIME type, and allowed resource metadata. Return the UI's exact bytes. Support immutable/versioned URIs and a SQL-defined publication view. Include a documented self-contained bundle example using the upstream MCP Apps SDK.
2. Bind dynamic tools to UI resources
Extend the structured table/view COMMENT JSON convention (#154) to include an optional UI binding and output schema. Example (proposed application-side descriptor):
{
"title": "Open analytics dashboard",
"description": "Display the analytics dashboard",
"ui": {
"resourceUri": "ui://analytics/dashboard-v1.html"
},
"outputSchema": {
"type": "object",
"properties": {
"count": {"type": "integer"},
"rows": {"type": "array", "items": {"type": "object"}}
},
"required": ["count", "rows"]
}
}Translate the UI binding into the protocol tool descriptor's _meta.ui.resourceUri; use the standard extension's UI visibility settings where supported. The illustrative output schema above assumes an object-per-row representation; if reusing the existing columns/types/rows/count representation, declare its actual array-of-arrays schema instead. Define and document the chosen shape explicitly, and validate results against the declared schema. The descriptor must remain compatible with existing COMMENT metadata.
Current dynamic tool registration sets name/title/description/annotations/inputSchema but no UI binding or outputSchema (source). The existing query result helper returns JSON serialized into text blocks (source). Add actual MCP structuredContent alongside useful text content for headless and older clients.
Apply to both dynamic read and write tools, including INSERT RETURNING responses from #199. Return actual database results, truncation information and errors consistently. Keep write authorization and safety annotations separate from UI presentation and result shape.
3. Host bridge and app entry points
An HTML component receives its originating tool result and can invoke authorized named tools via the standard MCP Apps bridge (illustrative source before bundling):
import { App } from "@modelcontextprotocol/ext-apps";
const app = new App({name: "Analytics dashboard", version: "1.0.0"});
app.ontoolresult = result => render(result.structuredContent);
await app.connect();
// On a user refresh action:
const result = await app.callServerTool({
name: "list_metrics",
arguments: {period: "month"}
});
render(result.structuredContent);Do not expose database credentials or require browser-side access to ClickHouse. Model and UI calls must share the same server-side identity and permission checks.
Support standard inline MCP Apps as the portable MVP. Investigate optional host capabilities such as entry points, fullscreen/side panels, app tools and display modes. ChatGPT and Claude have host-specific requirements and access/review constraints; expose only documented, validated metadata for enabled features. Do not make a proprietary host bridge or arbitrary external iframe necessary for core operation. External website embedding is optional and out of scope for the MVP.
4. Security and compatibility
- Fetch UI resources using the same effective principal/role/cluster as other resources (Generic ClickHouse-backed MCP Resources and Resource Templates #202); a tool binding or UI URI does not confer access.
- Use the standard sandbox and a strict allowlist for CSP, permissions, external domains and host metadata. Default to self-contained, no-network UI. Do not pass arbitrary database JSON through to privileged host metadata.
- Treat HTML/JS and COMMENT descriptors as trusted-publisher surfaces: restrict who can publish/edit them, version/review content, prevent injection through untrusted row values, avoid secrets in content and tool results.
- Enforce tool visibility, grants, read-only mode, blocked clauses, input/output validation and all normal authorization checks for every tool call. UI/model visibility is not an authorization boundary.
- Keep useful text results for clients without UI support; do not require an app to invoke a normal read/write operation.
- Document supported host profiles, protocol revisions, size limits, publication/cache behavior, and packaging/review requirements. Test real ChatGPT and Claude surfaces; native capability and account eligibility are not interchangeable.
Acceptance criteria
- Publish a self-contained HTML component from a ClickHouse row/view, discover the tool's standard UI binding, read the component through MCP, and render it in an MCP Apps-capable host.
- Demonstrate the same component in ChatGPT and Claude on supported accounts, with an interactive refresh and a user-authorized write using named tools.
- Dynamic read and INSERT RETURNING write tools provide schema-valid structuredContent and useful text fallback; test empty/error/truncated responses and backwards compatibility.
- Test metadata validation, unknown/missing UI URIs, version changes, XSS handling in sample code, resource/response limits, CSP policy and per-principal/per-cluster access.
- UI calls cannot bypass write restrictions or expose other principals' resources; test two users and two clusters.
- No application-specific Go code, local HTML files, separate application web server or persistent MCP-side UI state is needed for the sample application.
- Document SQL schema/configuration, COMMENT descriptor, bundle/publish workflow, supported host capabilities and limitations.
Related
-
Roadmap: ClickHouse-native applications in ChatGPT, Claude and other MCP hosts #205 — Application-platform umbrella roadmap.
-
Generic ClickHouse-backed MCP Resources and Resource Templates #202 — generic resource provider (dependency).
-
Dynamic write tools: parse COMMENT-JSON descriptors the way view tools do #154 — structured COMMENT descriptor handling for write tools.
-
Support ClickHouse 26.11 INSERT ... RETURNING for dynamic write tools and write_query #199 — meaningful INSERT RETURNING write responses.
-
Support ClickHouse-backed MCP Skills (SEP-2640), including supplementary resources, without filesystem storage #200 — database-backed Skills.
-
Support MCP Events (SEP-3415) for event-driven ClickHouse monitoring and analytics #198 — database-backed Events.
-
Surface ClickHouse query stats (written_rows, read_rows, elapsed) in read/write tool results #137 — query statistics; distinct from structured returned data.
References
- MCP Apps specification and SDK
- OpenAI MCP Apps documentation
- Claude MCP Apps documentation
- MCP extension client matrix
The proposed metadata fields, schema and SDK integration require implementation verification. Host-specific entry points and directory approval are not guaranteed by implementing the portable extension.
Activity