Skip to content

Commit 78ef6e3

Browse files
committed
fix: update Next.js support for webpack and Turbopack
1 parent a62b608 commit 78ef6e3

File tree

128 files changed

+4042
-4334
lines changed

Some content is hidden

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

128 files changed

+4042
-4334
lines changed

.cursor/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"mcpServers": {
33
"dev-inspector": {
4-
"url": "http://localhost:5173/__mcp__/sse?clientId=cursor&puppetId=inspector"
4+
"url": "http://localhost:8888/__mcp__/sse?clientId=cursor&puppetId=inspector"
55
}
66
}
77
}

.vscode/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"servers": {
33
"dev-inspector": {
44
"type": "sse",
5-
"url": "http://localhost:5173/__mcp__/sse?clientId=vscode&puppetId=inspector"
5+
"url": "http://localhost:8888/__mcp__/sse?clientId=vscode&puppetId=inspector"
66
}
77
}
88
}

examples/nextjs-app/next.config.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NextConfig } from "next";
2-
import UnpluginDevInspector from "@mcpc-tech/unplugin-dev-inspector-mcp";
2+
import UnpluginDevInspector, { turbopackDevInspector } from "@mcpc-tech/unplugin-dev-inspector-mcp";
33

44
/**
55
* Next.js configuration with both Webpack and Turbopack support
@@ -13,6 +13,8 @@ const nextConfig: NextConfig = {
1313
config.plugins.push(
1414
UnpluginDevInspector.webpack({
1515
enabled: true,
16+
autoOpenBrowser: true,
17+
browserUrl: 'http://localhost:3000'
1618
})
1719
);
1820
return config;
@@ -21,17 +23,11 @@ const nextConfig: NextConfig = {
2123
// Turbopack configuration (`next dev --turbopack`)
2224
// Note: Also requires running `npx dev-inspector-server` for MCP endpoints
2325
turbopack: {
24-
rules: {
25-
// Transform TSX files to inject data-source attributes
26-
"src/**/*.tsx": {
27-
loaders: ["@mcpc-tech/unplugin-dev-inspector-mcp/loader"],
28-
as: "*.tsx",
29-
},
30-
"src/**/*.jsx": {
31-
loaders: ["@mcpc-tech/unplugin-dev-inspector-mcp/loader"],
32-
as: "*.jsx",
33-
},
34-
},
26+
rules: turbopackDevInspector({
27+
enabled: true,
28+
autoOpenBrowser: true,
29+
browserUrl: 'http://localhost:3000'
30+
}),
3531
},
3632
};
3733

examples/solid/vite.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import DevInspector from '@mcpc-tech/unplugin-dev-inspector-mcp';
44

55
export default defineConfig({
66
plugins: [DevInspector.vite({
7-
enabled: true,
8-
}),
9-
solid()],
7+
enabled: true,
8+
autoOpenBrowser: true,
9+
}),
10+
solid()],
1011
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"indentWidth": 2,
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignorePatterns": ["**/node_modules/**", "**/dist/**", "**/.next/**"]
3+
}

packages/unplugin-dev-inspector/README.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ This project uses the following sponsor APIs and platforms:
5353
## Key Features
5454

5555
### 🎯 Visual Context
56+
5657
Click any element to instantly send its source code location, computed styles, and DOM hierarchy to AI. No more explaining "it's the blue button in the header".
5758

5859
### 🛠️ Full DevTools Access
60+
5961
AI can access Chrome DevTools to analyze network requests, console logs, and performance metrics. It sees what you see.
6062

6163
### 🤖 Multi-Agent Workflow
64+
6265
Switch between agents (Claude Code, Goose) and track their debugging progress visually with step-by-step status updates.
6366

6467
## Quick Start
@@ -87,13 +90,15 @@ npx @mcpc-tech/unplugin-dev-inspector-mcp setup
8790
```
8891

8992
**Options:**
93+
9094
- `--dry-run` - Preview changes without applying them
9195
- `--config <path>` - Specify config file path (auto-detect by default)
9296
- `--bundler <type>` - Specify bundler type: vite, webpack, nextjs
9397
- `--no-backup` - Skip creating backup files
9498
- `--help` - Show help message
9599

96100
**Examples:**
101+
97102
```bash
98103
# Preview changes before applying
99104
npx @mcpc-tech/unplugin-dev-inspector-mcp setup --dry-run
@@ -106,6 +111,7 @@ npx @mcpc-tech/unplugin-dev-inspector-mcp setup --bundler vite
106111
```
107112

108113
This will:
114+
109115
- Detect your bundler configuration
110116
- Add the necessary import
111117
- Add the plugin to your configuration
@@ -243,8 +249,6 @@ export default function RootLayout({ children }) {
243249

244250
- **Angular** - Support coming soon
245251

246-
247-
248252
## Configuration
249253

250254
### Auto-Update MCP Config
@@ -258,13 +262,13 @@ The plugin automatically updates MCP configuration files for detected editors wh
258262
DevInspector.vite({
259263
// Auto-detect and update (default: true)
260264
updateConfig: true,
261-
265+
262266
// Or specify editors manually
263267
updateConfig: ['cursor', 'vscode'],
264-
268+
265269
// Or disable
266270
updateConfig: false,
267-
271+
268272
// Server name in MCP config (default: 'dev-inspector')
269273
updateConfigServerName: 'my-app-inspector',
270274
})
@@ -289,13 +293,12 @@ DevInspector.vite({
289293

290294
### Custom Agents
291295

292-
This plugin uses the [Agent Client Protocol (ACP)](https://agentclientprotocol.com) to connect with AI agents.
296+
This plugin uses the [Agent Client Protocol (ACP)](https://agentclientprotocol.com) to connect with AI agents.
293297

294298
⏱️ **Note:** Initial connection may be slow as agents are launched via `npx` (downloads packages on first run).
295299

296300
Default agents: [View configuration →](https://github.com/mcpc-tech/dev-inspector-mcp/blob/main/packages/unplugin-dev-inspector/client/constants/agents.ts)
297301

298-
299302
You can customize available AI agents and set a default agent:
300303

301304
```typescript
@@ -327,11 +330,11 @@ export default {
327330
```
328331

329332
**Key Features:**
333+
330334
- Custom agents with the **same name** as [default agents](https://agentclientprotocol.com/overview/agents) automatically inherit missing properties (icons, env)
331335
- You can override just the command/args while keeping default icons
332336
- If no custom agents provided, defaults are: Claude Code, Codex CLI, Gemini CLI, Kimi CLI, Goose, OpenCode
333337

334-
335338
## What It Does
336339

337340
**Click element → Describe issue → AI analyzes → Get fix**
@@ -342,68 +345,81 @@ export default {
342345
4. Get intelligent solutions through natural conversation
343346

344347
**Examples:**
348+
345349
- "Why is this button not clickable?" → AI checks `pointer-events`, z-index, overlays
346350
- "This API call is failing" → AI analyzes network requests, timing, responses
347351
- "Where is this component?" → Jump to source file and line number
348352

349353
## Two Workflow Modes
350-
351-
DevInspector offers two ways to interact with your AI, depending on your preference:
352-
353-
### 1. Editor Mode
354-
**Best for:** Code-heavy tasks, refactoring, and maintaining flow.
355-
356-
- **How it works:** You use your IDE's AI assistant (Cursor, Windsurf, Copilot).
357-
- **The Flow:** Click an element in the browser -> The context (source, props, styles) is sent to your Editor via MCP -> You ask your Editor to fix it.
358-
- **Why:** Keeps you in your coding environment.
359-
360-
### 2. Inspector Bar Mode (Recommended)
361-
**Best for:** Quick fixes, visual tweaks, or if you don't use an AI editor.
362-
363-
- **How it works:** You use the floating "Inspector Bar" directly in the browser.
364-
- **The Flow:** Click "Ask AI" in the browser -> Select an agent (e.g., Claude Code, Custom Script) -> The agent runs in your terminal but interacts with the browser overlay.
365-
- **Why:** No context switching. Great for "what is this?" questions or network debugging.
366-
367-
## MCP Tools
354+
355+
DevInspector offers two ways to interact with your AI, depending on your preference:
356+
357+
### 1. Editor Mode
358+
359+
**Best for:** Code-heavy tasks, refactoring, and maintaining flow.
360+
361+
- **How it works:** You use your IDE's AI assistant (Cursor, Windsurf, Copilot).
362+
- **The Flow:** Click an element in the browser -> The context (source, props, styles) is sent to your Editor via MCP -> You ask your Editor to fix it.
363+
- **Why:** Keeps you in your coding environment.
364+
365+
### 2. Inspector Bar Mode (Recommended)
366+
367+
**Best for:** Quick fixes, visual tweaks, or if you don't use an AI editor.
368+
369+
- **How it works:** You use the floating "Inspector Bar" directly in the browser.
370+
- **The Flow:** Click "Ask AI" in the browser -> Select an agent (e.g., Claude Code, Custom Script) -> The agent runs in your terminal but interacts with the browser overlay.
371+
- **Why:** No context switching. Great for "what is this?" questions or network debugging.
372+
373+
## MCP Tools
368374

369375
### `capture_element_context`
376+
370377
Activates visual selector. Returns source location, DOM hierarchy, styles, dimensions, and user notes.
371378

372379
### `list_inspections`
380+
373381
Shows all inspections with ID, element details, notes, and status (pending/in-progress/completed/failed).
374382

375383
### `update_inspection_status`
384+
376385
Updates inspection status with optional progress steps.
377386

378387
**Parameters:** `status`, `message` (required for completed/failed), `progress`, `inspectionId` (optional)
379388

380389
### `execute_page_script`
390+
381391
Executes JavaScript in browser context. Access to window, document, React/Vue instances, localStorage.
382392

383393
### `chrome_devtools`
394+
384395
Agentic tool for Chrome DevTools access. Provides network inspection, console logs, performance metrics, element interaction, and more.
385396

386397
## MCP Prompts
387398

388399
### `capture_element`
400+
389401
Capture and analyze UI element context.
390402

391403
### `view_inspections`
404+
392405
View all pending, in-progress, and completed inspections.
393406

394407
### `launch_chrome_devtools`
408+
395409
Opens Chrome with DevTools API. Unlocks network analysis, console logs, performance metrics.
396410

397411
**Parameter:** `url` (defaults to dev server)
398412

399413
💡 Optional if Chrome is already open. Use when you need to launch a new Chrome instance.
400414

401415
### `get_network_requests`
416+
402417
List network requests or get details of a specific one. Always refreshes the list first.
403418

404419
**Parameter:** `reqid` (optional) - If provided, get details for that request. If omitted, just list all requests.
405420

406421
### `get_console_messages`
422+
407423
List console messages or get details of a specific one. Always refreshes the list first.
408424

409425
**Parameter:** `msgid` (optional) - If provided, get details for that message. If omitted, just list all messages.
@@ -413,6 +429,7 @@ List console messages or get details of a specific one. Always refreshes the lis
413429
For a deep dive into how the MCP context, CMCP library, and Puppet binding mechanism work together, see the [Architecture Documentation](./docs/architecture/mcp-cmcp-puppet-architecture.md).
414430

415431
**Key concepts:**
432+
416433
- **Hub-and-spoke model**: Vite dev server acts as central hub managing multiple client connections
417434
- **CMCP bidirectional execution**: Server defines tool schemas, browser client provides implementations
418435
- **Puppet binding**: Enables Chrome DevTools ↔ Inspector message passthrough
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
// Ambient module declarations for virtual modules
22
// This file is automatically included when you install the package
33

4-
declare module 'virtual:dev-inspector-mcp' {
5-
/**
6-
* Development-only inspector initialization module.
7-
* This module is automatically tree-shaken in production builds.
8-
*
9-
* Import this in your entry point for non-HTML projects (miniapps, library bundles):
10-
*
11-
* @example
12-
* ```typescript
13-
* // main.ts
14-
* import 'virtual:dev-inspector-mcp';
15-
* ```
16-
*
17-
* When building for production, bundlers will statically replace `import.meta.env.DEV`
18-
* with `false`, causing the entire module code to be removed via dead code elimination.
19-
*/
20-
const _default: void;
21-
export default _default;
4+
declare module "virtual:dev-inspector-mcp" {
5+
/**
6+
* Development-only inspector initialization module.
7+
* This module is automatically tree-shaken in production builds.
8+
*
9+
* Import this in your entry point for non-HTML projects (miniapps, library bundles):
10+
*
11+
* @example
12+
* ```typescript
13+
* // main.ts
14+
* import 'virtual:dev-inspector-mcp';
15+
* ```
16+
*
17+
* When building for production, bundlers will statically replace `import.meta.env.DEV`
18+
* with `false`, causing the entire module code to be removed via dead code elimination.
19+
*/
20+
const _default: void;
21+
export default _default;
2222
}
2323

2424
// Support for custom virtual module names
25-
declare module 'virtual:*' {
26-
const _default: void;
27-
export default _default;
25+
declare module "virtual:*" {
26+
const _default: void;
27+
export default _default;
2828
}

0 commit comments

Comments
 (0)