UNPKG

wmic-mcp

Version:

MCP server for the Windows Management Instrumentation Console (wmic).

32 lines 1.34 kB
#!/usr/bin/env node import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; import { exec } from "child_process"; const server = new McpServer({ name: "wmic", version: "0.0.2", }, { instructions: "Use the `call_wmic` tool to get system information. For example, you can use call_wmic with parameters `cpu get name` to get the CPU name.", }); server.tool("call_wmic", "Uses WMIC (the Windows Management Instrumentation Command-line) to get system information.", { commandWithoutWMIC_exe: z.string() }, async ({ commandWithoutWMIC_exe }) => { const command = `wmic ${commandWithoutWMIC_exe}`; const result = await new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { if (error) { reject(`Error: ${error.message}`); } else if (stderr) { reject(`Error: ${stderr}`); } else { resolve(stdout); } }); }); return { content: [{ type: "text", text: result }] }; }); // Start receiving messages on stdin and sending messages on stdout const transport = new StdioServerTransport(); await server.connect(transport); //# sourceMappingURL=index.js.map