|
1 | 1 | import { logger } from '@nuxt/kit' |
2 | | -import { addCustomTab } from '@nuxt/devtools-kit' |
| 2 | +import { refreshCustomTabs } from '@nuxt/devtools-kit' |
3 | 3 | import type { Nuxt } from 'nuxt/schema' |
4 | 4 | import type { ModuleOptions } from '../../../../module' |
5 | 5 | import { spawn } from 'node:child_process' |
@@ -171,12 +171,11 @@ async function launchMcpInspector(nuxt: Nuxt, options: ModuleOptions): Promise<v |
171 | 171 | inspectorProcess = spawn('npx', [ |
172 | 172 | '-y', |
173 | 173 | '@modelcontextprotocol/inspector', |
174 | | - 'streamable-http', |
175 | | - mcpServerUrl, |
| 174 | + '--transport', 'http', |
| 175 | + '--server-url', mcpServerUrl, |
176 | 176 | ], { |
177 | 177 | stdio: ['ignore', 'pipe', 'pipe'], |
178 | 178 | env, |
179 | | - shell: true, |
180 | 179 | }) |
181 | 180 |
|
182 | 181 | const childProcess = inspectorProcess |
@@ -368,42 +367,47 @@ export function addDevToolsCustomTabs(nuxt: Nuxt, options: ModuleOptions) { |
368 | 367 | return |
369 | 368 | } |
370 | 369 |
|
371 | | - addCustomTab(() => ({ |
372 | | - category: 'server', |
373 | | - name: 'mcp-inspector', |
374 | | - title: 'MCP Inspector', |
375 | | - icon: 'i-lucide-circuit-board', |
376 | | - view: isReady && inspectorUrl |
377 | | - ? { |
378 | | - type: 'iframe', |
379 | | - src: inspectorUrl, |
380 | | - } |
381 | | - : { |
382 | | - type: 'launch', |
383 | | - description: 'Launch MCP Inspector to test/debug your MCP server', |
384 | | - actions: [ |
385 | | - { |
386 | | - label: promise ? 'Starting...' : 'Launch Inspector', |
387 | | - pending: !!promise, |
388 | | - handle() { |
389 | | - promise = promise || launchMcpInspector(nuxt, options).finally(() => { |
390 | | - promise = null |
391 | | - }) |
392 | | - return promise |
393 | | - }, |
394 | | - }, |
395 | | - ...(inspectorProcess |
396 | | - ? [{ |
397 | | - label: 'Stop Inspector', |
398 | | - handle() { |
399 | | - stopMcpInspector() |
| 370 | + // @ts-ignore devtools:customTabs hook is provided by @nuxt/devtools-kit |
| 371 | + nuxt.hook('devtools:customTabs', (tabs) => { |
| 372 | + tabs.push({ |
| 373 | + category: 'server', |
| 374 | + name: 'mcp-inspector', |
| 375 | + title: 'MCP Inspector', |
| 376 | + icon: 'i-lucide-circuit-board', |
| 377 | + view: isReady && inspectorUrl |
| 378 | + ? { |
| 379 | + type: 'iframe', |
| 380 | + src: inspectorUrl, |
| 381 | + } |
| 382 | + : { |
| 383 | + type: 'launch', |
| 384 | + description: 'Launch MCP Inspector to test/debug your MCP server', |
| 385 | + actions: [ |
| 386 | + { |
| 387 | + label: promise ? 'Starting...' : 'Launch Inspector', |
| 388 | + pending: !!promise, |
| 389 | + handle() { |
| 390 | + promise = promise || launchMcpInspector(nuxt, options).then(() => { |
| 391 | + refreshCustomTabs(nuxt) |
| 392 | + }).finally(() => { |
400 | 393 | promise = null |
401 | | - }, |
402 | | - }] |
403 | | - : []), |
404 | | - ], |
405 | | - }, |
406 | | - }), nuxt) |
| 394 | + }) |
| 395 | + return promise |
| 396 | + }, |
| 397 | + }, |
| 398 | + ...(inspectorProcess |
| 399 | + ? [{ |
| 400 | + label: 'Stop Inspector', |
| 401 | + handle() { |
| 402 | + stopMcpInspector() |
| 403 | + promise = null |
| 404 | + }, |
| 405 | + }] |
| 406 | + : []), |
| 407 | + ], |
| 408 | + }, |
| 409 | + }) |
| 410 | + }) |
407 | 411 |
|
408 | 412 | nuxt.hook('close', () => { |
409 | 413 | stopMcpInspector() |
|
0 commit comments