
MCP Alchemy
Connect Claude directly to PostgreSQL, MySQL, SQLite, Oracle, MS SQL and other SQLAlchemy databases.
Add to your client
Copy the config for your MCP client and paste it into its config file.
uvx --from mcp-alchemy==2025.8.15.91819 --refresh-package mcp-alchemy mcp-alchemyPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-alchemy": {
"command": "uvx",
"args": [
"--from",
"mcp-alchemy==2025.8.15.91819",
"--with",
"psycopg2-binary",
"--refresh-package",
"mcp-alchemy",
"mcp-alchemy"
],
"env": {
"DB_URL": "postgresql://user:password@localhost/dbname"
}
}
}
}Requires `uv` (the Python package runner). Install it from https://docs.astral.sh/uv/ if `uvx` is not found.
Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- uv installed (curl -LsSf https://astral.sh/uv/install.sh | sh)
- A SQLAlchemy-compatible database and its driver (e.g. psycopg2-binary, pymysql, pymssql, oracledb)
- A DB_URL connection string for the target database
About MCP Alchemy
MCP Alchemy gives Claude access to and knowledge about relational databases through SQLAlchemy. It exposes tools to list and search tables, retrieve detailed schema definitions including primary keys and foreign key relationships, and execute SQL queries with parameter support. Output is rendered in a readable vertical format with smart truncation, and large result sets can be exported via the optional claude-local-files integration.
Tools & capabilities (4)
all_table_namesReturn all table names in the database as a comma-separated list. No input required.
filter_table_namesFind tables matching a substring. Input: q (string). Returns matching table names.
schema_definitionsGet detailed schema for specified tables. Input: table_names (string[]). Returns column names and types, primary keys, foreign key relationships, and nullable flags.
execute_queryExecute a SQL query with vertical output format. Inputs: query (string) and optional params (object). Features smart truncation of large results, clean NULL display, ISO formatted dates, and full result set access via claude-local-files.
What this server can do
MCP Alchemy provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Explore and understand an unfamiliar database structure
- Write and validate SQL queries with Claude's help
- Discover relationships between tables via foreign keys
- Analyze large datasets and generate reports and visualizations
Security notes
Connects to your databases using credentials embedded in the DB_URL connection string. Use a least-privilege database account, since the LLM can execute arbitrary SQL via the execute_query tool.
MCP Alchemy FAQ
Which databases are supported?
PostgreSQL, MySQL, MariaDB, SQLite, Oracle, MS SQL Server, CrateDB, Vertica, and any other SQLAlchemy-compatible database. You add the appropriate driver in the --with parameter and set a matching DB_URL.
How do I handle result sets larger than Claude's context window?
Set the CLAUDE_LOCAL_FILES_PATH environment variable and configure claude-local-files. The integration activates automatically, giving access to complete result sets for deeper analysis and export.
Can I tune the database connection pool?
Yes. MCP Alchemy uses connection pooling optimized for long-running MCP servers (pool_pre_ping=True, pool_size=1, max_overflow=2, pool_recycle=3600, AUTOCOMMIT). You can override these via the DB_ENGINE_OPTIONS environment variable, which accepts a JSON string of SQLAlchemy engine options.
I get a uv versioning error after a new release. What do I do?
After a new version release there can be a period of up to 600 seconds while the local cache clears, causing uv to raise a versioning error. Restarting the MCP client again resolves it.
Alternatives to MCP Alchemy
Compare all alternatives →Google's official MCP server with prebuilt BigQuery tools, querying datasets via Application Default Credentials.
Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents.
Official Supabase server: manage tables, run SQL, branches, configs and edge functions from your AI client.
Compare MCP Alchemy with: