# MCP Database Server
๐ **Universal Database Connector for AI Assistants**
Connect to ANY database (SQL Server, PostgreSQL, MySQL, MongoDB, Redis, SQLite) through your AI assistant with just a simple configuration!
A universal MCP (Model Context Protocol) server that provides seamless connections to multiple database types. This server enables AI assistants like Claude to interact with your databases through a unified interface.
## ๐ฆ Quick Install
```bash
# Install with uv (recommended)
uv add mcp-universal-database-server
# Or install with pip
pip install mcp-universal-database-server
```
## ๐ง Simple Setup
Add this to your `~/.cursor/mcp.json` or `.vscode/settings.json`:
```json
{
"mcpServers": {
"mcp-database-server": {
"command": "mcp-universal-database-server",
"args": ["serve"]
}
}
}
```
**That's it!** Your AI assistant can now connect to any database. Just ask: *"Connect to my SQL Server database"*
## ๐ Features
- **Universal Database Support**: Connect to PostgreSQL, MySQL, SQLite, MongoDB, Redis, and more
- **MCP Integration**: Seamless integration with VSCode, Cursor, and other MCP-compatible tools
- **Secure Connections**: Support for SSL/TLS and connection pooling
- **Rich Operations**: Full CRUD operations, schema management, and query execution
- **Type Safety**: Built with Python type hints and Pydantic models
- **Easy Installation**: Install via `uv` package manager
## ๐ฆ Supported Databases
### SQL Databases
- **PostgreSQL** - Advanced open-source relational database
- **MySQL** - Popular open-source relational database
- **SQLite** - Lightweight file-based SQL database
- **Microsoft SQL Server** *(planned)*
- **Oracle Database** *(planned)*
### NoSQL Databases
- **MongoDB** - Document-oriented database
- **Redis** - In-memory key-value store
- **Apache Cassandra** *(planned)*
### Cloud Databases
- **Google Firestore** *(planned)*
- **Amazon DynamoDB** *(planned)*
- **Azure Cosmos DB** *(planned)*
## ๐ ๏ธ Installation
### Using uv (Recommended)
```bash
# Install from PyPI (once published)
uv add mcp-database-server
# Or install from source
uv add git+https://github.com/yourusername/mcp-database-server.git
```
### Using pip
```bash
pip install mcp-database-server
```
## ๐ง Configuration
### 1. Generate Configuration
```bash
mcp-database-server generate-config --output mcp_config.json
```
### 2. Configure VSCode/Cursor
Add to your MCP settings file (`.vscode/settings.json` or Cursor equivalent):
```json
{
"mcp.servers": {
"mcp-database-server": {
"command": "mcp-database-server",
"args": ["serve"]
}
}
}
```
### 3. Add Database Connections
Use the MCP tools in your AI assistant to add connections:
```
Add a PostgreSQL connection:
- Name: my_postgres
- Type: postgresql
- Host: localhost
- Port: 5432
- Username: myuser
- Password: mypassword
- Database: mydatabase
```
## ๐ Usage
### Starting the Server
```bash
# Start MCP server (typically called by your editor)
mcp-database-server serve
# Test a connection
mcp-database-server test-connection \
--type postgresql \
--host localhost \
--port 5432 \
my_postgres
# List supported database types
mcp-database-server list-supported
```
### Available MCP Tools
Once configured, you can use these tools through your AI assistant:
#### Connection Management
- `add_connection` - Add a new database connection
- `remove_connection` - Remove a database connection
- `list_connections` - List all configured connections
- `test_connection` - Test a specific connection
#### Schema Operations
- `get_schema_info` - Get database schema information
- `get_table_info` - Get detailed table information
- `list_databases` - List available databases
- `list_tables` - List tables in a database/schema
#### Data Operations
- `execute_query` - Execute SQL queries or database commands
- `insert_data` - Insert data into tables/collections
- `update_data` - Update data in tables (SQL databases)
- `delete_data` - Delete data from tables/collections
#### Table Management (SQL)
- `create_table` - Create new tables
- `drop_table` - Drop tables
#### Collection Management (NoSQL)
- `create_collection` - Create new collections
- `find_documents` - Find documents in collections
- `update_documents` - Update documents in collections
## ๐ Examples
### Example 1: PostgreSQL Connection
```python
# Through MCP tools in your AI assistant:
# 1. Add connection
add_connection(
name="my_postgres",
type="postgresql",
host="localhost",
port=5432,
username="myuser",
password="mypassword",
database="mydb"
)
# 2. Execute query
execute_query(
connection_name="my_postgres",
query="SELECT * FROM users WHERE active = $1",
parameters={"active": true}
)
```
### Example 2: MongoDB Connection
```python
# 1. Add MongoDB connection
add_connection(
name="my_mongo",
type="mongodb",
host="localhost",
port=27017,
username="myuser",
password="mypassword",
database="mydb"
)
# 2. Find documents
find_documents(
connection_name="my_mongo",
collection_name="users",
filter_query={"status": "active"},
limit=10
)
```
### Example 3: SQLite Connection
```python
# 1. Add SQLite connection
add_connection(
name="my_sqlite",
type="sqlite",
database="/path/to/database.db"
)
# 2. Get schema info
get_schema_info(connection_name="my_sqlite")
```
## ๐ Security
- **Connection Security**: All connections support SSL/TLS encryption
- **Credential Management**: Passwords are handled securely and not logged
- **Connection Pooling**: Efficient connection management with automatic cleanup
- **Input Validation**: All inputs are validated using Pydantic models
## ๐งช Development
### Setup Development Environment
```bash
# Clone repository
git clone https://github.com/yourusername/mcp-database-server.git
cd mcp-database-server
# Install with uv
uv sync --dev
# Run tests
uv run pytest
# Format code
uv run black src/
uv run ruff check src/
```
### Project Structure
```
mcp-database-server/
โโโ src/mcp_database_server/
โ โโโ __init__.py
โ โโโ server.py # Main MCP server
โ โโโ connection_manager.py # Connection management
โ โโโ database_factory.py # Database factory
โ โโโ types.py # Type definitions
โ โโโ cli.py # CLI interface
โ โโโ databases/ # Database drivers
โ โโโ base.py # Base classes
โ โโโ postgresql.py # PostgreSQL driver
โ โโโ mysql.py # MySQL driver
โ โโโ sqlite.py # SQLite driver
โ โโโ mongodb.py # MongoDB driver
โ โโโ redis.py # Redis driver
โโโ tests/ # Test files
โโโ pyproject.toml # Project configuration
โโโ README.md
```
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
### Adding New Database Support
1. Create a new driver in `src/mcp_database_server/databases/`
2. Inherit from `SQLDatabase` or `NoSQLDatabase` base class
3. Implement all required methods
4. Register the driver in `database_factory.py`
5. Add appropriate dependencies to `pyproject.toml`
6. Write tests for the new driver
## ๐ Support
- **Issues**: [GitHub Issues](https://github.com/yourusername/mcp-database-server/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/mcp-database-server/discussions)
- **Documentation**: [GitHub Wiki](https://github.com/yourusername/mcp-database-server/wiki)
## ๐ Acknowledgments
- [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) for the protocol specification
- All the amazing database driver maintainers
- The Python async ecosystem
---
Made with โค๏ธ for the AI and database communities
Raw data
{
"_id": null,
"home_page": null,
"name": "mcp-universal-database-server",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "database, mcp, mongodb, mysql, nosql, postgresql, server, sql, sqlite",
"author": null,
"author_email": "Adarsh Bhayani <adarsh.bhayani@simformsolutions.com>",
"download_url": "https://files.pythonhosted.org/packages/af/f4/bec8835271621a5a44aa2345e6a4c9e92fc208650d35335eca0dd69bad99/mcp_universal_database_server-0.1.2.tar.gz",
"platform": null,
"description": "# MCP Database Server\n\n\ud83d\ude80 **Universal Database Connector for AI Assistants**\n\nConnect to ANY database (SQL Server, PostgreSQL, MySQL, MongoDB, Redis, SQLite) through your AI assistant with just a simple configuration!\n\nA universal MCP (Model Context Protocol) server that provides seamless connections to multiple database types. This server enables AI assistants like Claude to interact with your databases through a unified interface.\n\n## \ud83d\udce6 Quick Install\n\n```bash\n# Install with uv (recommended)\nuv add mcp-universal-database-server\n\n# Or install with pip\npip install mcp-universal-database-server\n```\n\n## \ud83d\udd27 Simple Setup\n\nAdd this to your `~/.cursor/mcp.json` or `.vscode/settings.json`:\n\n```json\n{\n \"mcpServers\": {\n \"mcp-database-server\": {\n \"command\": \"mcp-universal-database-server\",\n \"args\": [\"serve\"]\n }\n }\n}\n```\n\n**That's it!** Your AI assistant can now connect to any database. Just ask: *\"Connect to my SQL Server database\"*\n\n## \ud83d\ude80 Features\n\n- **Universal Database Support**: Connect to PostgreSQL, MySQL, SQLite, MongoDB, Redis, and more\n- **MCP Integration**: Seamless integration with VSCode, Cursor, and other MCP-compatible tools\n- **Secure Connections**: Support for SSL/TLS and connection pooling\n- **Rich Operations**: Full CRUD operations, schema management, and query execution\n- **Type Safety**: Built with Python type hints and Pydantic models\n- **Easy Installation**: Install via `uv` package manager\n\n## \ud83d\udce6 Supported Databases\n\n### SQL Databases\n- **PostgreSQL** - Advanced open-source relational database\n- **MySQL** - Popular open-source relational database \n- **SQLite** - Lightweight file-based SQL database\n- **Microsoft SQL Server** *(planned)*\n- **Oracle Database** *(planned)*\n\n### NoSQL Databases\n- **MongoDB** - Document-oriented database\n- **Redis** - In-memory key-value store\n- **Apache Cassandra** *(planned)*\n\n### Cloud Databases\n- **Google Firestore** *(planned)*\n- **Amazon DynamoDB** *(planned)*\n- **Azure Cosmos DB** *(planned)*\n\n## \ud83d\udee0\ufe0f Installation\n\n### Using uv (Recommended)\n\n```bash\n# Install from PyPI (once published)\nuv add mcp-database-server\n\n# Or install from source\nuv add git+https://github.com/yourusername/mcp-database-server.git\n```\n\n### Using pip\n\n```bash\npip install mcp-database-server\n```\n\n## \ud83d\udd27 Configuration\n\n### 1. Generate Configuration\n\n```bash\nmcp-database-server generate-config --output mcp_config.json\n```\n\n### 2. Configure VSCode/Cursor\n\nAdd to your MCP settings file (`.vscode/settings.json` or Cursor equivalent):\n\n```json\n{\n \"mcp.servers\": {\n \"mcp-database-server\": {\n \"command\": \"mcp-database-server\",\n \"args\": [\"serve\"]\n }\n }\n}\n```\n\n### 3. Add Database Connections\n\nUse the MCP tools in your AI assistant to add connections:\n\n```\nAdd a PostgreSQL connection:\n- Name: my_postgres\n- Type: postgresql\n- Host: localhost\n- Port: 5432\n- Username: myuser\n- Password: mypassword\n- Database: mydatabase\n```\n\n## \ud83d\ude80 Usage\n\n### Starting the Server\n\n```bash\n# Start MCP server (typically called by your editor)\nmcp-database-server serve\n\n# Test a connection\nmcp-database-server test-connection \\\n --type postgresql \\\n --host localhost \\\n --port 5432 \\\n my_postgres\n\n# List supported database types\nmcp-database-server list-supported\n```\n\n### Available MCP Tools\n\nOnce configured, you can use these tools through your AI assistant:\n\n#### Connection Management\n- `add_connection` - Add a new database connection\n- `remove_connection` - Remove a database connection\n- `list_connections` - List all configured connections\n- `test_connection` - Test a specific connection\n\n#### Schema Operations\n- `get_schema_info` - Get database schema information\n- `get_table_info` - Get detailed table information\n- `list_databases` - List available databases\n- `list_tables` - List tables in a database/schema\n\n#### Data Operations\n- `execute_query` - Execute SQL queries or database commands\n- `insert_data` - Insert data into tables/collections\n- `update_data` - Update data in tables (SQL databases)\n- `delete_data` - Delete data from tables/collections\n\n#### Table Management (SQL)\n- `create_table` - Create new tables\n- `drop_table` - Drop tables\n\n#### Collection Management (NoSQL)\n- `create_collection` - Create new collections\n- `find_documents` - Find documents in collections\n- `update_documents` - Update documents in collections\n\n## \ud83d\udcdd Examples\n\n### Example 1: PostgreSQL Connection\n\n```python\n# Through MCP tools in your AI assistant:\n# 1. Add connection\nadd_connection(\n name=\"my_postgres\",\n type=\"postgresql\",\n host=\"localhost\",\n port=5432,\n username=\"myuser\",\n password=\"mypassword\",\n database=\"mydb\"\n)\n\n# 2. Execute query\nexecute_query(\n connection_name=\"my_postgres\",\n query=\"SELECT * FROM users WHERE active = $1\",\n parameters={\"active\": true}\n)\n```\n\n### Example 2: MongoDB Connection\n\n```python\n# 1. Add MongoDB connection\nadd_connection(\n name=\"my_mongo\",\n type=\"mongodb\",\n host=\"localhost\",\n port=27017,\n username=\"myuser\",\n password=\"mypassword\",\n database=\"mydb\"\n)\n\n# 2. Find documents\nfind_documents(\n connection_name=\"my_mongo\",\n collection_name=\"users\",\n filter_query={\"status\": \"active\"},\n limit=10\n)\n```\n\n### Example 3: SQLite Connection\n\n```python\n# 1. Add SQLite connection\nadd_connection(\n name=\"my_sqlite\",\n type=\"sqlite\",\n database=\"/path/to/database.db\"\n)\n\n# 2. Get schema info\nget_schema_info(connection_name=\"my_sqlite\")\n```\n\n## \ud83d\udd12 Security\n\n- **Connection Security**: All connections support SSL/TLS encryption\n- **Credential Management**: Passwords are handled securely and not logged\n- **Connection Pooling**: Efficient connection management with automatic cleanup\n- **Input Validation**: All inputs are validated using Pydantic models\n\n## \ud83e\uddea Development\n\n### Setup Development Environment\n\n```bash\n# Clone repository\ngit clone https://github.com/yourusername/mcp-database-server.git\ncd mcp-database-server\n\n# Install with uv\nuv sync --dev\n\n# Run tests\nuv run pytest\n\n# Format code\nuv run black src/\nuv run ruff check src/\n```\n\n### Project Structure\n\n```\nmcp-database-server/\n\u251c\u2500\u2500 src/mcp_database_server/\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 server.py # Main MCP server\n\u2502 \u251c\u2500\u2500 connection_manager.py # Connection management\n\u2502 \u251c\u2500\u2500 database_factory.py # Database factory\n\u2502 \u251c\u2500\u2500 types.py # Type definitions\n\u2502 \u251c\u2500\u2500 cli.py # CLI interface\n\u2502 \u2514\u2500\u2500 databases/ # Database drivers\n\u2502 \u251c\u2500\u2500 base.py # Base classes\n\u2502 \u251c\u2500\u2500 postgresql.py # PostgreSQL driver\n\u2502 \u251c\u2500\u2500 mysql.py # MySQL driver\n\u2502 \u251c\u2500\u2500 sqlite.py # SQLite driver\n\u2502 \u251c\u2500\u2500 mongodb.py # MongoDB driver\n\u2502 \u2514\u2500\u2500 redis.py # Redis driver\n\u251c\u2500\u2500 tests/ # Test files\n\u251c\u2500\u2500 pyproject.toml # Project configuration\n\u2514\u2500\u2500 README.md\n```\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n### Adding New Database Support\n\n1. Create a new driver in `src/mcp_database_server/databases/`\n2. Inherit from `SQLDatabase` or `NoSQLDatabase` base class\n3. Implement all required methods\n4. Register the driver in `database_factory.py`\n5. Add appropriate dependencies to `pyproject.toml`\n6. Write tests for the new driver\n\n## \ud83d\udcde Support\n\n- **Issues**: [GitHub Issues](https://github.com/yourusername/mcp-database-server/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/yourusername/mcp-database-server/discussions)\n- **Documentation**: [GitHub Wiki](https://github.com/yourusername/mcp-database-server/wiki)\n\n## \ud83d\ude4f Acknowledgments\n\n- [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) for the protocol specification\n- All the amazing database driver maintainers\n- The Python async ecosystem\n\n---\n\nMade with \u2764\ufe0f for the AI and database communities\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Universal MCP server for multiple database connections and operations",
"version": "0.1.2",
"project_urls": {
"Documentation": "https://github.com/adarshbhayani/mcp-database-server#readme",
"Homepage": "https://github.com/adarshbhayani/mcp-database-server",
"Issues": "https://github.com/adarshbhayani/mcp-database-server/issues",
"Repository": "https://github.com/adarshbhayani/mcp-database-server"
},
"split_keywords": [
"database",
" mcp",
" mongodb",
" mysql",
" nosql",
" postgresql",
" server",
" sql",
" sqlite"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "97d4d48cc00d7733339faad7ff1b90f831a4995420c82e1ecb1eed200cad6555",
"md5": "b67562a17aa6e3226021a2627b5f8fcc",
"sha256": "aff32ea11be7ed301c2b1c19d5f3d4b0a711f37a8c9b7041a8bf6a6b5710ca47"
},
"downloads": -1,
"filename": "mcp_universal_database_server-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b67562a17aa6e3226021a2627b5f8fcc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 39686,
"upload_time": "2025-08-22T13:38:33",
"upload_time_iso_8601": "2025-08-22T13:38:33.541583Z",
"url": "https://files.pythonhosted.org/packages/97/d4/d48cc00d7733339faad7ff1b90f831a4995420c82e1ecb1eed200cad6555/mcp_universal_database_server-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "aff4bec8835271621a5a44aa2345e6a4c9e92fc208650d35335eca0dd69bad99",
"md5": "84c2bddab409f1a63a30afc936e9f691",
"sha256": "faad5e8a4591d43795bfd872d1907d965dbd892b2388d205cfc08d3a75c5a27b"
},
"downloads": -1,
"filename": "mcp_universal_database_server-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "84c2bddab409f1a63a30afc936e9f691",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 29295,
"upload_time": "2025-08-22T13:38:34",
"upload_time_iso_8601": "2025-08-22T13:38:34.899409Z",
"url": "https://files.pythonhosted.org/packages/af/f4/bec8835271621a5a44aa2345e6a4c9e92fc208650d35335eca0dd69bad99/mcp_universal_database_server-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-22 13:38:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adarshbhayani",
"github_project": "mcp-database-server#readme",
"github_not_found": true,
"lcname": "mcp-universal-database-server"
}