UNPKG

@turbot/powerpipe-mcp

Version:

Powerpipe MCP server to run benchmarks, detections and controls using AI.

45 lines 1.85 kB
import { ConfigurationService } from "../services/config.js"; import { executeCommand, formatResult } from "../utils/command.js"; import { buildPowerpipeCommand, getPowerpipeEnv } from "../utils/powerpipe.js"; import { handlePowerpipeRunOutput } from "../utils/powerpipe_run.js"; function validateParams(args) { if (!args || typeof args !== 'object') { throw new Error('Arguments must be an object'); } const params = args; if (!params.qualified_name || typeof params.qualified_name !== 'string') { throw new Error('qualified_name is required and must be a string'); } return params; } export const tool = { name: "powerpipe_control_run", description: "Executes a specific control to evaluate your infrastructure against a single compliance requirement. Use control show first to understand what will be evaluated.", inputSchema: { type: "object", properties: { qualified_name: { type: "string", description: "The qualified name of the control to run" } }, required: ["qualified_name"], additionalProperties: false }, handler: async (args) => { const params = validateParams(args); const config = ConfigurationService.getInstance(); const modDirectory = config.getModLocation(); const cmd = buildPowerpipeCommand(`control run ${params.qualified_name}`, modDirectory, { output: 'json' }); const env = getPowerpipeEnv(modDirectory); try { const output = executeCommand(cmd, { env }); const result = JSON.parse(output); return formatResult({ result }, cmd); } catch (error) { return handlePowerpipeRunOutput(error, cmd); } } }; //# sourceMappingURL=powerpipe_control_run.js.map