Skip to main content
Glama

MCP Server for MySQL

MIT License
15
790
  • Linux
  • Apple
import mysql from 'mysql2/promise'; async function testConnection() { try { console.log('Attempting to connect to MySQL...'); // Connection configuration const config = { host: process.env.MYSQL_HOST || '127.0.0.1', port: process.env.MYSQL_PORT || 3306, user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '', database: process.env.MYSQL_DATABASE }; console.log('Connection config:', { ...config, password: config.password ? '******' : 'not set' }); // Create connection pool const pool = mysql.createPool(config); // Test connection const connection = await pool.getConnection(); console.log('Connection successful!'); // Get server info const [rows] = await connection.query('SELECT VERSION() as version'); console.log('MySQL Version:', rows[0].version); // Release connection connection.release(); // Close pool await pool.end(); console.log('Connection pool closed'); } catch (error) { console.error('Error connecting to MySQL:', error); } } testConnection();

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/benborla/mcp-server-mysql'

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