VajraM-dev/Postgres-MCP-Server-With-SSE-Transport
If you are the rightful owner of Postgres-MCP-Server-With-SSE-Transport and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP (Model Context Protocol) Server is designed to facilitate secure and efficient interaction with AI models using a flexible communication protocol.
MCP (Model Context Protocol) Server
Project Structure
āāā client.py # Client-side interaction script
āāā server.py # Main MCP server implementation
āāā pg_connect.py # PostgreSQL database connection
āāā lm_config.py # Language model configuration
ā
āāā .env.example # Example environment configuration
āāā .env.dev # Development environment configuration
āāā requirements.txt # Project dependencies
āāā .gitignore # Git ignore file
Prerequisites
- Python 3.10+
- PostgreSQL
- API access to AI providers (Anthropic, Google)
Installation
1. Clone the Repository
git https://github.com/VajraM-dev/Postgres-MCP-Server-With-SSE-Transport.git
2. Create Virtual Environment
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
3. Install Dependencies
pip install -r requirements.txt
4. Configure Environment
- Copy
.env.exampleto.env.dev - Fill in the required configuration:
cp .env.example .env.dev
nano .env.dev # or use your preferred text editor
Configuration Parameters
POSTGRES_USERNAME: PostgreSQL database usernamePOSTGRES_PASSWORD: PostgreSQL database passwordPOSTGRES_DB_NAME: Database namePOSTGRES_HOST: Database hostPOSTGRES_PORT: Database portMCP_NAME: Server nameMCP_HOST: Server hostMCP_PORT: Server portTRANSPORT: Communication transport (sse/stdio)ANTHROPIC_API_KEY: Anthropic API keyGOOGLE_API_KEY: Google API keyUSE_PROVIDER: Default AI provider
Running the Server
Development Mode
python server.py
Client Interaction
python client.py
Key Features
- š Secure configuration management
- šļø PostgreSQL database integration
- š¤ Multi-provider AI model support
- š” Flexible communication transport
- š”ļø Extensible tool registration
Supported AI Providers
- Anthropic (Claude models)
- Google (Gemini models)
Tools and Endpoints
Available Tools
list_tables(): Retrieve database tables- Custom tools can be easily added via decorators
Endpoints
/sse: Server-Sent Events endpoint- Customizable routing and tool registration
Extending the Framework
Adding New Tools
@app.tool()
def custom_tool():
"""Custom tool implementation"""
# Your tool logic here
Configuring AI Providers
Modify lm_config.py to add or configure new AI providers.