UNPKG

@turbot/powerpipe-mcp

Version:

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

46 lines 1.69 kB
import { executeCommand, formatCommandError } from "../utils/command.js"; import { buildPowerpipeCommand } from "../utils/powerpipe.js"; // Define a function to handle status resource requests export async function handleStatusResource(uri) { // Check if this is a status resource URI if (uri !== 'powerpipe://status') { return null; } try { const cmd = buildPowerpipeCommand('--version', ''); const output = executeCommand(cmd); // Version output is not JSON, so we need to parse it manually const versionMatch = output.trim().match(/v?(\d+\.\d+(\.\d+)?)/i); const version = versionMatch ? versionMatch[1] : output.trim(); return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify({ powerpipe: { version }, server: { version: process.env.MCP_SERVER_VERSION || 'unknown', startTime: process.env.MCP_SERVER_START_TIME || 'unknown' } }, null, 2) }], _meta: {} }; } catch (error) { const errorResult = formatCommandError(error); return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify({ error: errorResult.content[0].text }, null, 2) }], _meta: {} }; } } //# sourceMappingURL=status.js.map