MCP Alchemy connects Claude Desktop directly to your databases, turning Claude into your database expert. It helps you explore database structures, write SQL queries, display relationships between tables, and analyze large datasets. The tool works with PostgreSQL, MySQL, MariaDB, SQLite, Oracle, MS SQL Server, and other SQLAlchemy-compatible databases.
First, ensure you have uv installed:
curl -LsSf https://astral.sh/uv/install.sh | sh
Add MCP Alchemy to your claude_desktop_config.json
file. You'll need to specify the appropriate database driver in the --with
parameter.
{
"mcpServers": {
"my_sqlite_db": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "sqlite:////absolute/path/to/database.db"
}
}
}
}
{
"mcpServers": {
"my_postgres_db": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831", "--with", "psycopg2-binary",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "postgresql://user:password@localhost/dbname"
}
}
}
}
{
"mcpServers": {
"my_mysql_db": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831", "--with", "pymysql",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "mysql+pymysql://user:password@localhost/dbname"
}
}
}
}
{
"mcpServers": {
"my_mssql_db": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831", "--with", "pymssql",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "mssql+pymssql://user:password@localhost/dbname"
}
}
}
}
{
"mcpServers": {
"my_oracle_db": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831", "--with", "oracledb",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "oracle+oracledb://user:password@localhost/dbname"
}
}
}
}
{
"mcpServers": {
"my_cratedb": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831", "--with", "sqlalchemy-cratedb>=0.42.0.dev1",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "crate://user:password@localhost:4200/?schema=testdrive"
}
}
}
}
For CrateDB Cloud, use a URL like crate://user:[email protected]:4200?ssl=true
.
{
"mcpServers": {
"my_vertica_db": {
"command": "uvx",
"args": ["--from", "mcp-alchemy==2025.6.19.201831", "--with", "vertica-python",
"--refresh-package", "mcp-alchemy", "mcp-alchemy"],
"env": {
"DB_URL": "vertica+vertica_python://user:password@localhost:5433/dbname",
"DB_ENGINE_OPTIONS": "{\"connect_args\": {\"ssl\": false}}"
}
}
}
}
You can customize MCP Alchemy using these environment variables:
DB_URL
: SQLAlchemy database URL (required)CLAUDE_LOCAL_FILES_PATH
: Directory for full result sets (optional)EXECUTE_QUERY_MAX_CHARS
: Maximum output length (optional, default 4000)DB_ENGINE_OPTIONS
: JSON string containing additional SQLAlchemy engine options (optional)Example of DB_ENGINE_OPTIONS
:
{
"connect_args": {"ssl": false},
"isolation_level": null,
"pool_size": 5
}
Note: When DB_ENGINE_OPTIONS
is not set, the default behavior includes isolation_level='AUTOCOMMIT'
for backward compatibility.
Returns all table names in the database as a comma-separated list:
users, orders, products, categories
Finds tables matching a substring:
Input: "user"
Returns: "users, user_roles, user_permissions"
Gets detailed schema for specified tables:
users:
id: INTEGER, primary key, autoincrement
email: VARCHAR(255), nullable
created_at: DATETIME
Relationships:
id -> orders.user_id
Executes SQL queries with vertical output format:
1. row
id: 123
name: John Doe
created_at: 2024-03-15T14:30:00
email: NULL
Result: 1 rows
Features:
When the CLAUDE_LOCAL_FILES_PATH
environment variable is set, MCP Alchemy integrates with claude-local-files to:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-alchemy" '{"command":"uvx","args":["--from","mcp-alchemy==2025.6.19.201831","--refresh-package","mcp-alchemy","mcp-alchemy"],"env":{"DB_URL":"sqlite:////absolute/path/to/database.db"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-alchemy": {
"command": "uvx",
"args": [
"--from",
"mcp-alchemy==2025.6.19.201831",
"--refresh-package",
"mcp-alchemy",
"mcp-alchemy"
],
"env": {
"DB_URL": "sqlite:////absolute/path/to/database.db"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-alchemy": {
"command": "uvx",
"args": [
"--from",
"mcp-alchemy==2025.6.19.201831",
"--refresh-package",
"mcp-alchemy",
"mcp-alchemy"
],
"env": {
"DB_URL": "sqlite:////absolute/path/to/database.db"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect