Skip to content

Commit 5c331d9

Browse files
committed
Merge feat/mcp-add-stdio into pkr-tests
2 parents 02f58c7 + f3039cc commit 5c331d9

100 files changed

Lines changed: 5654 additions & 2373 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.browser-echo-mcp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"url":"http://127.0.0.1:5179","routeLogs":"/__client-logs","timestamp":1755811764407,"pid":28310}

.cursor/mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mcpServers": {
3+
"browser-echo": {
4+
"command": "node",
5+
"args": ["packages/mcp/bin/cli.mjs"]
6+
}
7+
}
8+
}

.github/workflows/pkg-pr-new.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
cache: pnpm
2626

2727
- name: Install dependencies
28-
run: pnpm install
28+
run: pnpm install:packages
2929

3030
- name: Build package
3131
run: pnpm build

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ pnpm-debug.log*
2525
.cache/
2626
.env.*
2727
.env.local
28-
.env.*.local
28+
.env.*.local
29+
docs/

README.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,29 @@ No production impact. Providers enable this across frameworks by injecting a tin
1616

1717
## Quick start
1818

19+
#### 1. Install Framework Package
20+
21+
First, set up Browser Echo for your framework:
22+
1923
| Framework | Quick Setup |
2024
| --- | --- |
21-
| TanStack / Vite (React/Vue) | [Installation Guide](packages/vite/README.md) |
25+
| TanStack / Vite | [Installation Guide](packages/vite/README.md#tanstack-start) |
2226
| Nuxt 3/4 | [Installation Guide](packages/nuxt/README.md) |
2327
| Next.js (App Router) | [Installation Guide](packages/next/README.md) |
24-
| Vue | [Installation Guide](packages/vue/README.md) |
25-
| React | [Installation Guide](packages/react/README.md) |
28+
| Vue + Vite | [Installation Guide](packages/vite/README.md#vue--vite) |
29+
| React + Vite | [Installation Guide](packages/vite/README.md#react--vite) |
30+
| Vue (non-Vite) | [Installation Guide](packages/vue/README.md) |
31+
| React (non-Vite) | [Installation Guide](packages/react/README.md) |
32+
| Core | [Installation Guide](packages/core/README.md) |
2633

2734
> Framework users only install their provider + `@browser-echo/core`. No cross‑framework bloat.
2835
36+
#### 2. Use Browser Echo MCP (Optional)
37+
38+
**⚠️ IMPORTANT:** You **must complete step 1** (framework setup) first before MCP will work. The MCP server needs your framework to forward browser logs to it.
39+
40+
**📖 [Set up Browser Echo MCP Server](packages/mcp/README.md)** for AI assistant integration
41+
2942
## What you get
3043

3144
- Drop‑in client patch that wraps `console.log/info/warn/error/debug`
@@ -34,8 +47,40 @@ No production impact. Providers enable this across frameworks by injecting a tin
3447
- Colorized terminal output
3548
- Optional file logging (Vite provider only)
3649
- Works great with AI assistants reading your terminal
50+
- **NEW:** MCP (Model Context Protocol) support for enhanced AI assistant integration
51+
52+
## Browser Echo MCP Server
53+
54+
Browser Echo includes built-in MCP (Model Context Protocol) server support, enabling AI assistants like Claude (via Cursor) to interact with your frontend logs using natural language commands:
55+
56+
- **"Check frontend logs"** - Retrieves recent console logs
57+
- **"Show only errors from the last 2 minutes"** - Filters by level and time
58+
- **"Find hydration mismatch warnings"** - Searches for specific content
59+
- **"Clear logs and start fresh"** - Clears the buffer for new captures
60+
- **"Focus on my current tab's logs"** - Filters by session
61+
62+
The MCP server exposes two main tools:
63+
- `get_logs` - Fetch logs with extensive filtering (level, session, time, content)
64+
- `clear_logs` - Clear logs with soft/hard modes and session-specific clearing
65+
66+
This integration makes debugging with AI assistants much more powerful - they can directly query and analyze your frontend logs without you having to copy/paste from the terminal.
67+
68+
**📖 [Full MCP Setup Guide & Documentation](packages/mcp/README.md)**
69+
70+
### MCP discovery and forwarding (Vite / Next / Nuxt)
71+
72+
- By default, when an MCP server is detected, frameworks forward logs to MCP and **suppress local terminal output**. If MCP is not found, they log locally.
73+
- **Vite now auto‑discovers MCP** (no need to set `mcp.url`). It resolves in this order:
74+
1. Explicit option/env: Vite plugin `mcp.url` or `BROWSER_ECHO_MCP_URL`
75+
2. Discovery file written by the MCP server: `.browser-echo-mcp.json` (project root or OS tmp) containing `url` and `routeLogs`
76+
3. Port scan of common local ports (127.0.0.1 / localhost)
77+
4. Fallback to local terminal logging
78+
- **Terminal output control:**
79+
- `BROWSER_ECHO_SUPPRESS_TERMINAL=1` — Force suppress terminal output (even when no MCP)
80+
- `BROWSER_ECHO_SUPPRESS_TERMINAL=0` — Force show terminal output (even when MCP forwarding)
81+
- Framework-specific options available (see individual framework package READMEs)
3782

38-
## Options (shared shape)
83+
## Options
3984

4085
Most providers accept these options (names may appear as plugin options or component props):
4186

@@ -44,7 +89,7 @@ type BrowserLogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
4489

4590
interface BrowserEchoOptions {
4691
enabled?: boolean; // default: true (dev only)
47-
route?: `/${string}`; // default: '/__client-logs'
92+
route?: `/${string}`; // default: '/api/client-logs' (Next), '/__client-logs' (others)
4893
include?: BrowserLogLevel[]; // default: ['log','info','warn','error','debug']
4994
preserveConsole?: boolean; // default: true (also keep logging in the browser)
5095
tag?: string; // default: '[browser]'
@@ -72,7 +117,7 @@ interface BrowserEchoOptions {
72117

73118
* Vite: ensure plugin is added and either `index.html` exists or you import the virtual module manually.
74119
* Nuxt: confirm the module is in `modules[]` and you’re in dev mode.
75-
* Next: make sure `app/__client-logs/route.ts` is exported and `<BrowserEchoScript />` is rendered in `<head>`.
120+
* Next: make sure `app/api/client-logs/route.ts` is exported and `<BrowserEchoScript />` is rendered in `<head>`.
76121

77122
* Endpoint 404
78123

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export { POST, runtime, dynamic } from '@browser-echo/next/route';
1+
import { POST as originalPOST, runtime, dynamic } from '@browser-echo/next/route';
2+
3+
export { originalPOST as POST, runtime, dynamic };

example/next-app/package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"react": "19.1.0",
13-
"react-dom": "19.1.0",
14-
"next": "15.4.6"
12+
"next": "15.4.7",
13+
"react": "19.1.1",
14+
"react-dom": "19.1.1"
1515
},
1616
"devDependencies": {
17-
"typescript": "^5",
18-
"@types/node": "^20",
19-
"@types/react": "^19",
20-
"@types/react-dom": "^19",
21-
"@tailwindcss/postcss": "^4",
22-
"tailwindcss": "^4",
23-
"eslint": "^9",
24-
"eslint-config-next": "15.4.6",
17+
"@browser-echo/mcp": "workspace:*",
18+
"@browser-echo/next": "https://pkg.pr.new/instructa/browser-echo/@browser-echo/next@e0bbe63",
2519
"@eslint/eslintrc": "^3",
26-
"@browser-echo/next": "https://pkg.pr.new/instructa/browser-echo/@browser-echo/next@e0bbe63"
20+
"@tailwindcss/postcss": "^4.1.12",
21+
"@types/node": "^24.3.0",
22+
"@types/react": "^19.1.10",
23+
"@types/react-dom": "^19.1.7",
24+
"eslint": "^9",
25+
"eslint-config-next": "15.4.7",
26+
"tailwindcss": "^4.1.12",
27+
"typescript": "^5.9.2"
2728
}
2829
}

example/nuxt-app/nuxt.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ export default defineNuxtConfig({
55
modules: ['@browser-echo/nuxt'],
66
// optional browser-echo configuration:
77
browserEcho: {
8-
stackMode: 'condensed'
8+
stackMode: 'condensed',
9+
mcpServers: {
10+
browserEcho: {
11+
type: 'http',
12+
url: 'http://localhost:5181/mcp'
13+
}
14+
}
915
}
1016
})

example/react-vite-app/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ Browser Echo streams browser console logs to your Vite dev server terminal with
1515

1616
## Getting Started
1717

18-
1. Install dependencies:
18+
1. Install Browser Echo for Vite:
19+
```bash
20+
npm install -D @browser-echo/vite
21+
# or
22+
pnpm add -D @browser-echo/vite
23+
```
24+
25+
2. Install dependencies:
1926
```bash
2027
npm install
2128
```
2229

23-
2. Start the development server:
30+
3. Start the development server:
2431
```bash
2532
npm run dev
2633
```
2734

28-
3. Open the application in your browser and interact with the demo buttons
35+
4. Open the application in your browser and interact with the demo buttons
2936

30-
4. Watch your terminal to see browser console logs streamed in real-time!
37+
5. Watch your terminal to see browser console logs streamed in real-time!
3138

3239
## What to Expect
3340

example/react-vite-app/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"react": "^19.0.0",
14-
"react-dom": "^19.0.0"
13+
"react": "^19.1.1",
14+
"react-dom": "^19.1.1"
1515
},
1616
"devDependencies": {
1717
"@browser-echo/vite": "https://pkg.pr.new/instructa/browser-echo/@browser-echo/vite@e0bbe63",
1818
"@eslint/js": "^9.17.0",
19-
"@types/react": "^19.0.1",
20-
"@types/react-dom": "^19.0.2",
21-
"@vitejs/plugin-react": "^4.3.4",
19+
"@types/react": "^19.1.10",
20+
"@types/react-dom": "^19.1.7",
21+
"@vitejs/plugin-react": "^5.0.1",
2222
"eslint": "^9.17.0",
2323
"eslint-plugin-react-hooks": "^5.0.0",
2424
"eslint-plugin-react-refresh": "^0.4.16",
25-
"globals": "^15.14.0",
26-
"typescript": "~5.7.2",
27-
"vite": "^7.0.0"
25+
"globals": "^16.3.0",
26+
"typescript": "~5.9.2",
27+
"vite": "^7.1.3"
2828
}
2929
}

0 commit comments

Comments
 (0)