@frontmcp/react/router entry point bridges React Router v7 with MCP. AI agents can navigate your app, go back in history, and read the current route — all through standard MCP tools and resources.
react-router-dom is an optional peer dependency. Only install it if you use the router integration.Setup
1. Install React Router
2. Wire the Bridge
CalluseRouterBridge() inside your React Router tree:
src/App.tsx
3. Register Router Entries
Add the router tools and resources to your MCP server:src/server.ts
useRouterBridge
Wires React Router’snavigate and location into a module-scoped bridge singleton.
<BrowserRouter>, <MemoryRouter>, etc.). It:
- Captures
useNavigate()and syncs it to the bridge on mount - Updates the bridge location on every route change
- Clears the bridge on unmount
NavigateTool
MCP tool that navigates to a URL path.Input Schema
Example
"Navigated to /dashboard"
GoBackTool
MCP tool that navigates back in browser history.
Takes no input parameters.
CurrentRouteResource
MCP resource that reads the current URL/path/params.Response
createRouterEntries
Factory that returns tool and resource entries for easy spreading intocreate() config: