Simple MySQL MCP Server

by fabiovige

Not rated
GitHub

About

A simple MCP server for MySQL, demonstrating fundamental MCP protocol concepts. Requires a MySQL database connection configured via environment variables.

Details

Author
fabiovige
Categories
Database, Other

Setup

Install Simple MySQL MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/fabiovige/mcp-mysql-simple

Follow the installation instructions in the repository README, then restart your MCP client.

Servidor MCP (Model Context Protocol) para MySQL com arquitetura limpa e princípios SOLID.

- Separação de Responsabilidades: Classes especializadas para cada função
- SOLID Principles: Código mais maintível e extensível
- Clean Architecture: Estrutura modular e testável

- Validação de Queries: Proteção contra operações perigosas
- Sanitização: Nomes de tabelas validados
- SQL Injection Protection: Parâmetros seguros

- Conexão Reutilizada: Gerenciamento eficiente de recursos
- Tratamento de Erros: Mensagens consistentes e informativas
- Shutdown Gracioso: Encerramento controlado de conexões

MySQLMCPServer ├── DatabaseConfig (Configurações) ├── DatabaseConnection (Conexão MySQL) ├── QueryValidator (Validação e Segurança) ├── ResponseFormatter (Formatação) ├── ToolsHandler (Ferramentas) ├── ResourcesHandler (Recursos) └── PromptsHandler (Templates)

- execute_query: Executa queries SQL com validação
- describe_table: Descreve estrutura de tabelas

- mysql://databases: Lista de bancos disponíveis
- mysql://tables: Tabelas do banco atual
- mysql://schema: Schema completo

- analyze_table: Análise detalhada de tabela
- find_large_tables: Tabelas com mais registros
- database_overview: Visão geral do banco

MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=root MYSQL_PASSWORD=sua_senha MYSQL_DATABASE=seu_banco
# Compilar npm run build # Executar npm start # Desenvolvimento npm run dev

Adicione aoclaude_desktop_config.json:

{ "mcpServers": { "mysql-optimized": { "command": "node", "args": ["/caminho/para/dist/index.js"], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "root", "MYSQL_PASSWORD": "sua_senha", "MYSQL_DATABASE": "seu_banco" } } } }

- ✅ Bloqueio deDROP DATABASE/TABLE
- ✅ Proteção contraDELETE ... WHERE 1=1
- ✅ Sanitização de nomes de tabelas
- ✅ Validação de queries vazias
- ✅ Tratamento seguro de parâmetros

- 🔒 Conexões controladas
- 🔒 Logs de erro seguros
- 🔒 Isolamento de responsabilidades
- 🔒 Validação de entrada

// Executar query segura { "name": "execute_query", "arguments": { "query": "SELECT * FROM usuarios LIMIT 5", "database": "meu_banco" } } // Analisar tabela { "name": "describe_table", "arguments": { "table_name": "usuarios" } }

- ✅ Conexão estabelecida
- 🔄 Queries executadas
- ❌ Erros com detalhes
- 🔚 Shutdown gracioso

- Cache de resultados
- Métricas de performance
- Pool de conexões
- Suporte a transações
- Interface web de monitoramento
- Fork o projeto
- Crie uma branch (git checkout -b feature/nova-funcionalidade)
- Commit suas mudanças (git commit -m 'Adiciona nova funcionalidade')
- Push para a branch (git push origin feature/nova-funcionalidade)
- Abra um Pull Request

- ✨ Arquitetura otimizada com SOLID
- 🔒 Validação e segurança aprimoradas
- 🚀 Performance melhorada
- 📚 Documentação expandida

- 🎉 Versão inicial
- 🔧 Implementação básica MCP
- 🗄️ Suporte MySQL completo

MIT License - veja o arquivoLICENSEpara detalhes.

Criado com ❤️ para demonstrar o protocolo MCP da Anthropic

Multi-database agent access (PostgreSQL, SQLite, MySQL, Oracle, SQL Server) with batch queries, pre-configured connections, and SQLGlot-enforced read-only safety

A read-only MCP server for MySQL, enabling LLMs to query live data using the CData JDBC Driver.

Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite

A single-binary MCP server for MySQL, MariaDB, PostgreSQL, and SQLite

A Model Context Protocol (MCP) server that provides multi-database query execution capabilities with support for SQLite, PostgreSQL, and MySQL databases. Includes a built-in Web UI for managing database connections.

Allows Claude AI to interact directly with MySQL databases.

Update various databases (PostgreSQL, MySQL, MongoDB, SQLite) using data from CSV and Excel files.

Enables AI assistants to interact with various databases through JDBC connections.

An MCP server for retrieving data from a MariaDB database.

Access and manage MariaDB or MySQL databases using an MCP server.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.