@turbot/tailpipe-mcp
Version:
Tailpipe MCP server to query cloud and security logs using AI.
42 lines • 1.73 kB
JavaScript
import { logger } from "../services/logger.js";
import { executeCommand, formatCommandError } from "../utils/command.js";
import { buildTailpipeCommand, getTailpipeEnv } from "../utils/tailpipe.js";
import { formatListResult } from "../utils/format.js";
function parseTables(output) {
const rawTables = JSON.parse(output);
if (!Array.isArray(rawTables)) {
throw new Error('Expected array output from Tailpipe CLI');
}
return rawTables.map(table => ({
name: table.name || '',
...(table.description && { description: table.description }),
local: {
file_count: table.local?.file_count || 0,
file_size: table.local?.file_size || 0
},
plugin: table.plugin || ''
}));
}
export const tool = {
name: "tailpipe_table_list",
description: `List all available Tailpipe tables, including their schemas, descriptions, and column counts. Use tailpipe_table_show for detailed information about specific tables.`,
inputSchema: {
type: "object",
properties: {},
additionalProperties: false
},
handler: async () => {
logger.debug('Executing table_list tool');
const cmd = buildTailpipeCommand('table list', { output: 'json' });
try {
const output = executeCommand(cmd, { env: getTailpipeEnv() });
const tables = parseTables(output);
return formatListResult(tables, 'tables', cmd);
}
catch (error) {
logger.error('Failed to execute table_list tool:', error instanceof Error ? error.message : String(error));
return formatCommandError(error, cmd);
}
}
};
//# sourceMappingURL=tailpipe_table_list.js.map