@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.| Field | Value |
|---|---|
| Name | navigate |
| Description | Navigate to a URL path in the application |
Input Schema
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | URL path to navigate to |
replace | boolean | No | Replace history entry instead of pushing |
Example
"Navigated to /dashboard"
GoBackTool
MCP tool that navigates back in browser history.| Field | Value |
|---|---|
| Name | go_back |
| Description | Go back to the previous page in browser history |
CurrentRouteResource
MCP resource that reads the current URL/path/params.| Field | Value |
|---|---|
| URI | route://current |
| Name | Current Route |
Response
createRouterEntries
Factory that returns tool and resource entries for easy spreading intocreate() config:
Bridge Functions
Low-level bridge functions for advanced use cases:| Function | Description |
|---|---|
setNavigate(fn) | Set the navigate function |
setLocation(loc) | Set the current location |
getNavigate() | Get the navigate function (or null) |
getLocation() | Get the current location (or null) |
clearBridge() | Reset both navigate and location to null |