Skip to content

Commit fa76a2b

Browse files
committed
feat: add MCP command-line scripts and enhance logging functionality with new HTTP transport options
1 parent 5911665 commit fa76a2b

25 files changed

Lines changed: 1317 additions & 899 deletions

.cursor/mcp.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"mcpServers": {
33
"browser-echo": {
4-
"url": "http://localhost:5173/__mcp"
4+
"type": "http",
5+
"url": "http://localhost:5179/mcp"
56
}
67
}
78
}

example/react-vite-app/vite.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ import browserEcho from '@browser-echo/vite'
44

55
// https://vite.dev/config/
66
export default defineConfig({
7-
plugins: [react(), browserEcho({ stackMode: 'condensed' })],
7+
plugins: [react(), browserEcho({
8+
stackMode: 'condensed',
9+
// mcp: {
10+
// url: 'http://localhost:5179'
11+
// }
12+
})],
813
})

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
"cleanup": "pnpm tsx scripts/cleanup.ts",
1010
"test": "vitest run --reporter=dot",
1111
"test:watch": "vitest",
12-
"lint": "eslint ."
12+
"lint": "eslint .",
13+
"mcp": "node packages/mcp/dist/cli.mjs",
14+
"mcp:port": "node packages/mcp/dist/cli.mjs --port",
15+
"mcp:dev": "pnpm tsx packages/mcp/src/index.ts",
16+
"mcp:build": "pnpm --filter @browser-echo/mcp run build"
1317
},
1418
"devDependencies": {
1519
"@types/node": "^24.3.0",

packages/mcp/README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ MCP (Model Context Protocol) server for Browser Echo - captures and exposes fron
44

55
## Overview
66

7-
This package provides an MCP server that:
7+
This package provides an MCP server using Streamable HTTP transport that:
88
- Captures frontend console logs (errors, warnings, info, debug)
99
- Exposes logs through MCP tools and resources for AI assistants
1010
- Enables debugging of React hydration issues, network failures, and other frontend problems
1111
- Supports session-based filtering and soft/hard log clearing
12+
- Runs on HTTP transport for compatibility with browser-based log forwarding
1213

1314
## Installation
1415

@@ -18,7 +19,19 @@ pnpm add -D @browser-echo/mcp
1819

1920
## Usage
2021

21-
The MCP server is automatically started when using Browser Echo with supported frameworks (Vite, Next.js, Nuxt).
22+
Start the MCP server:
23+
24+
```bash
25+
# Start on default port 5179
26+
pnpm --package=@browser-echo/mcp dlx browser-echo-mcp
27+
28+
# Or with custom port
29+
pnpm --package=@browser-echo/mcp dlx browser-echo-mcp --port 8080
30+
```
31+
32+
The server exposes:
33+
- MCP endpoint at `http://localhost:5179/mcp`
34+
- Log ingestion at `http://localhost:5179/__client-logs`
2235

2336
### Available Tools
2437

@@ -116,8 +129,8 @@ The server also exposes logs as MCP resources:
116129

117130
### Environment Variables
118131

119-
- `BROWSER_ECHO_MCP=0` - Disable MCP server (enabled by default in development)
120-
- `NODE_ENV=production` - MCP is automatically disabled in production
132+
- `BROWSER_ECHO_MCP_URL` - Override the default MCP server URL
133+
- `BROWSER_ECHO_BUFFER_SIZE` - Maximum log entries to keep in memory (default: 1000)
121134

122135
## API
123136

@@ -155,7 +168,17 @@ publishLogEntry({
155168

156169
## Integration with AI Assistants
157170

158-
The MCP server is designed to work seamlessly with AI assistants like Claude (via Cursor) or other MCP-compatible tools.
171+
The MCP server works with any MCP-compatible client. For Cursor, add to `.cursor/mcp.json`:
172+
173+
```json
174+
{
175+
"mcpServers": {
176+
"browser-echo": {
177+
"url": "http://localhost:5179/mcp"
178+
}
179+
}
180+
}
181+
```
159182

160183
### Natural Language Commands
161184

packages/mcp/bin/cli.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
3+
import { fileURLToPath } from 'node:url'
4+
import { runMain } from '../dist/index.mjs'
5+
6+
globalThis.__mcp_starter_cli__ = {
7+
startTime: Date.now(),
8+
entry: fileURLToPath(import.meta.url),
9+
}
10+
11+
runMain()

packages/mcp/build.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ export default defineBuildConfig({
44
entries: ['./src/index'],
55
clean: true,
66
declaration: true,
7+
failOnWarn: false,
8+
externals: [
9+
'@modelcontextprotocol/sdk',
10+
],
711
rollup: {
812
emitCJS: false,
13+
inlineDependencies: false,
914
},
1015
});

0 commit comments

Comments
 (0)