MCP (Model Context Protocol) Server

by VajraM-dev

131 downloads Not rated yet
GitHub

About

# 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 ├──…

Explore

- 🔒 Secure configuration management
- 🗃️ PostgreSQL database integration
- 🤖 Multi-provider AI model support
- 📡 Flexible communication transport
- 🛡️ Extensible tool registration

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP (Model Context Protocol) Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Python 3.10+
- PostgreSQL
- API access to AI providers (Anthropic, Google)

python -m venv venv
source venv/bin/activate  # On Windows, use venv\Scripts\activate
pip install -r requirements.txt

1. Copy .env.example to .env.dev
2. Fill in the required configuration:

cp .env.example .env.dev
nano .env.dev  # or use your preferred text editor

- POSTGRES_USERNAME: PostgreSQL database username
- POSTGRES_PASSWORD: PostgreSQL database password
- POSTGRES_DB_NAME: Database name
- POSTGRES_HOST: Database host
- POSTGRES_PORT: Database port
- MCP_NAME: Server name
- MCP_HOST: Server host
- MCP_PORT: Server port
- TRANSPORT: Communication transport (sse/stdio)
- ANTHROPIC_API_KEY: Anthropic API key
- GOOGLE_API_KEY: Google API key
- USE_PROVIDER: Default AI provider

Modify lm_config.py to add or configure new AI providers.

- list_tables(): Retrieve database tables
- Custom tools can be easily added via decorators

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp (model context protocol) server": {
            "Postgres-MCP-Server-With-SSE-Transport": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "Postgres-MCP-Server-With-SSE-Transport": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

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

1. Copy .env.example to .env.dev 2. 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 username - POSTGRES_PASSWORD: PostgreSQL database password - POSTGRES_DB_NAME: Database name - POSTGRES_HOST: Database host - POSTGRES_PORT: Database port - MCP_NAME: Server name - MCP_HOST: Server host - MCP_PORT: Server port - TRANSPORT: Communication transport (sse/stdio) - ANTHROPIC_API_KEY: Anthropic API key - GOOGLE_API_KEY: Google API key - USE_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.
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.