MCP-UI Resources
MCP-UI Resources enable you to build rich, interactive user interfaces that work seamlessly with MCP servers. These widgets can be embedded in MCP-compatible clients to provide visual interfaces alongside your tools and resources.Overview
MCP-UI is a framework for creating interactive widgets that:- Render as web components in MCP clients
- Communicate with MCP servers through tools
- Support multiple rendering modes (iframe, inline, remote DOM)
- Provide full React/JavaScript capabilities
Resource Types
1. External URL Resources
Iframe-based widgets served from your MCP server: :::warning Deprecated External URL resources are now built automatically bymcp-use/server setupWidgetRoutes. Consider using the newer widget approach instead.
:::
- Served as standalone HTML pages
- Isolated in iframes for security
- Can include external resources
- Full JavaScript capabilities
setupWidgetRoutes function in mcp-use/server. Routes are generated based on your widget definitions without manual setup.
:::
2. Raw HTML Resources
Inline HTML content rendered directly:- Renders inline without iframe
- Simpler but less isolated
- Good for basic interactions
- Limited external resource loading
3. Remote DOM Resources
JavaScript-driven dynamic interfaces:- Dynamic JavaScript execution
- React/Vue/vanilla JS support
- Real-time updates possible
- More complex interactions
Building React Widgets
Project Structure
Example: Kanban Board Widget
Widget Styling
Accessing MCP Tools from Widgets
Using PostMessage API
Widgets can communicate with the MCP server:Direct API Calls
Widgets can also call server APIs directly:Widget Parameters
Defining Parameters
Accessing Parameters in Widgets
Development Workflow
1. Setup Development Environment
2. Create Widget Component
3. Register Widget in Server
4. Test with Inspector
The widget will be available at:- Widget URL:
http://localhost:3000/mcp-use/widgets/my-widget - Inspector:
http://localhost:3000/inspector
Best Practices
1. Performance Optimization
2. Error Handling
3. Responsive Design
4. State Management
Security Considerations
Content Security Policy
Input Sanitization
Troubleshooting
Widget Not Loading
- Check server is running:
http://localhost:3000/health - Verify widget registration in server
- Check browser console for errors
- Ensure correct widget name in URL
Parameters Not Working
- Check parameter encoding in URL
- Verify parameter parsing in widget
- Check for JSON parsing errors
- Validate parameter types match definition
Styling Issues
- Check CSS file is imported
- Verify CSS specificity
- Check for conflicting styles
- Test in different browsers
Next Steps
- Apps SDK Resources - OpenAI Apps SDK integration
- UI Widgets - General widget guide
- Templates - Project templates overview
- Examples - Complete implementations