Back to Home
lukleh icon

mcp-read-only-sql

Verified Safe

by lukleh

Overview

Provides a secure, read-only SQL query interface to PostgreSQL and ClickHouse databases via the Model Context Protocol (MCP).

Installation

Run Command
uv run python -m src.server

Environment Variables

  • DB_PASSWORD_{CONNECTION_NAME_UPPER_WITH_UNDERSCORES}
  • SSH_PASSWORD_{CONNECTION_NAME_UPPER_WITH_UNDERSCORES}

Security Notes

The server implements a robust three-layer security model including database-level read-only enforcement, query timeouts, and result size limits. SQL injection is mitigated by input sanitization (`sql_guard.py`) and explicit multi-statement rejection. Subprocess execution (`psql`, `clickhouse-client`, `sshpass`) avoids `shell=True` for arguments, preventing shell injection. Sensitive data (passwords) are primarily sourced from environment variables, not stored in configuration files. The DBeaver importer contains hardcoded keys for decrypting DBeaver's default encrypted credentials, which is a minor detail for its specific (import) use case and not a general server vulnerability. Overall, the codebase demonstrates a strong focus on security best practices for database access.

Similar Servers

Stats

Interest Score0
Security Score9
Cost ClassMedium
Avg Tokens500
Stars0
Forks0
Last Update2025-11-21

Tags

SQLPostgreSQLClickHouseRead-OnlyDatabase Proxy