VS Code MCP Database Extension
A powerful VS Code extension that integrates with GitHub Copilot to provide database querying capabilities through the Model Context Protocol (MCP).
Features
- 🤖 AI-Powered Database Assistant: Chat with your database using natural language through GitHub Copilot
- 🔍 Intelligent SQL Generation: Convert natural language questions into SQL queries
- 📊 Schema Exploration: Browse and understand your database structure
- ⚡ Query Execution: Run SQL queries and see formatted results
- 🔗 Multi-Database Support: Works with PostgreSQL, MySQL, SQLite, and SQL Server
- 🛡️ Secure: Connection strings are stored securely in workspace settings
Installation
- Install the extension from the VS Code marketplace
- Configure your database connection using the command palette
- Start chatting with your database using
@dba
Quick Start
Open the Command Palette (Ctrl+Shift+P
) and run:
Database MCP: Configure Database Connection
Choose your database provider and enter your connection string:
- PostgreSQL:
postgresql://username:password@localhost:5432/database_name
- MySQL:
mysql://username:password@localhost:3306/database_name
- SQLite:
path/to/database.db
- SQL Server:
mssql://username:password@localhost:1433/database_name
2. Test Your Connection
Run the command:
Database MCP: Test Database Connection
3. Start Using the Database Assistant
Open GitHub Copilot Chat and use @dba
:
@dba show me the database structure
@dba find all users created last week
@dba count how many orders we have
@dba sample data from products table
Usage Examples
Natural Language Queries
@dba show me all customers from New York
@dba find the top 10 products by sales
@dba count users by registration month
@dba get recent orders from last 7 days
SQL Execution
Execute SQL directly by wrapping it in code blocks:
SELECT name, email FROM users
WHERE created_at > '2024-01-01'
LIMIT 10;
Schema Exploration
@dba show database schema
@dba describe the users table
@dba find tables with 'order' in the name
Commands
Command |
Description |
Database MCP: Configure Database Connection |
Set up your database connection |
Database MCP: Test Database Connection |
Verify your database connection |
Database MCP: Show Database Schema |
Display complete schema in a new document |
Configuration
The extension stores configuration in your workspace settings:
{
"dbMcp.provider": "postgresql",
"dbMcp.connectionString": "postgresql://user:pass@localhost:5432/mydb",
"dbMcp.enabled": true
}
Security
- Connection strings are stored in workspace settings (not globally)
- Passwords are masked during input
- No credentials are logged or transmitted outside your local environment
Requirements
- VS Code 1.74.0 or higher
- GitHub Copilot extension
- Access to a supported database
Supported Databases
- PostgreSQL (requires
pg
package)
- MySQL (requires
mysql2
package)
- SQLite (requires
sqlite3
package)
- SQL Server (requires
mssql
package)
Troubleshooting
Connection Issues
- Connection Refused: Ensure your database server is running
- Authentication Failed: Check username/password in connection string
- Database Not Found: Verify database name is correct
- Permission Denied: Ensure user has appropriate database permissions
Common Solutions
- Test connection using the built-in test command
- Check your connection string format
- Verify database server is accessible from your machine
- Ensure required database drivers are installed
Development
To build and run locally:
# Clone the repository
git clone <repo-url>
cd vscode-mcp-database-extension
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Open in VS Code for debugging
code .
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details
Changelog
0.0.1
- Initial release
- Basic database connectivity
- GitHub Copilot integration
- Schema exploration
- SQL query execution
- Multi-database support