Add MCP Apps protocol support for Chartifact embeddings#158
Add MCP Apps protocol support for Chartifact embeddings#158
Conversation
- Create MCP adapter package with JSON-RPC 2.0 protocol implementation - Add MCP-compatible viewer at /mcp-view/ - Implement guest messenger for iframe communication - Add example MCP server with chart and dashboard tools - Update README with MCP Apps information - Add comprehensive documentation Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
- Create interactive test harness for local development - Add comprehensive integration guide for developers - Document architecture with diagrams and message flows - Add .gitignore for mcp-adapter package Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
- Update @modelcontextprotocol/sdk from 0.5.0 to ^1.25.2 - Fixes ReDoS vulnerability (CVE in versions < 1.25.2) - Fixes DNS rebinding protection issue (< 1.24.0) - Add security notes to documentation - Update example server README with security information Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
|
@copilot any reason to create https://microsoft.github.io/chartifact/mcp-view/ and not just add functionality to our existing https://microsoft.github.io/chartifact/view/ ? |
Good point! You're right that we could consolidate. The existing I initially created a separate endpoint for:
However, we could merge them by detecting Would you prefer I consolidate into |
|
@copilot /view/ uses the |
- Add MCP JSON-RPC 2.0 protocol handling to host package - Detect MCP mode via ?mcp URL parameter - Automatically disable clipboard, drag-drop, file upload in MCP mode - Remove separate /mcp-view/ endpoint - use single /view/ for both - Update all documentation and examples to use /view/?mcp - Remove mcp-adapter package and mcp-view directory Per feedback: integrate MCP into host package with protocol detection Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Done! Consolidated MCP protocol into the existing
The single |
Chartifact can now be embedded as an interactive UI in MCP-compatible clients (Claude, VS Code, ChatGPT) via the Model Context Protocol Apps extension. This leverages the existing sandboxed renderer architecture with a JSON-RPC 2.0 protocol adapter integrated into the host package.
Implementation
Protocol Layer (
packages/host/src/)message.jsonrpc === '2.0'for MCP vsmessage.typefor standard messagesinitialize,ui/render,ui/get-content,ui/clearViewer (
docs/view/)/view/endpoint with MCP support via?mcpURL parameterui/readynotification when in MCP contextExample Server (
demos/mcp-server/)create_chartandcreate_dashboardtoolsUsage
MCP servers return Chartifact visualizations as UI resources:
The MCP client embeds the viewer iframe with the
?mcpparameter, which handles JSON-RPC protocol translation and delegates to the existing Chartifact host for rendering.Architecture Decisions
/view/endpoint handles both standard and MCP protocolsjsonrpcproperty?mcpparameter disables interactive features for embeddingpackages/host/src/where postMessage logic existsTesting
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.