WebsitePlatform Login
Tools

Database Queries

SQL database queries and schema information with support for multiple database types

The Database MCP server enables secure SQL queries on various database types with read-only access.

Main Features

Database Queries

  • query_database: Executes read-only SQL queries
    • Supports SELECT, WITH, SHOW, DESCRIBE, EXPLAIN
    • Automatically blocks modifying commands (INSERT, UPDATE, DELETE, etc.)
    • Asynchronous execution for optimal performance

Schema Information

  • get_database_schema: Retrieves database schema information
    • Lists all tables and views
    • Shows columns with data types
    • Helpful for exploring unknown databases

Configuration

The database URL is provided via the X-Database-URL header. The server supports connection pooling for better performance with multiple requests.

Supported Databases

The database tool supports the following database types:

# PostgreSQL
postgresql://user:password@localhost:5432/mydatabase

# MySQL
mysql://user:password@localhost:3306/mydatabase

# MariaDB (uses MySQL driver)
mysql://user:password@localhost:3306/mydatabase

# Microsoft SQL Server
mssql://user:password@localhost:1433/mydatabase

Security Recommendations

For production use, we strongly recommend:

  1. Create read-only database users:

    • PostgreSQL:
      CREATE USER readonly WITH PASSWORD 'password';
      GRANT CONNECT ON DATABASE databasename TO readonly;
      GRANT USAGE ON SCHEMA public TO readonly;
      GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
    • MySQL/MariaDB:
      CREATE USER 'readonly'@'%' IDENTIFIED BY 'password';
      GRANT SELECT ON databasename.* TO 'readonly'@'%';
    • SQL Server:
      CREATE LOGIN readonly WITH PASSWORD='password';
      USE databasename;
      CREATE USER readonly FOR LOGIN readonly;
      EXEC sp_addrolemember 'db_datareader', 'readonly';
  2. Restrict network access to database servers using firewalls or VPNs to the following IP: 148.251.245.94

    • This is the IP address of the MCP server that accesses the database.
  3. Use connection pooling for improved performance with multiple users

  4. Set appropriate timeouts to prevent long-running queries