@mcpc-tech/unplugin-dev-inspector-mcp 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ ---
2
+ title: Inspect Web Mcp
3
+ emoji: 😻
4
+ colorFrom: purple
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 5.49.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: AI-powered web debugging with visual element inspection
11
+ tags:
12
+ - building-mcp-track-creative
13
+ - mcp-in-action-track-creative
14
+ ---
15
+
16
+ # @mcpc-tech/unplugin-dev-inspector-mcp
17
+
18
+ [![npm version](https://img.shields.io/npm/v/@mcpc-tech/unplugin-dev-inspector-mcp.svg)](https://www.npmjs.com/package/@mcpc-tech/unplugin-dev-inspector-mcp)
19
+ [![npm downloads](https://img.shields.io/npm/dm/@mcpc-tech/unplugin-dev-inspector-mcp.svg)](https://www.npmjs.com/package/@mcpc-tech/unplugin-dev-inspector-mcp)
20
+
21
+ **AI-powered visual debugging for React & Vue via MCP and ACP.**
22
+
23
+ Works with any MCP-compatible AI client. Supports ACP agents: **Claude Code**, **Codex CLI**, **Gemini CLI**, **OpenCode**, and [more](https://agentclientprotocol.com/overview/agents).
24
+
25
+ Click any element → AI diagnoses issues, inspects source, analyzes network, and provides fixes.
26
+
27
+ ## 🎬 Demo Video
28
+
29
+ [![Demo Video](https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExbnVvb2Y4MmJqbGJyMGJkendvZjkzZHN5MG4zY21mMXhjemF6dWk4aSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/67nUJwE7Fb2TMhBjhy/giphy.gif)](https://www.youtube.com/shorts/TCt2oOtPS_k)
30
+
31
+ 👉 **Watch the demo:** [https://www.youtube.com/shorts/TCt2oOtPS_k](https://www.youtube.com/shorts/TCt2oOtPS_k)
32
+
33
+ ## 📢 Social Media
34
+
35
+ 🐦 **Twitter/X Post:** [https://x.com/yaoandyan/status/1995082020431753600](https://x.com/yaoandyan/status/1995082020431753600?s=20)
36
+
37
+ ## 👥 Team
38
+
39
+ - [yaonyan](https://huggingface.co/zpharnoex) - Project Creator
40
+
41
+ ## 🤝 Sponsors & Integrations
42
+
43
+ This project uses the following sponsor APIs and platforms:
44
+
45
+ - **Anthropic** - Claude API for MCP integration testing and AI-powered debugging capabilities
46
+ - **Gradio** - `@gradio/client` for connecting to Gradio-powered APIs in the demo app
47
+
48
+ ---
49
+
50
+ ![Demo: MCP-powered visual debugging in action](https://media.giphy.com/media/sGCk7b783GiGm5vZGl/giphy.gif)
51
+
52
+ ## Key Features
53
+
54
+ ### 🎯 Visual Context
55
+ 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".
56
+
57
+ ### 🛠️ Full DevTools Access
58
+ AI can access Chrome DevTools to analyze network requests, console logs, and performance metrics. It sees what you see.
59
+
60
+ ### 🤖 Multi-Agent Workflow
61
+ Switch between agents (Claude Code, Goose) and track their debugging progress visually with step-by-step status updates.
62
+
63
+ ## Quick Start
64
+
65
+ ```bash
66
+ # npm
67
+ npm i -D @mcpc-tech/unplugin-dev-inspector-mcp@beta
68
+ # pnpm
69
+ pnpm add -D @mcpc-tech/unplugin-dev-inspector-mcp@beta
70
+ # yarn
71
+ yarn add -D @mcpc-tech/unplugin-dev-inspector-mcp@beta
72
+ ```
73
+
74
+ ```typescript
75
+ // vite.config.ts
76
+ import DevInspector from '@mcpc-tech/unplugin-dev-inspector-mcp';
77
+ import react from '@vitejs/plugin-react'; // or vue()
78
+
79
+ export default {
80
+ plugins: [
81
+ DevInspector.vite({
82
+ enabled: true,
83
+ enableMcp: true,
84
+ }),
85
+ react(), // or vue()
86
+ ],
87
+ };
88
+ ```
89
+
90
+ > 💡 **Troubleshooting:** If source locations show `unknown:0:0`, try moving `DevInspector.vite()` **before** framework plugins like `react()`, `vue()`, or `preact()`. This ensures source location injection happens before JSX transformation.
91
+
92
+ Currently supports **Vite**. Webpack, Rollup, esbuild, and Rspack support coming soon.
93
+
94
+ ### For Non-HTML Projects (Miniapps, Library Bundles)
95
+
96
+ If your project doesn't use HTML files (e.g., miniapp platforms that only bundle JS):
97
+
98
+ ```typescript
99
+ // vite.config.ts
100
+ DevInspector.vite({
101
+ enabled: true,
102
+ autoInject: false // Disable HTML injection
103
+ })
104
+ ```
105
+
106
+ ```typescript
107
+ // main.ts or app entry point
108
+ import 'virtual:dev-inspector-mcp'; // ← Add this import
109
+ ```
110
+
111
+ **✅ Zero Production Impact:** This import is automatically removed in production builds via tree-shaking. The entire dev-inspector code is wrapped in `if (import.meta.env.DEV)` guards, which bundlers statically replace with `false` during production builds.
112
+
113
+ #### Custom Virtual Module Name
114
+
115
+ If `virtual:dev-inspector-mcp` conflicts with your project, you can customize it:
116
+
117
+ ```typescript
118
+ // vite.config.ts
119
+ DevInspector.vite({
120
+ enabled: true,
121
+ autoInject: false,
122
+ virtualModuleName: 'virtual:my-custom-inspector' // ← Custom name
123
+ })
124
+ ```
125
+
126
+ ```typescript
127
+ // main.ts
128
+ import 'virtual:my-custom-inspector'; // ← Use your custom name
129
+ ```
130
+
131
+ ## Configuration
132
+
133
+ ### Auto-Update MCP Config
134
+
135
+ The plugin automatically updates MCP configuration files for detected editors when the dev server starts. This saves you from manually configuring MCP endpoints.
136
+
137
+ **Supported editors:** Cursor, VSCode, Windsurf, Claude Code
138
+
139
+ ```typescript
140
+ // vite.config.ts
141
+ DevInspector.vite({
142
+ // Auto-detect and update (default: true)
143
+ updateConfig: true,
144
+
145
+ // Or specify editors manually
146
+ updateConfig: ['cursor', 'vscode'],
147
+
148
+ // Or disable
149
+ updateConfig: false,
150
+
151
+ // Server name in MCP config (default: 'dev-inspector')
152
+ updateConfigServerName: 'my-app-inspector',
153
+ })
154
+ ```
155
+
156
+ **Custom editors:** For non-standard editors, use `customEditors`:
157
+
158
+ ```typescript
159
+ DevInspector.vite({
160
+ customEditors: [
161
+ {
162
+ id: 'my-editor',
163
+ name: 'My Editor',
164
+ configPath: '~/.my-editor', // absolute, ~/relative, or project-relative
165
+ configFileName: 'mcp.json',
166
+ serverUrlKey: 'url', // default: 'url'
167
+ configFormat: 'mcpServers', // 'mcpServers' or 'servers' (vscode-style)
168
+ },
169
+ ],
170
+ })
171
+ ```
172
+
173
+ ### Custom Agents
174
+
175
+ This plugin uses the [Agent Client Protocol (ACP)](https://agentclientprotocol.com) to connect with AI agents.
176
+
177
+ ⏱️ **Note:** Initial connection may be slow as agents are launched via `npx` (downloads packages on first run).
178
+
179
+ Default agents: [View configuration →](https://github.com/mcpc-tech/dev-inspector-mcp/blob/main/packages/unplugin-dev-inspector/client/constants/agents.ts)
180
+
181
+
182
+ You can customize available AI agents and set a default agent:
183
+
184
+ ```typescript
185
+ // vite.config.ts
186
+ export default {
187
+ plugins: [
188
+ DevInspector.vite({
189
+ enabled: true,
190
+ enableMcp: true,
191
+ // Custom agents (will be merged with default properties)
192
+ agents: [
193
+ {
194
+ name: "Claude Code", // Matches default - auto-fills icon and env
195
+ command: "npx",
196
+ args: ["-y", "@zed-industries/claude-code-acp"],
197
+ },
198
+ {
199
+ name: "My Custom Agent",
200
+ command: "my-agent-cli",
201
+ args: ["--mode", "acp"],
202
+ env: [{ key: "MY_API_KEY", required: true }],
203
+ meta: { icon: "https://example.com/icon.svg" }
204
+ }
205
+ ],
206
+ // Set default agent to show on startup
207
+ defaultAgent: "Claude Code"
208
+ }),
209
+ ],
210
+ };
211
+ ```
212
+
213
+ **Key Features:**
214
+ - Custom agents with the **same name** as [default agents](https://agentclientprotocol.com/overview/agents) automatically inherit missing properties (icons, env)
215
+ - You can override just the command/args while keeping default icons
216
+ - If no custom agents provided, defaults are: Claude Code, Codex CLI, Gemini CLI, Kimi CLI, Goose, OpenCode
217
+
218
+
219
+ ## What It Does
220
+
221
+ **Click element → Describe issue → AI analyzes → Get fix**
222
+
223
+ 1. Click any UI element to capture context (source, styles, DOM)
224
+ 2. Describe what's wrong or ask a question about the element
225
+ 3. AI diagnoses using Chrome DevTools integration
226
+ 4. Get intelligent solutions through natural conversation
227
+
228
+ **Examples:**
229
+ - "Why is this button not clickable?" → AI checks `pointer-events`, z-index, overlays
230
+ - "This API call is failing" → AI analyzes network requests, timing, responses
231
+ - "Where is this component?" → Jump to source file and line number
232
+
233
+ ## MCP Tools
234
+
235
+ ### `capture_element_context`
236
+ Activates visual selector. Returns source location, DOM hierarchy, styles, dimensions, and user notes.
237
+
238
+ ### `list_inspections`
239
+ Shows all inspections with ID, element details, notes, and status (pending/in-progress/completed/failed).
240
+
241
+ ### `update_inspection_status`
242
+ Updates inspection status with optional progress steps.
243
+
244
+ **Parameters:** `status`, `message` (required for completed/failed), `progress`, `inspectionId` (optional)
245
+
246
+ ### `execute_page_script`
247
+ Executes JavaScript in browser context. Access to window, document, React/Vue instances, localStorage.
248
+
249
+ ### `chrome_devtools`
250
+ Agentic tool for Chrome DevTools access. Provides network inspection, console logs, performance metrics, element interaction, and more.
251
+
252
+ ## MCP Prompts
253
+
254
+ ### `capture_element`
255
+ Capture and analyze UI element context.
256
+
257
+ ### `view_inspections`
258
+ View all pending, in-progress, and completed inspections.
259
+
260
+ ### `launch_chrome_devtools`
261
+ Opens Chrome with DevTools API. Unlocks network analysis, console logs, performance metrics.
262
+
263
+ **Parameter:** `url` (defaults to dev server)
264
+
265
+ 💡 Optional if Chrome is already open. Use when you need to launch a new Chrome instance.
266
+
267
+ ### `get_network_requests`
268
+ List network requests or get details of a specific one. Always refreshes the list first.
269
+
270
+ **Parameter:** `reqid` (optional) - If provided, get details for that request. If omitted, just list all requests.
271
+
272
+ ### `get_console_messages`
273
+ List console messages or get details of a specific one. Always refreshes the list first.
274
+
275
+ **Parameter:** `msgid` (optional) - If provided, get details for that message. If omitted, just list all messages.
276
+
277
+ ## Architecture
278
+
279
+ 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).
280
+
281
+ **Key concepts:**
282
+ - **Hub-and-spoke model**: Vite dev server acts as central hub managing multiple client connections
283
+ - **CMCP bidirectional execution**: Server defines tool schemas, browser client provides implementations
284
+ - **Puppet binding**: Enables Chrome DevTools ↔ Inspector message passthrough
285
+ - **Dynamic rebinding**: Automatic connection recovery after browser refresh
286
+
287
+ ## License
288
+
289
+ MIT