-
-
Notifications
You must be signed in to change notification settings - Fork 399
Expand file tree
/
Copy pathtestMcpIntrospection.ts
More file actions
85 lines (70 loc) · 2.75 KB
/
Copy pathtestMcpIntrospection.ts
File metadata and controls
85 lines (70 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import * as fs from 'fs'
import * as path from 'path'
import { ElectronApplication, _electron as electron } from 'playwright'
// Constants
const DEFAULT_REMOTE_DEBUGGING_PORT = 9222
const PROJECT_ROOT = path.join(__dirname, '../../..')
async function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}
async function main() {
console.log('=== MCP Introspection Demo ===')
console.log('Starting MQTT Explorer with MCP introspection flags...')
// Launch Electron app with MCP introspection enabled
const electronApp: ElectronApplication = await electron.launch({
args: [
PROJECT_ROOT,
'--enable-mcp-introspection',
`--remote-debugging-port=${DEFAULT_REMOTE_DEBUGGING_PORT}`,
'--no-sandbox',
],
timeout: 30000,
})
console.log('✓ App launched with MCP introspection')
console.log(`✓ Remote debugging enabled on port ${DEFAULT_REMOTE_DEBUGGING_PORT}`)
// Get the first window
const page = await electronApp.firstWindow({ timeout: 10000 })
const title = await page.title()
console.log(`✓ Window ready, title: ${title}`)
// Check console logs for remote debugging message
const logs: Array<string> = []
page.on('console', msg => {
const text = msg.text()
logs.push(text)
if (text.includes('Remote debugging enabled')) {
console.log(`✓ ${text}`)
}
})
// Wait for app to load
await sleep(3000)
// Take screenshot 1: Main app window showing MCP introspection is working
console.log('\nTaking screenshots...')
const screenshot1Path = path.join(PROJECT_ROOT, 'screenshot-mcp-app-running.png')
await page.screenshot({
path: screenshot1Path,
fullPage: false,
})
console.log(`✓ Screenshot 1 saved: ${screenshot1Path}`)
// Take screenshot 2: Connection form (showing the app is interactive)
await sleep(1000)
const screenshot2Path = path.join(PROJECT_ROOT, 'screenshot-mcp-connection-form.png')
await page.screenshot({
path: screenshot2Path,
fullPage: true,
})
console.log(`✓ Screenshot 2 saved: ${screenshot2Path}`)
console.log('\n=== MCP Introspection Test Results ===')
console.log('✓ Application started successfully with MCP introspection')
console.log(`✓ Remote debugging port: ${DEFAULT_REMOTE_DEBUGGING_PORT}`)
console.log(`✓ Chrome DevTools Protocol is accessible at: http://localhost:${DEFAULT_REMOTE_DEBUGGING_PORT}`)
console.log('✓ Screenshots captured successfully')
console.log('\nThe MCP introspection implementation is working correctly!')
console.log('External tools can now connect to the app via CDP for automated testing.')
// Close the app
await electronApp.close()
process.exit(0)
}
main().catch(error => {
console.error('Error during MCP introspection test:', error)
process.exit(1)
})