mcp-dbs
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
Provides a way for users to support the project through Buy Me A Coffee donations, with a QR code and direct link included in the README.
Enables connection to PostgreSQL databases, with support for querying, schema exploration, and data operations through environment variable configuration.
Provides tools for connecting to SQLite databases, executing queries, and managing database schema with options for automatic database creation.
MCP Database Server
A Model Context Protocol (MCP) implementation for connecting to and working with various database systems.
Supported Databases
- SQLite
- PostgreSQL
- Microsoft SQL Server
- MongoDB
Installation
Usage
The MCP Database Server can be used in two modes:
SSE Mode (Default)
By default, the server runs in SSE (Server-Sent Events) mode on port 3001:
This will start an HTTP server with an SSE endpoint at http://localhost:3001/mcp
.
Custom Port
You can specify a custom port using the --port
option:
STDIO Mode
For tools that communicate over standard input/output, you can use the --stdio
option:
Claude Desktop Integration
You can integrate mcp-dbs with Claude Desktop by adding it to your Claude configuration file.
Configuration Steps
- Open or create your Claude Desktop configuration file
- Add the mcp-dbs configuration to the
mcpServers
section:
Replace the environment variables with your own database connection details.
Notes
- The
command
should benode
- In
args
, provide the absolute path to the cli.js file in your mcp-dbs installation - Configure the appropriate environment variables for your database type (see the environment variables section below)
- You can use environment variables for any of the supported databases (SQLite, PostgreSQL, SQL Server, or MongoDB)
Using with Claude
Once configured, Claude will be able to access your database using the MCP tools described below. You can ask Claude to:
- Connect to your database
- Execute queries and get results
- Explore your database schema
- Work with tables and data
Tools
- connect-database: Connect to a database
- disconnect-database: Disconnect from a database
- execute-query: Execute a query and return results
- execute-update: Execute a query without returning results
Resources
- database-schema: Get the full database schema
- table-schema: Get the schema for a specific table
- tables-list: Get a list of all tables
Using environment variables for configuration
You can configure your database connections using environment variables:
SQLite
PostgreSQL
SQL Server
MongoDB
These environment variables will take precedence over any configuration passed to the connect-database tool.
MCP Tools
The server exposes the following MCP tools:
connect-database
Connect to a database.
Parameters:
connectionId
: A unique identifier for the connectiontype
: Database type (sqlite
,postgres
,mssql
, ormongodb
)
Example for SQLite:
Example for PostgreSQL:
Example for SQL Server:
Example for MongoDB:
disconnect-database
Disconnect from a database.
Parameters:
connectionId
: The connection ID to disconnect
execute-query
Execute a query that returns results.
Parameters:
connectionId
: The connection IDquery
: SQL query or MongoDB aggregation pipeline (as JSON string)params
: (Optional) Array of parameters for the query. For MongoDB, the first parameter is the collection name.
Example for SQL:
Example for MongoDB:
Example for MongoDB (new format with embedded collection):
Example for MongoDB (shell syntax):
Example for MongoDB (direct collection reference shell syntax):
Example for MongoDB (raw command):
execute-update
Execute a query that doesn't return results (INSERT, UPDATE, DELETE).
Parameters:
connectionId
: The connection IDquery
: SQL query or MongoDB command (as JSON string)params
: (Optional) Array of parameters for the query. For MongoDB, the first parameter is the collection name.
Example for SQL:
Example for MongoDB:
Example for MongoDB (new format with embedded collection):
Example for MongoDB (shell syntax):
Example for MongoDB (direct collection reference shell syntax):
Example for MongoDB (raw command):
MCP Resources
The server exposes the following MCP resources:
Database Schema
URI: database://{connectionId}/schema
Returns schema information about the database, including all tables and their columns.
Table Schema
URI: database://{connectionId}/tables/{tableName}
Returns schema information about a specific table, including its columns.
Tables List
URI: database://{connectionId}/tables
Returns a list of all tables in the database.
Development
Testing
Run the tests:
Support the Project
If you find this project helpful, consider buying me a coffee!
Scan the QR code above or click here to support the development of this project.
License
MIT
This server cannot be installed
A Model Context Protocol (MCP) implementation for connecting to and working with various database systems.
- Supported Databases
- Installation
- Usage
- Claude Desktop Integration
- Tools
- Resources
- Using environment variables for configuration
- MCP Tools
- MCP Resources
- Development
- Support the Project
- License