Skip to main content
Glama
Yonsn76

MyPos MCP

by Yonsn76

listarTablas

Retrieve a complete list of all tables available in your MySQL or PostgreSQL database to understand the database structure and available data.

Instructions

Sigue estas reglas para listar tablas: PROPÓSITO: Obtener una lista de todas las tablas en la base de datos. USO: Úsalo cuando necesites saber qué tablas existen. EJEMPLO: "Muestra las tablas disponibles."

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Inline handler function for the 'listarTablas' tool. It fetches the database schema using query_runner.getSchema() and returns a formatted list of table names.
    async () => { const schema = await query_runner.getSchema(); return { content: [ { type: 'text', text: 'Tablas:\n' + schema.map(t => `- ${t.name}`).join('\n') } ] }; }
  • mcp_server.js:64-79 (registration)
    Registration of the 'listarTablas' MCP tool using server.tool(), including description, empty input schema, and inline handler.
    server.tool( 'listarTablas', 'Sigue estas reglas para listar tablas:\n' + 'PROPÓSITO: Obtener una lista de todas las tablas en la base de datos.\n' + 'USO: Úsalo cuando necesites saber qué tablas existen.\n' + 'EJEMPLO: "Muestra las tablas disponibles."', {}, async () => { const schema = await query_runner.getSchema(); return { content: [ { type: 'text', text: 'Tablas:\n' + schema.map(t => `- ${t.name}`).join('\n') } ] }; } );
  • Empty input schema (no parameters) for the 'listarTablas' tool.
    {},
  • QueryRunner.getSchema() method: Retrieves list of tables and their columns using database-specific queries (SHOW TABLES for MySQL, information_schema for PostgreSQL). Called by the tool handler to get table names.
    async getSchema() { if (this.db_type === 'mysql') { const [tables] = await this.pool.execute("SHOW TABLES"); const tableKey = Object.keys(tables[0])[0]; return await Promise.all(tables.map(async tbl => { const tableName = tbl[tableKey]; const [cols] = await this.pool.execute(`SHOW COLUMNS FROM \`${tableName}\``); return { name: tableName, columns: cols.map(c => ({ name: c.Field, type: c.Type })) }; })); } else { // pg const res = await this.pool.query(` SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type='BASE TABLE' `); return await Promise.all(res.rows.map(async row => { const tname = row.table_name; const res2 = await this.pool.query(` SELECT column_name, data_type FROM information_schema.columns WHERE table_name = $1 `, [tname]); return { name: tname, columns: res2.rows.map(c => ({ name: c.column_name, type: c.data_type })) }; })); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Yonsn76/MyPos-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server