Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

918 B
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { mysqlConnect, mysqlGetTableNames } from '../common';
import { mysqlAuth } from '../..';
import { getTablesOutputSchema } from '../output-schemas';

export default createAction({
  auth: mysqlAuth,
  name: 'get_tables',
  displayName: 'Get Tables',
  description: 'Returns a list of tables in the database',
  audience: 'both',
  outputSchema: getTablesOutputSchema,
  aiMetadata: { description: 'Lists the names of all tables in the connected MySQL database (SHOW TABLES). Use to discover the schema before reading or writing rows. Takes no input; read-only and idempotent.', idempotent: true },
  props: {},
  async run(context) {
    const conn = await mysqlConnect(context.auth, context.propsValue);
    try {
      const tables = await mysqlGetTableNames(conn);
      return { tables };
    } finally {
      await conn.end();
    }
  },
});