Cover image
Try Now
2025-04-08

Un servidor MCP que proporciona acceso a las bases de datos Mariadb OU MySQL.

3 years

Works with Finder

1

Github Watches

0

Github Forks

4

Github Stars

MariaDB / MySQL Database Access MCP Server

This MCP server provides access to MariaDB / MySQL databases.

It allows you to:

  • List available databases
  • List tables in a database
  • Describe table schemas
  • Execute SQL queries

Security Features

  • Read-only access Default: SELECT, SHOW, DESCRIBE, and EXPLAIN
  • Query validation: Prevents SQL injection and blocks any data modification attempts
  • Query timeout: Prevents long-running queries from consuming resources
  • Row limit: Prevents excessive data return

Installation

Option 1: Install from NPM (Recommended)

# Install globally
npm install -g mariadb-mcp-server

# Or install locally in your project
npm install mariadb-mcp-server

Option 2: Build from Source

# Clone the repository
git clone https://github.com/rjsalgado/mariadb-mcp-server.git
cd mariadb-mcp-server

# Install dependencies and build
npm install
npm run build

2. Configure environment variables

The server requires the following environment variables:

  • MARIADB_HOST: Database server hostname
  • MARIADB_PORT: Database server port (default: 3306)
  • MARIADB_USER: Database username
  • MARIADB_PASSWORD: Database password
  • MARIADB_DATABASE: Default database name (optional)
  • MARIADB_ALLOW_INSERT: false
  • MARIADB_ALLOW_UPDATE: false
  • MARIADB_ALLOW_DELETE: false
  • MARIADB_TIMEOUT_MS: 10000
  • MARIADB_ROW_LIMIT: 1000

3. Add to MCP settings

Add the following configuration to your MCP settings file:

If you installed via npm (Option 1):

{
  "mcpServers": {
    "mariadb": {
      "command": "npx",
      "args": ["mariadb-mcp-server"],
      "env": {
        "MARIADB_HOST": "your-host",
        "MARIADB_PORT": "3306",
        "MARIADB_USER": "your-user",
        "MARIADB_PASSWORD": "your-password",
        "MARIADB_DATABASE": "your-database",
        "MARIADB_ALLOW_INSERT": "false",
        "MARIADB_ALLOW_UPDATE": "false",
        "MARIADB_ALLOW_DELETE": "false",
        "MARIADB_TIMEOUT_MS": "10000",
        "MARIADB_ROW_LIMIT": "1000",
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

If you built from source (Option 2):

{
  "mcpServers": {
    "mariadb": {
      "command": "node",
      "args": ["/path/to/mariadb-mcp-server/dist/index.js"],
      "env": {
        "MARIADB_HOST": "your-host",
        "MARIADB_PORT": "3306",
        "MARIADB_USER": "your-user",
        "MARIADB_PASSWORD": "your-password",
        "MARIADB_DATABASE": "your-default-database",
        "MARIADB_ALLOW_INSERT": "false",
        "MARIADB_ALLOW_UPDATE": "false",
        "MARIADB_ALLOW_DELETE": "false",
        "MARIADB_TIMEOUT_MS": "10000",
        "MARIADB_ROW_LIMIT": "1000",
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Available Tools

"server_name": "mariadb" or "server_name": "mysql"

list_databases

Lists all accessible databases on the MariaDB / MySQL server. Parameters: None

Example:

{
  "server_name": "mariadb",
  "tool_name": "list_databases",
  "arguments": {}
}

list_tables

Lists all tables in a specified database.

Parameters:

  • database (optional): Database name (uses default if not specified)

Example:

{
  "server_name": "mariadb",
  "tool_name": "list_tables",
  "arguments": {
    "database": "my_database"
  }
}

describe_table

Shows the schema for a specific table.

Parameters:

  • database (optional): Database name (uses default if not specified)
  • table (required): Table name

Example:

{
  "server_name": "mariadb",
  "tool_name": "describe_table",
  "arguments": {
    "database": "my_database",
    "table": "my_table"
  }
}

execute_query

Executes a SQL query.

Parameters:

  • query (required): SQL query
  • database (optional): Database name (uses default if not specified)

Example:

{
  "server_name": "mariadb",
  "tool_name": "execute_query",
  "arguments": {
    "database": "my_database",
    "query": "SELECT * FROM my_table LIMIT 10"
  }
}

Testing

The server includes test scripts to verify functionality with your MariaDB / MySQL setup:

1. Setup Test Database

This script creates a test database, table, and sample data:

# Set your MariaDB / MySQL credentials as environment variables
export MARIADB_HOST=localhost
export MARIADB_PORT=3306
export MARIADB_USER=your_username
export MARIADB_PASSWORD=your_password
export MARIADB_ALLOW_INSERT: false
export MARIADB_ALLOW_UPDATE: false
export MARIADB_ALLOW_DELETE: false
export MARIADB_TIMEOUT_MS=10000
export MARIADB_ROW_LIMIT=1000


# Run the setup script
npm run test:setup

2. Test MCP Tools

This script tests each of the MCP tools against the test database:

####
# Set your MariaDB / MySQL credentials as environment variables
MARIADB_HOST=localhost
MARIADB_PORT=3306
MARIADB_USER=your_username
MARIADB_PASSWORD=your_password
MARIADB_DATABASE=mcp_test_db
MARIADB_ALLOW_INSERT=false
MARIADB_ALLOW_UPDATE=false
MARIADB_ALLOW_DELETE=false
MARIADB_TIMEOUT_MS=10000
MARIADB_ROW_LIMIT=1000
MARIADB_DEBUG_SQL=true
####
export MARIADB_HOST=localhost
export MARIADB_PORT=3306
export MARIADB_USER=your_username
export MARIADB_PASSWORD=your_password
export MARIADB_DATABASE=mcp_test_db
export MARIADB_ALLOW_INSERT: false
export MARIADB_ALLOW_UPDATE: false
export MARIADB_ALLOW_DELETE: false
export MARIADB_TIMEOUT_MS=10000
export MARIADB_ROW_LIMIT=1000


# Run the tools test script
npm run test:tools

3. Run All Tests

To run both setup and tool tests:

# Set your MariaDB / MySQL credentials as environment variables
export MARIADB_HOST=localhost
export MARIADB_PORT=3306
export MARIADB_USER=your_username
export MARIADB_PASSWORD=your_password
export MARIADB_ALLOW_INSERT: false
export MARIADB_ALLOW_UPDATE: false
export MARIADB_ALLOW_DELETE: false
export MARIADB_TIMEOUT_MS=10000
export MARIADB_ROW_LIMIT=1000

# Run all tests
npm test

Troubleshooting

If you encounter issues:

  1. Check the server logs for error messages
  2. Verify your MariaDB/MySQL credentials and connection details
  3. Ensure your MariaDB/MySQL user has appropriate permissions
  4. Check that your query is read-only and properly formatted

Inspiration https://github.com/dpflucas/mysql-mcp-server

License

This project is licensed under the MIT License - see the LICENSE file for details.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • J. DE HARO OLLE
  • Especialista en juegos de palabras en varios idiomas.

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • albert tan
  • Japanese education, creating tailored learning experiences.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • HiveNexus
  • Un bot de chat de IA para equipos pequeños y medianos, que apoyan modelos como Deepseek, Open AI, Claude y Gemini. 专为中小团队设计的 ai 聊天应用 , 支持 Deepseek 、 Open ai 、 Claude 、 Géminis 等模型。

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

  • JackKuo666
  • 🔍 Habilitar asistentes de IA para buscar y acceder a la información del paquete PYPI a través de una interfaz MCP simple.

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

    Reviews

    1 (1)
    Avatar
    user_QdrYUANs
    2025-04-16

    The Bankless Onchain MCP Server is incredibly efficient and user-friendly. It offers seamless integration for managing onchain data, making it an essential tool for anyone dealing with blockchain technology. The setup process is straightforward, and the server's performance is impressive. Highly recommended for tech enthusiasts and professionals alike!