Provides tools for querying and managing PostgreSQL databases, including executing SQL queries, inspecting schemas and tables, and accessing multi-schema data across customer, document, loan, and leasing management systems.
MCP Database Server
A Model Context Protocol (MCP) server that provides PostgreSQL database access with query execution and schema inspection capabilities.
Overview
This MCP server enables AI assistants (like Claude) to interact with a PostgreSQL database containing data from multiple systems:
cs (CustomerScoreView): Customer and credit assessment data
dms (Data Management System): Document management data
los (Loan Management System): Loan and payment data
mls (Mahatheun Leasing System): Contract and asset leasing data
Features
✅ Query Execution: Execute SQL SELECT, INSERT, UPDATE, DELETE queries
✅ Schema Inspection: List schemas, tables, and column details
✅ Multi-Schema Support: Organize data by system (cs, dms, los, mls)
✅ Docker Setup: PostgreSQL in Docker with automatic initialization
✅ CSV Import: Sample data included and ready to import
Prerequisites
Python 3.10 or higher
Docker and Docker Compose
pip (Python package installer)
Installation
Clone or navigate to the project directory:
cd c:\Users\chaya\project\mcp-databaseInstall Python dependencies:
pip install -r requirements.txtConfigure environment variables:
copy .env.example .envEdit
.envif you need to change database credentials (optional).
Setup
1. Start PostgreSQL Database
Start the PostgreSQL container with Docker Compose:
Verify the database is running:
2. Verify Database Initialization
The database will automatically initialize with schemas and sample data. Check the schemas:
List tables in a schema:
3. (Optional) Import CSV Data
Sample CSV files are provided in raw_data/. To import them into the database:
Import a specific CSV file:
Running the MCP Server
Test Locally
Run the server directly to test:
The server will start and listen for MCP messages via stdio.
Configure with Claude Desktop
To use this MCP server with Claude Desktop, add it to your Claude configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Add this configuration:
Restart Claude Desktop to load the server.
Available MCP Tools
1. list_schemas
Lists all available database schemas.
Example:
2. list_tables
Lists all tables, optionally filtered by schema.
Parameters:
schema(optional): Schema name to filter (e.g., "cs", "dms", "los", "mls")
Example:
3. describe_table
Get detailed column information for a specific table.
Parameters:
table_name(required): Name of the tableschema(optional): Schema name (default: "public")
Example:
4. execute_query
Execute a SQL query on the database.
Parameters:
query(required): SQL query stringparams(optional): Array of parameters for parameterized queries
Examples:
Database Schema
cs (CustomerScoreView)
customers: Customer information and credit scorescredit_assessments: Credit assessment history
dms (Data Management System)
documents: Document metadata and storage infodocument_versions: Document version history
los (Loan Management System)
loans: Loan accounts and termspayments: Payment history
mls (Mahatheun Leasing System)
contracts: Lease contract informationassets: Asset details for leased itemslease_payments: Lease payment records
Project Structure
Troubleshooting
Docker container won't start
Connection refused error
Ensure PostgreSQL is running:
docker-compose psCheck port 5432 is not in use by another process
Verify
.envfile has correct credentials
Import errors in Python
Development
To extend the server:
Add new tools in
src/tools.pyRegister handlers in
src/server.pyUpdate database schema in
db/init.sqlAdd sample data in
raw_data/
License
This project is provided as-is for database integration purposes.
This server cannot be installed