032c50aa46
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Changelog Validation / Validate CHANGELOG.md (pull_request) Has been cancelled
MCP: Copilot Agent / Run Copilot Coding Agent (pull_request) Has been cancelled
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Generic: Repo Health / Access control (pull_request) Has been cancelled
Universal: PR Check / Changelog Updated (pull_request) Has been cancelled
MCP: Build & Validate / build (20) (pull_request) Has been cancelled
MCP: Build & Validate / build (22) (pull_request) Has been cancelled
MCP: Standards Compliance / Secret Scanning (pull_request) Has been cancelled
MCP: Standards Compliance / License Header Validation (pull_request) Has been cancelled
MCP: Standards Compliance / Repository Structure Validation (pull_request) Has been cancelled
MCP: Standards Compliance / Coding Standards Check (pull_request) Has been cancelled
MCP: Standards Compliance / Workflow Configuration Check (pull_request) Has been cancelled
MCP: Standards Compliance / Documentation Quality Check (pull_request) Has been cancelled
MCP: Standards Compliance / README Completeness Check (pull_request) Has been cancelled
MCP: Standards Compliance / Git Repository Hygiene (pull_request) Has been cancelled
MCP: Standards Compliance / File Naming Standards (pull_request) Has been cancelled
MCP: Standards Compliance / Insecure Code Pattern Detection (pull_request) Has been cancelled
MCP: Standards Compliance / Line Length Check (pull_request) Has been cancelled
MCP: Standards Compliance / Script Integrity Validation (pull_request) Has been cancelled
MCP: Standards Compliance / File Size Limits (pull_request) Has been cancelled
MCP: Standards Compliance / Dead Code Detection (pull_request) Has been cancelled
MCP: Standards Compliance / Binary File Detection (pull_request) Has been cancelled
MCP: Standards Compliance / TODO/FIXME Tracking (pull_request) Has been cancelled
MCP: Standards Compliance / Broken Link Detection (pull_request) Has been cancelled
MCP: Standards Compliance / API Documentation Coverage (pull_request) Has been cancelled
MCP: Standards Compliance / Accessibility Check (pull_request) Has been cancelled
MCP: Standards Compliance / Performance Metrics (pull_request) Has been cancelled
Universal: Auto-Assign / Assign unassigned issues and PRs (pull_request_target) Has been cancelled
MCP: Standards Compliance / Version Consistency Check (pull_request) Has been cancelled
MCP: Standards Compliance / Code Complexity Analysis (pull_request) Has been cancelled
MCP: Standards Compliance / Code Duplication Detection (pull_request) Has been cancelled
Universal: CodeQL Analysis / Analyze (actions) (pull_request) Has been cancelled
MCP: Standards Compliance / Terraform Configuration Validation (pull_request) Has been cancelled
Universal: CodeQL Analysis / Analyze (javascript) (pull_request) Has been cancelled
MCP: Standards Compliance / Unused Dependencies Check (pull_request) Has been cancelled
MCP: Standards Compliance / Enterprise Readiness Check (pull_request) Has been cancelled
MCP: Standards Compliance / Repository Health Check (pull_request) Has been cancelled
Universal: CodeQL Analysis / Security Scan Summary (pull_request) Has been cancelled
MCP: Standards Compliance / Dependency Vulnerability Scanning (pull_request) Has been cancelled
MCP: Standards Compliance / Compliance Summary (pull_request) Has been cancelled
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been cancelled
Generic: Repo Health / Release configuration (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
v1.3 — Admin Tools: - tools/scheduler.ts: windows_task_scheduler_list, _manage (#27, #28) - tools/registry.ts: windows_registry_read, _write (#29, #30) - tools/environment.ts: windows_env_get, _set (#31, #32) - tools/startup.ts: windows_startup_list, _manage (#33, #34) - tools/config.ts: windows_mcp_config (#40) v1.4 — Advanced: - tools/apps.ts: windows_installed_apps (#19) - tools/dialog.ts: windows_dialog (#21) - tools/netstat.ts: windows_network_connections (#23) - tools/recycle_bin.ts: windows_recycle_bin (#26) All 40 issues implemented. 44 tools total (some issues split into sub-tools like terminal_start/send/read/list/kill). Authored-by: Moko Consulting
88 lines
3.4 KiB
TypeScript
88 lines
3.4 KiB
TypeScript
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* Tool: windows_dialog (#21)
|
|
*/
|
|
|
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
import { z } from 'zod';
|
|
import { runPowerShell } from '../shell.js';
|
|
|
|
export function registerDialogTools(server: McpServer): void {
|
|
server.tool(
|
|
'windows_dialog',
|
|
'Show system dialogs: message box, input prompt, file/folder picker.',
|
|
{
|
|
type: z.enum(['message', 'input', 'file_open', 'file_save', 'folder']).describe('Dialog type'),
|
|
title: z.string().default('mcp_windows').describe('Dialog title'),
|
|
message: z.string().optional().describe('Message text (for message/input)'),
|
|
buttons: z.enum(['ok', 'okcancel', 'yesno', 'yesnocancel']).default('ok').describe('Buttons (for message)'),
|
|
filter: z.string().optional().describe('File filter (for file dialogs, e.g. "Text files|*.txt|All files|*.*")'),
|
|
default_path: z.string().optional().describe('Default path/filename'),
|
|
},
|
|
async ({ type, title, message, buttons, filter, default_path }) => {
|
|
let ps: string;
|
|
|
|
switch (type) {
|
|
case 'message': {
|
|
const btnMap: Record<string, number> = { ok: 0, okcancel: 1, yesno: 4, yesnocancel: 3 };
|
|
ps = `
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
$result = [System.Windows.Forms.MessageBox]::Show('${(message || '').replace(/'/g, "''")}', '${title.replace(/'/g, "''")}', ${btnMap[buttons]})
|
|
$result.ToString()`;
|
|
break;
|
|
}
|
|
|
|
case 'input':
|
|
ps = `
|
|
Add-Type -AssemblyName Microsoft.VisualBasic
|
|
$result = [Microsoft.VisualBasic.Interaction]::InputBox('${(message || 'Enter value:').replace(/'/g, "''")}', '${title.replace(/'/g, "''")}', '${(default_path || '').replace(/'/g, "''")}')
|
|
if ($result) { $result } else { '__CANCELLED__' }`;
|
|
break;
|
|
|
|
case 'file_open':
|
|
ps = `
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
$dlg = New-Object System.Windows.Forms.OpenFileDialog
|
|
$dlg.Title = '${title.replace(/'/g, "''")}'
|
|
${filter ? `$dlg.Filter = '${filter.replace(/'/g, "''")}'` : ''}
|
|
${default_path ? `$dlg.InitialDirectory = '${default_path.replace(/'/g, "''")}'` : ''}
|
|
$dlg.Multiselect = $false
|
|
if ($dlg.ShowDialog() -eq 'OK') { $dlg.FileName } else { '__CANCELLED__' }`;
|
|
break;
|
|
|
|
case 'file_save':
|
|
ps = `
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
$dlg = New-Object System.Windows.Forms.SaveFileDialog
|
|
$dlg.Title = '${title.replace(/'/g, "''")}'
|
|
${filter ? `$dlg.Filter = '${filter.replace(/'/g, "''")}'` : ''}
|
|
${default_path ? `$dlg.FileName = '${default_path.replace(/'/g, "''")}'` : ''}
|
|
if ($dlg.ShowDialog() -eq 'OK') { $dlg.FileName } else { '__CANCELLED__' }`;
|
|
break;
|
|
|
|
case 'folder':
|
|
ps = `
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
$dlg = New-Object System.Windows.Forms.FolderBrowserDialog
|
|
$dlg.Description = '${(message || title).replace(/'/g, "''")}'
|
|
${default_path ? `$dlg.SelectedPath = '${default_path.replace(/'/g, "''")}'` : ''}
|
|
if ($dlg.ShowDialog() -eq 'OK') { $dlg.SelectedPath } else { '__CANCELLED__' }`;
|
|
break;
|
|
}
|
|
|
|
const result = await runPowerShell(ps, { timeout: 120000 }); // Long timeout — user interaction
|
|
if (result.exitCode !== 0) {
|
|
return { content: [{ type: 'text', text: `Error: ${result.stderr}` }], isError: true };
|
|
}
|
|
|
|
const output = result.stdout.trim();
|
|
if (output === '__CANCELLED__') {
|
|
return { content: [{ type: 'text', text: 'Dialog cancelled by user.' }] };
|
|
}
|
|
|
|
return { content: [{ type: 'text', text: output }] };
|
|
},
|
|
);
|
|
}
|