Skip to main content
Glama

KatCoder MySQL MCP Server

by berthojoris
cli.ts2.55 kB
#!/usr/bin/env node import { Command } from 'commander'; import winston from 'winston'; import { MySQLMCPImplementation } from './implementation'; import { MCPServerConfig } from './server'; const logger = winston.createLogger({ level: 'info', format: winston.format.combine( winston.format.timestamp(), winston.format.colorize(), winston.format.printf(({ timestamp, level, message }) => { return `[${timestamp}] ${level}: ${message}`; }) ), transports: [ new winston.transports.Console() ] }); const program = new Command(); program .name('katcoder-mysql-mcp') .description('KatCoder MySQL Model Context Protocol Server') .version('1.0.0') .argument('<connectionString>', 'MySQL connection string (mysql://user:password@host:port/database)') .argument('[enabledTools]', 'Comma-separated list of enabled tools (default: all)', 'all') .option('-v, --verbose', 'Enable verbose logging') .action(async (connectionString: string, enabledTools: string, options: { verbose?: boolean }) => { try { if (options.verbose) { logger.level = 'debug'; } logger.info('Starting KatCoder MySQL MCP Server'); logger.info(`Connection: ${connectionString.replace(/:([^@]+)@/, ':***@')}`); logger.info(`Enabled tools: ${enabledTools}`); // Parse enabled tools const tools = enabledTools === 'all' ? ['list', 'read', 'create', 'update', 'delete', 'execute', 'ddl', 'transaction', 'bulk_insert', 'utility'] : enabledTools.split(',').map(tool => tool.trim()); // Validate connection string if (!connectionString.startsWith('mysql://')) { throw new Error('Connection string must start with mysql://'); } // Create and start server const config: MCPServerConfig = { connectionString, enabledTools: tools }; const server = new MySQLMCPImplementation(config); await server.run(); logger.info('MySQL MCP Server started successfully'); logger.info('Server is ready to handle requests'); // Handle graceful shutdown const shutdown = async () => { logger.info('Shutting down MySQL MCP Server...'); logger.info('Server shut down successfully'); process.exit(0); }; process.on('SIGINT', shutdown); process.on('SIGTERM', shutdown); } catch (error) { logger.error(`Failed to start server: ${error instanceof Error ? error.message : String(error)}`); process.exit(1); } }); program.parse();

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/berthojoris/katcoder-mysql-mcp'

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