What is MCP?
Model Context Protocol (MCP) is a standardized protocol for sharing context between applications and AI tools. React Grab’s MCP integration enables you to:- Share selected UI elements with MCP-compatible AI tools
- Automatically send context when you copy elements
- Stream UI selections to your AI assistant in real-time
Installation
Start the MCP server
The MCP server runs on port To stop the server:
7567 by default and handles communication between React Grab and MCP-compatible tools.Quick Start (CLI)
Start the server before running your dev server:The server runs as a detached background process. Stopping your dev server (Ctrl+C) won’t stop the MCP server.
Recommended: Config File Setup
For better lifecycle management, start the server from your config file. This ensures the server stops when your dev server stops:Vite
Next.js
How It Works
- React Grab sends selected element context to the MCP server via HTTP POST
- MCP Server stores the context and makes it available via the MCP protocol
- AI Tools can query the server to retrieve the latest UI context
- The context includes HTML structure, component info, and optional user prompts
Using with AI Tools
Once the MCP server is running, AI tools can use theget_element_context tool to retrieve the latest context you’ve selected in React Grab.
Context Format
The MCP server provides context in this format:Context Expiration
Context automatically expires after a certain time to prevent stale data from being used. The server tracks when context was submitted and clears it after the TTL expires.Server Options
You can customize the MCP server:STDIO Mode
For direct integration with MCP-compatible tools that use stdin/stdout:Troubleshooting
MCP server won't start
MCP server won't start
- Check if port 7567 is already in use
- Try killing any existing processes:
pkill -f "react-grab.*server" - Check server logs for error messages
Context not appearing in AI tool
Context not appearing in AI tool
- Verify the MCP server is running by checking
http://localhost:7567/health - Make sure your AI tool is configured to connect to the React Grab MCP server
- Check that the context hasn’t expired (try selecting an element again)
Browser can't connect to server
Browser can't connect to server
- Ensure the server is running before loading your app
- Check browser console for CORS or connection errors
- Verify the server URL matches the configured port
Next Steps
Plugin API
Learn about the plugin system and hooks
Configuration
Customize React Grab behavior
