03e7ea0e69
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
Replace template API scaffolding with Windows desktop system tools: - shell.ts: PowerShell/cmd/bash executor + persistent terminal sessions - tools/execute.ts: windows_execute (#1) - tools/process.ts: windows_process_list (#2) - tools/audio.ts: windows_audio_get, windows_audio_set (#6, #7) - tools/system.ts: windows_system_info (#18) - tools/terminal.ts: windows_terminal_start/send/read/list/kill (#35) - tools/filesystem.ts: windows_file_read/write/edit, windows_search (#36-39) Removes template API client/config/types (not needed for local OS MCP). Authored-by: Moko Consulting
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* Tool: windows_execute — Execute shell commands (#1)
|
|
*/
|
|
|
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
import { z } from 'zod';
|
|
import { runShell } from '../shell.js';
|
|
|
|
export function registerExecuteTools(server: McpServer): void {
|
|
server.tool(
|
|
'windows_execute',
|
|
'Execute a shell command (PowerShell, cmd, or bash). Returns stdout, stderr, and exit code.',
|
|
{
|
|
command: z.string().describe('The command to execute'),
|
|
shell: z.enum(['pwsh', 'cmd', 'bash']).default('pwsh').describe('Shell to use'),
|
|
timeout: z.number().optional().describe('Timeout in milliseconds (default 30000)'),
|
|
cwd: z.string().optional().describe('Working directory'),
|
|
},
|
|
async ({ command, shell, timeout, cwd }) => {
|
|
const result = await runShell(command, { shell, timeout, cwd });
|
|
const parts: string[] = [];
|
|
|
|
if (result.stdout) parts.push(result.stdout);
|
|
if (result.stderr) parts.push(`[stderr]\n${result.stderr}`);
|
|
parts.push(`[exit code: ${result.exitCode}]`);
|
|
|
|
return {
|
|
content: [{ type: 'text', text: parts.join('\n\n') }],
|
|
isError: result.exitCode !== 0,
|
|
};
|
|
},
|
|
);
|
|
}
|