Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,6 @@ devenv.local.nix
# pre-commit
.pre-commit-config.yaml
*.sql
.idea
!tests/db-sample-data/
!tests/db-sample-data/*.sql
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '3.8'

services:
# Sample PostgreSQL database with dvdrental sample data
sample-postgres:
image: postgres:16-alpine
container_name: sample-postgres-db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: dvdrental
ports:
- "5432:5432"
volumes:
# Initialize with sample data from a SQL file
- ./test/db-sample-data:/docker-entrypoint-initdb.d
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
- postgres-mcp-network

# Postgres MCP Server
postgres-mcp-server:
build:
context: .
dockerfile: Dockerfile
container_name: postgres-mcp-server
ports:
- "8000:8000"
environment:
# Connection string to the sample database
- DATABASE_URL=postgresql://postgres:postgres@sample-postgres:5432/dvdrental
depends_on:
sample-postgres:
condition: service_healthy
networks:
- postgres-mcp-network
# Override the entrypoint to connect to our sample database with SSE transport for MCP Inspector
command: ["--access-mode=unrestricted", "--transport=sse", "postgresql://postgres:postgres@sample-postgres:5432/dvdrental"]

volumes:
postgres-data:
driver: local

networks:
postgres-mcp-network:
driver: bridge
8 changes: 8 additions & 0 deletions src/postgres_mcp/moldes/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from enum import Enum


class AccessMode(str, Enum):
"""SQL access modes for the server."""

UNRESTRICTED = "unrestricted" # Unrestricted access
RESTRICTED = "restricted" # Read-only with safety features
Loading