Multi-database MCP server via SQLAlchemy
## MCP Alchemy MCP Server: SQLAlchemy Database Abstraction The **MCP Alchemy MCP Server** provides SQLAlchemy ORM integration for Google Antigravity, enabling database-agnostic operations with models, migrations, and advanced querying directly from your development environment. ### Why MCP Alchemy? - **Database Agnostic**: Work with PostgreSQL, MySQL, SQLite, and more - **ORM Features**: Object-relational mapping for Python - **Migrations**: Database schema version control - **Connection Pooling**: Efficient database connections - **Type Safety**: Full type hints support ### Key Features #### 1. Model Queries ```python # Query with ORM-style syntax users = await mcp.query( model="User", filter={"status": "active"}, order_by="-created_at", limit=20, include=["orders", "profile"] ) for user in users: print(f"User: {user['name']} - {len(user['orders'])} orders") # Raw SQL with ORM mapping result = await mcp.query_raw(""" SELECT * FROM users WHERE email LIKE :pattern """, params={"pattern": "%@example.com"}, model="User") ``` #### 2. CRUD Operations ```python # Create record user = await mcp.create( model="User", data={ "name": "John Doe", "email": "john@example.com", "status": "active" } ) # Update record await mcp.update( model="User", id=user["id"], data={"status": "premium"} ) # Delete record await mcp.delete(model="User", id=user["id"]) ``` #### 3. Relationship Handling ```python # Query with relationships orders = await mcp.query( model="Order", filter={"user_id": 123}, include=["items", "items.product", "shipping_address"] ) # Create with relationships order = await mcp.create( model="Order", data={ "user_id": 123, "items": [ {"product_id": 1, "quantity": 2}, {"product_id": 2, "quantity": 1} ] } ) ``` #### 4. Schema Operations ```python # List models models = await mcp.list_models() for model in models: print(f"Model: {model['name']}") # Get model schema schema = await mcp.get_model_schema(model="User") for field in schema["fields"]: print(f"Field: {field['name']} ({field['type']})") # Run migrations await mcp.migrate(direction="up") ``` ### Configuration ```json { "mcpServers": { "alchemy": { "command": "python", "args": ["-m", "mcp_alchemy"], "env": { "DATABASE_URL": "postgresql://user:pass@localhost/mydb", "MODELS_PATH": "./app/models", "POOL_SIZE": "5" } } } } ``` ### Use Cases **Application Development**: ORM-based database access for apps. **Multi-Database**: Support multiple database backends. **Schema Management**: Version control for database schemas. **Complex Queries**: Build complex queries programmatically. The MCP Alchemy enables SQLAlchemy operations within your development environment.
{
"mcpServers": {
"alchemy": {
"mcpServers": {
"mcp-alchemy": {
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost/dbname"
},
"args": [
"mcp-alchemy"
],
"command": "uvx"
}
}
}
}
}