|
| 1 | +import { chdir } from 'process'; |
| 2 | +import { exec, ProcessOutput, silentNpm } from '../../utils/process'; |
| 3 | +import assert from 'node:assert/strict'; |
| 4 | + |
| 5 | +const MCP_INSPECTOR_PACKAGE_NAME = '@modelcontextprotocol/inspector-cli'; |
| 6 | +const MCP_INSPECTOR_PACKAGE_VERSION = '0.16.2'; |
| 7 | +const MCP_INSPECTOR_COMMAND_NAME = 'mcp-inspector-cli'; |
| 8 | + |
| 9 | +async function runInspector(...args: string[]): Promise<ProcessOutput> { |
| 10 | + const result = await exec( |
| 11 | + MCP_INSPECTOR_COMMAND_NAME, |
| 12 | + '--cli', |
| 13 | + 'npx', |
| 14 | + '--no', |
| 15 | + '@angular/cli', |
| 16 | + 'mcp', |
| 17 | + ...args, |
| 18 | + ); |
| 19 | + |
| 20 | + return result; |
| 21 | +} |
| 22 | + |
| 23 | +export default async function () { |
| 24 | + await silentNpm( |
| 25 | + 'install', |
| 26 | + '--ignore-scripts', |
| 27 | + '-g', |
| 28 | + `${MCP_INSPECTOR_PACKAGE_NAME}@${MCP_INSPECTOR_PACKAGE_VERSION}`, |
| 29 | + ); |
| 30 | + |
| 31 | + // Ensure 'list_projects' is registered when inside an Angular workspace |
| 32 | + const { stdout: stdoutInsideWorkspace } = await runInspector('--method', 'tools/list'); |
| 33 | + |
| 34 | + assert.match(stdoutInsideWorkspace, /"list_projects"/); |
| 35 | + assert.match(stdoutInsideWorkspace, /"get_best_practices"/); |
| 36 | + assert.match(stdoutInsideWorkspace, /"search_documentation"/); |
| 37 | + |
| 38 | + chdir('..'); |
| 39 | + |
| 40 | + const { stdout: stdoutOutsideWorkspace } = await runInspector('--method', 'tools/list'); |
| 41 | + |
| 42 | + assert.doesNotMatch(stdoutOutsideWorkspace, /"list_projects"/); |
| 43 | + assert.match(stdoutOutsideWorkspace, /"get_best_practices"/); |
| 44 | + assert.match(stdoutInsideWorkspace, /"search_documentation"/); |
| 45 | + |
| 46 | + silentNpm('uninstall', '-g', MCP_INSPECTOR_PACKAGE_NAME); |
| 47 | +} |
0 commit comments