Skip to content

Commit 30eea12

Browse files
committed
chore: update README and package documentation to reflect changes in Browser Echo MCP setup, enhance configuration tips, and clarify logging options for improved user experience
1 parent 0d023ed commit 30eea12

5 files changed

Lines changed: 99 additions & 85 deletions

File tree

README.md

Lines changed: 66 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# Browser Echo
1+
# Browser Echo MCP
22

3-
![Browser Echo](public/banner.png)
4-
5-
Stream browser `console.*` logs to your dev terminal and optional file logging.
3+
![Browser Echo MCP](public/browser-echo-mcp-banner.png)
64

7-
`browser-echo` makes it easy for you (and your AI coding assistant) to read client-side logs directly in the server terminal during development.
5+
`browser-echo` makes it easy for you to read client-side logs directly in your coding agent during development.
86

97
## Features
108

119
🤖 **AI Coding Assistant Support** - Perfect for Cursor AI, Claude Code, GitHub Copilot CLI, Gemini CLI, and other code editors that read terminal output
1210

1311
🚀 **Framework Support** - React, Vue, Nuxt 3/4, Next.js, TanStack Start, Vite-based frameworks, and custom setups
1412

15-
No production impact. Providers enable this across frameworks by injecting a tiny client patch and exposing a dev-only HTTP endpoint.
1613

1714
## Quick start
1815

@@ -31,106 +28,104 @@ First, set up Browser Echo for your framework:
3128
| React (non-Vite) | [Installation Guide](packages/react/README.md) |
3229
| Core | [Installation Guide](packages/core/README.md) |
3330

34-
> Framework users only install their provider + `@browser-echo/core`. No cross‑framework bloat.
35-
36-
#### 2. Use Browser Echo MCP (Optional)
31+
#### 2. Use Browser Echo MCP
3732

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.
33+
**⚠️ IMPORTANT:** You **must complete step 1** (framework setup) first before MCP will work. The MCP server needs your frameworks server to forward browser logs to it.
3934

4035
**📖 [Set up Browser Echo MCP Server](packages/mcp/README.md)** for AI assistant integration
4136

42-
## What you get
37+
## Browser Echo Core (Terminal only)
38+
39+
![Browser Echo](public/banner.png)
40+
41+
Stream browser `console.*` logs to your dev terminal and optional file logging.
42+
43+
`browser-echo` makes it easy for you (and your AI coding assistant) to read client-side logs directly in the server terminal during development.
44+
45+
> 💡 **Tip**: The MCP server isn't required for most use cases. AI assistants are usually smart enough to read CLI output directly, and the terminal solution is often faster and cheaper than MCP integration. The MCP was designed to avoid polluting the context window, but in most cases the terminal output is sufficient.
46+
4347

4448
- Drop‑in client patch that wraps `console.log/info/warn/error/debug`
4549
- Batched posts (uses `sendBeacon` when possible)
4650
- Source hints `(file:line:col)` + stack traces
4751
- Colorized terminal output
4852
- Optional file logging (Vite provider only)
4953
- Works great with AI assistants reading your terminal
50-
- **NEW:** MCP (Model Context Protocol) support for enhanced AI assistant integration
5154

52-
## Browser Echo MCP Server
55+
## Production
5356

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:
57+
No production impact. Providers enable this across frameworks by injecting a tiny client patch and exposing a dev-only HTTP endpoint.
5558

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
59+
* Providers apply only in development and inject nothing into your production client bundles.
60+
* If you also want to strip `console.*` in prod builds, use your bundler’s strip tools (e.g. Rollup plugin) separately.
6161

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
62+
## FAQ / Troubleshooting
6563

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.
64+
<details>
65+
<summary>The MCP doesn't show any logs</summary>
6766

68-
**📖 [Full MCP Setup Guide & Documentation](packages/mcp/README.md)**
67+
1. **Make sure you have installed framework support** → See [Install Framework Package](#1-install-framework-package) above
68+
2. **Ensure your development server is running** before starting the MCP server
69+
3. **Restart the MCP server** if logs still don't appear:
70+
- **In Cursor:** Settings → MCP & Integrations → toggle "browser-echo" off and on
71+
- **In Claude Code:** Type `/mcp` → Choose "browser-echo" → Enter → Hit `2` to reconnect
6972

70-
### MCP discovery and forwarding (Vite / Next / Nuxt)
73+
</details>
7174

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)
75+
<details>
76+
<summary>No logs appear (framework setup issues)</summary>
8277

83-
## Options
78+
* **Vite:** Ensure plugin is added and either `index.html` exists or you import the virtual module manually
79+
* **Nuxt:** Confirm the module is in `modules[]` and you're in dev mode
80+
* **Next.js:** Make sure `app/api/client-logs/route.ts` is exported and `<BrowserEchoScript />` is rendered in `<head>`
8481

85-
Most providers accept these options (names may appear as plugin options or component props):
82+
</details>
8683

87-
```ts
88-
type BrowserLogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
84+
<details>
85+
<summary>Getting 404 errors on log endpoints</summary>
8986

90-
interface BrowserEchoOptions {
91-
enabled?: boolean; // default: true (dev only)
92-
route?: `/${string}`; // default: '/api/client-logs' (Next), '/__client-logs' (others)
93-
include?: BrowserLogLevel[]; // default: ['log','info','warn','error','debug']
94-
preserveConsole?: boolean; // default: true (also keep logging in the browser)
95-
tag?: string; // default: '[browser]'
96-
// stacks
97-
stackMode?: 'none' | 'condensed' | 'full'; // default: 'full' (provider-specific; Vite supports all)
98-
showSource?: boolean; // default: true (when available)
99-
// batching
100-
batch?: { size?: number; interval?: number }; // default: 20 / 300ms
101-
// server-side
102-
truncate?: number; // default: 10_000 chars (Vite)
103-
fileLog?: { enabled?: boolean; dir?: string }; // Vite-only
104-
}
105-
```
87+
* Using a custom `base` or proxy? Keep the route same‑origin and not behind auth
88+
* Nuxt sometimes proxies dev servers; our module registers a Nitro route directly
10689

107-
> Note: File logging and `truncate` are currently implemented in the Vite plugin’s dev server middleware. Nuxt/Next providers print to stdout by default (you can extend them if you need file output there).
90+
</details>
10891

109-
## Production
92+
<details>
93+
<summary>Too many/noisy logs</summary>
11094

111-
* Providers apply only in development and inject nothing into your production client bundles.
112-
* If you also want to strip `console.*` in prod builds, use your bundler’s strip tools (e.g. Rollup plugin) separately.
95+
* Limit to `['warn','error']` and use `stackMode: 'condensed'`
96+
97+
</details>
98+
99+
<details>
100+
<summary>Seeing duplicate logs in browser</summary>
101+
102+
* Set `preserveConsole: false` in your configuration
103+
104+
</details>
113105

114-
## Troubleshooting
106+
<details>
107+
<summary>I see logs from other running projects (multiple client setup)</summary>
115108

116-
* No logs appear
109+
If you're running multiple MCP servers in different projects and seeing logs from unrelated projects, ensure each project has its own `.browser-echo-mcp.json` file in its root directory:
117110

118-
* Vite: ensure plugin is added and either `index.html` exists or you import the virtual module manually.
119-
* Nuxt: confirm the module is in `modules[]` and you’re in dev mode.
120-
* Next: make sure `app/api/client-logs/route.ts` is exported and `<BrowserEchoScript />` is rendered in `<head>`.
111+
1. **Check for ancestor config files**: Look for `.browser-echo-mcp.json` files in parent directories (e.g., `~/projects/.browser-echo-mcp.json`). If found, delete them or move them to specific project roots.
121112

122-
* Endpoint 404
113+
2. **Use distinct ports**: Start each MCP server with a unique port:
114+
```bash
115+
# In project A
116+
browser-echo-mcp --port 5179
123117

124-
* Using a custom `base` or proxy? Keep the route same‑origin and not behind auth.
125-
* Nuxt sometimes proxies dev servers; our module registers a Nitro route directly.
118+
# In project B
119+
browser-echo-mcp --port 5180
120+
```
126121

127-
* Too noisy
122+
3. **Verify project isolation**: Ensure each MCP server was started from within its own project directory (not from a shared parent).
128123

129-
* Limit to `['warn','error']` and use `stackMode: 'condensed'`.
124+
4. **Check process CWD**: If using IDE integrations or task runners, make sure each MCP server process has its `CWD` set to the individual project root.
130125

131-
* Duplicate logs in browser
126+
If the issue persists after following these steps, please [open an issue on GitHub](https://github.com/regenrek/vite-browser-logs/issues) with details about your setup.
132127

133-
* Set `preserveConsole: false`.
128+
</details>
134129

135130
## License
136131

packages/core/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,31 @@ initBrowserEcho({
4848

4949
## Options
5050

51+
Most providers accept these options (names may appear as plugin options or component props):
52+
5153
```ts
52-
interface InitBrowserEchoOptions {
53-
route?: `/${string}`; // default: '/__client-logs'
54+
type BrowserLogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
55+
56+
interface BrowserEchoOptions {
57+
enabled?: boolean; // default: true (dev only)
58+
route?: `/${string}`; // default: '/api/client-logs' (Next), '/__client-logs' (others)
5459
include?: BrowserLogLevel[]; // default: ['log','info','warn','error','debug']
55-
preserveConsole?: boolean; // default: true (also keep logging in browser)
60+
preserveConsole?: boolean; // default: true (also keep logging in the browser)
5661
tag?: string; // default: '[browser]'
62+
// stacks
63+
stackMode?: 'none' | 'condensed' | 'full'; // default: 'full' (provider-specific; Vite supports all)
64+
showSource?: boolean; // default: true (when available)
65+
// batching
5766
batch?: { size?: number; interval?: number }; // default: 20 / 300ms
58-
stackMode?: 'full' | 'condensed' | 'none'; // default: 'condensed'
67+
// server-side
68+
truncate?: number; // default: 10_000 chars (Vite)
69+
fileLog?: { enabled?: boolean; dir?: string }; // Vite-only
5970
}
6071
```
6172

73+
> Note: File logging and `truncate` are currently implemented in the Vite plugin's dev server middleware. Nuxt/Next providers print to stdout by default (you can extend them if you need file output there).
74+
75+
6276
## Framework Providers
6377

6478
This core package is typically used through framework-specific providers:

packages/mcp/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# @browser-echo/mcp
22

3+
![Browser Echo MCP](../../public/browser-echo-mcp-banner.png)
4+
35
MCP (Model Context Protocol) server for Browser Echo — enables AI assistants to directly access and analyze your frontend browser console logs using natural language commands.
46

57
## Example Usage
@@ -21,6 +23,8 @@ Your AI assistant will automatically use the appropriate MCP tools to fetch and
2123

2224
**📖 [Choose your framework and complete setup first](../README.md#quick-start)**
2325

26+
> **💡 Configuration Tip:** Set `BROWSER_ECHO_MCP_URL=http://127.0.0.1:5179/mcp` in your framework environment to explicitly configure MCP forwarding. See [Environment Variables](#environment-variables) for full configuration options.
27+
2428
Once your framework is set up and forwarding logs, install the Browser Echo MCP server with your client. Using stdio transport.
2529

2630
**Standard config** works in most of the tools:
@@ -39,7 +43,7 @@ Once your framework is set up and forwarding logs, install the Browser Echo MCP
3943

4044
### Cursor
4145

42-
[![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=browser-echo&config=eyJjb21tYW5kIjoibnB4IC15IEBicm93c2VyLWVjaG8vbWNwIn0%3D)
46+
[![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=browser-echo&config=eyJjb21tYW5kIjoibnB4IEBicm93c2VyLWVjaG8vbWNwIn0%3D)
4347

4448
<details>
4549
<summary>Manual Install</summary>
@@ -109,14 +113,14 @@ Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). F
109113

110114
#### Or install manually:
111115

112-
Follow the MCP install [guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server), use the standard config above. You can also install the Playwright MCP server using the VS Code CLI:
116+
Follow the MCP install [guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server), use the standard config above. You can also install the Browser Echo MCP server using the VS Code CLI:
113117

114118
```bash
115119
# For VS Code
116120
code --add-mcp '{"name":"browser-echo","command":"npx","args":["@browser-echo/mcp@latest"]}'
117121
```
118122

119-
After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code.
123+
After installation, the Browser Echo MCP server will be available for use with your GitHub Copilot agent in VS Code.
120124
</details>
121125

122126
<details>
@@ -396,10 +400,13 @@ publishLogEntry({
396400

397401
## Environment Variables
398402

399-
- `BROWSER_ECHO_BUFFER_SIZE` — Max entries in memory (default: `1000`)
400-
- `BROWSER_ECHO_MCP_URL` — MCP server URL for framework forwarding (if set, frameworks bypass discovery)
401-
- `BROWSER_ECHO_INGEST_PORT` — Force a fixed ingest port in stdio mode (default: 5179 preferred)
402-
<!-- Tmp discovery and multi-port scanning removed from defaults -->
403+
Configure the MCP server behavior with these environment variables:
404+
405+
- `BROWSER_ECHO_MCP_URL=http://127.0.0.1:5179/mcp` — MCP server URL for framework forwarding (if set, frameworks bypass auto-discovery)
406+
- `BROWSER_ECHO_BUFFER_SIZE=1000` — Max entries kept in memory (default: `1000`)
407+
- `BROWSER_ECHO_INGEST_PORT=5179` — Force a fixed ingest port in stdio mode (default: 5179)
408+
- `BROWSER_ECHO_SUPPRESS_TERMINAL=1` — Force suppress terminal output when MCP is forwarding logs
409+
- `BROWSER_ECHO_SUPPRESS_TERMINAL=0` — Force show terminal output even when MCP is active
403410

404411
---
405412

packages/vite/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ interface BrowserEchoViteOptions {
140140
};
141141
discoverMcp?: boolean; // Enable MCP auto-discovery (default: true)
142142
discoveryRefreshMs?: number; // Discovery refresh interval (default: 30000)
143-
discoveryPorts?: number[]; // (Deprecated) No longer used; discovery tries 5179 in dev, then local file
144143
}
145144
```
146145

@@ -188,8 +187,7 @@ browserEcho({
188187

189188
#### Discovery behavior
190189

191-
- Discovery order: `BROWSER_ECHO_MCP_URL` → port 5179 (dev) → project-local `.browser-echo-mcp.json`.
192-
- Tmp discovery and multi-port scanning have been removed for simplicity and safety.
190+
Discovery order: `BROWSER_ECHO_MCP_URL` → port 5179 (dev) → project-local `.browser-echo-mcp.json`.
193191

194192
## File Logging (Vite-only feature)
195193

public/browser-echo-mcp-banner.png

196 KB
Loading

0 commit comments

Comments
 (0)