Prerequisites
- Node.js 22.12 or later
- A modern web browser
- An MCP client (Claude Desktop, Cursor, Claude Code, or Windsurf)
What we will build
- An HTML page that registers a
get_page_titletool and connects to the relay - A running relay process that bridges browser tools to MCP clients
- A desktop AI agent that can list and call the browser tool
Create the web page
Create a file called The first script tag loads
relay-demo.html:relay-demo.html
@mcp-b/global, which sets up navigator.modelContext. The tool registration is the same pattern from the first tool tutorial. The last script tag loads embed.js, which creates a hidden iframe that connects the page’s tools to the local relay via WebSocket.The
embed.js script must appear after your tools are registered, so the relay can discover them on connection.Configure the relay in your MCP client
Add the relay to your MCP client’s configuration. The exact location depends on your client.When the MCP client starts, it launches the relay process. The relay listens for WebSocket connections from browser pages on
- Claude Desktop
- Cursor
- Claude Code
Open Claude Desktop settings, go to the MCP section, and add:
claude_desktop_config.json
ws://127.0.0.1:9333.Open the page
Open
relay-demo.html in your browser. You can open the file directly, or serve it from a local server if you prefer.The page registers the tool and the embed.js script connects to the relay via WebSocket (see Transports and Bridges for details). The relay now knows about the get_page_title tool on this tab.Verify the connection from your MCP client
In your MCP client, the relay exposes management tools. Ask the agent:Your browser tab is connected.
List the connected WebMCP sources.The agent calls
webmcp_list_sources, which returns something like:Call the tool from the agent
Ask the agent:You have called a browser-side tool from a desktop AI agent through the local relay.
What is the title of the connected web page?The agent calls the
get_page_title tool and returns:Try with a live website
Open webmcp.sh in a separate tab. It has WebMCP tools for navigation, SQL queries, entity management, and more. Ask the agent to list sources again. You will see tools from both tabs. The relay aggregates tools from all connected pages.

What you learned
- The local relay bridges browser WebMCP tools to desktop MCP clients over WebSocket and stdio
- Adding
embed.jsto a page connects that page’s tools to the relay - The relay exposes management tools (
webmcp_list_sources,webmcp_list_tools) alongside the dynamic browser tools - Multiple browser tabs can connect simultaneously, and the relay aggregates their tools
Next steps
- See the
webmcp-local-relayreference for CLI options, security settings, and architecture details - Read Connect Desktop Agents with Local Relay for production configuration (origin restrictions, custom ports)
- Try Build Your First Tool or Build Your First React Tool if you have not yet created your own tools
