Skip to content

Commit 07dea21

Browse files
Merge pull request #4 from surajmandalcell/claude/publish-python-package-RTzUj
Claude/publish python package r tz uj
2 parents 157c4b3 + 9d27982 commit 07dea21

File tree

23 files changed

+898
-803
lines changed

23 files changed

+898
-803
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Postgres MCP CI
1+
name: pgsql-mcp CI
22

33
on:
44
push:
@@ -12,7 +12,7 @@ on:
1212
- "**/README.md"
1313

1414
jobs:
15-
postgres-mcp-ci:
15+
pgsql-mcp-ci:
1616
runs-on: ubuntu-latest
1717

1818
steps:

.github/workflows/docker-build-dockerhub.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
id: docker_meta
6161
uses: docker/metadata-action@v5
6262
with:
63-
images: crystaldba/postgres-mcp
63+
images: ${{ secrets.DOCKERHUB_USERNAME }}/pgsql-mcp
6464
tags: |
6565
type=raw,value=${{ needs.prepare.outputs.version }}
6666
type=raw,value=latest
@@ -84,5 +84,5 @@ jobs:
8484
platforms: linux/amd64,linux/arm64
8585
push: true
8686
tags: ${{ steps.docker_meta.outputs.tags }}
87-
cache-from: type=registry,ref=crystaldba/postgres-mcp:buildcache
88-
cache-to: type=registry,ref=crystaldba/postgres-mcp:buildcache,mode=max
87+
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pgsql-mcp:buildcache
88+
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pgsql-mcp:buildcache,mode=max

.github/workflows/pypi-publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: "Version to publish (must match pyproject.toml)"
10+
required: false
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
version: "0.6.9"
28+
29+
- name: Build package
30+
run: uv build
31+
32+
- name: Upload artifacts
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: dist
36+
path: dist/
37+
38+
publish:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
environment: pypi
42+
permissions:
43+
id-token: write
44+
steps:
45+
- name: Download artifacts
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: dist
49+
path: dist/
50+
51+
- name: Publish to PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1

CLAUDE.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# CLAUDE.md - Project Guidelines
2+
3+
## Project Overview
4+
5+
**pgsql-mcp** is a PostgreSQL MCP (Model Context Protocol) server providing index tuning, query analysis, explain plans, and database health monitoring.
6+
7+
## Build & Test Commands
8+
9+
```bash
10+
# Install dependencies
11+
uv sync
12+
13+
# Run tests
14+
uv run pytest -v
15+
16+
# Run linting
17+
uv run ruff format --check .
18+
uv run ruff check .
19+
20+
# Run type checking
21+
uv run pyright
22+
23+
# Run the server locally
24+
uv run pgsql-mcp --help
25+
```
26+
27+
## Code Style
28+
29+
- Python 3.12+
30+
- Line length: 150 characters
31+
- Formatter: ruff/black
32+
- Type hints required
33+
- Google-style docstrings
34+
35+
## Architecture
36+
37+
```
38+
src/postgres_mcp/
39+
├── __init__.py # Entry point (main function)
40+
├── sql/ # SQL execution & safety
41+
├── index/ # Index optimization (DTA algorithm)
42+
├── explain/ # Query plan analysis
43+
├── database_health/ # Health check modules
44+
├── migrations/ # Schema migration support
45+
└── top_queries/ # pg_stat_statements analysis
46+
```
47+
48+
## Development Rules
49+
50+
### SSOT (Single Source of Truth) - 100% Compliance
51+
52+
1. **Configuration**: All config lives in `pyproject.toml` - no duplicate config files
53+
2. **Constants**: Define once, import everywhere - no magic strings/numbers scattered in code
54+
3. **Types**: Single type definition per concept - reuse via imports
55+
4. **Database schemas**: Schema definitions in one place, reference elsewhere
56+
5. **Error messages**: Centralized error definitions when used in multiple places
57+
6. **Version**: Single version in `pyproject.toml` only
58+
59+
### DRY (Don't Repeat Yourself) - 100% Compliance
60+
61+
1. **No copy-paste code**: Extract to functions/classes when logic repeats
62+
2. **Shared utilities**: Common operations go in dedicated utility modules
63+
3. **SQL patterns**: Reusable SQL builders instead of string concatenation
64+
4. **Test fixtures**: Shared fixtures in `conftest.py`, not duplicated per test
65+
5. **Configuration**: Environment handling in one module, imported by others
66+
67+
### File Hygiene - Always Remove Unnecessary Files
68+
69+
1. **Delete, don't comment**: Remove dead code entirely, don't comment it out
70+
2. **No orphan files**: Delete files that are no longer imported/used
71+
3. **No placeholder files**: Remove empty `__init__.py` if not needed for packaging
72+
4. **Clean imports**: Remove unused imports immediately
73+
5. **No backup files**: No `.bak`, `.old`, `.backup` files in repo
74+
6. **No generated files in git**: Add build artifacts to `.gitignore`
75+
7. **Remove deprecated code**: When replacing functionality, delete the old implementation
76+
77+
### Before Every Commit
78+
79+
- [ ] No duplicate logic exists
80+
- [ ] No unused imports
81+
- [ ] No commented-out code
82+
- [ ] No orphan files
83+
- [ ] All constants centralized
84+
- [ ] Types reused via imports
85+
- [ ] Tests pass: `uv run pytest`
86+
- [ ] Lint passes: `uv run ruff check .`
87+
- [ ] Types pass: `uv run pyright`

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ ENV PATH="/app/.venv/bin:$PATH"
3737

3838
ARG TARGETPLATFORM
3939
ARG BUILDPLATFORM
40-
LABEL org.opencontainers.image.description="Postgres MCP Agent - Multi-architecture container (${TARGETPLATFORM})"
41-
LABEL org.opencontainers.image.source="https://github.com/crystaldba/postgres-mcp"
42-
LABEL org.opencontainers.image.licenses="Apache-2.0"
43-
LABEL org.opencontainers.image.vendor="Crystal DBA"
44-
LABEL org.opencontainers.image.url="https://www.crystaldba.ai"
40+
LABEL org.opencontainers.image.description="pgsql-mcp - PostgreSQL MCP Server (${TARGETPLATFORM})"
41+
LABEL org.opencontainers.image.source="https://github.com/surajmandalcell/postgres-mcp"
42+
LABEL org.opencontainers.image.licenses="MIT"
43+
LABEL org.opencontainers.image.vendor="surajmandalcell"
4544

4645
# Install runtime system dependencies
4746
RUN apt-get update && apt-get install -y \
@@ -57,9 +56,9 @@ RUN chmod +x /app/docker-entrypoint.sh
5756
# Expose the SSE port
5857
EXPOSE 8000
5958

60-
# Run the postgres-mcp server
59+
# Run the pgsql-mcp server
6160
# Users can pass a database URI or individual connection arguments:
62-
# docker run -it --rm postgres-mcp postgres://user:pass@host:port/dbname
63-
# docker run -it --rm postgres-mcp -h myhost -p 5432 -U myuser -d mydb
64-
ENTRYPOINT ["/app/docker-entrypoint.sh", "postgres-mcp"]
61+
# docker run -it --rm pgsql-mcp postgres://user:pass@host:port/dbname
62+
# docker run -it --rm pgsql-mcp -h myhost -p 5432 -U myuser -d mydb
63+
ENTRYPOINT ["/app/docker-entrypoint.sh", "pgsql-mcp"]
6564
CMD []

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025, Crystal Corp.
3+
Copyright (c) 2025, Suraj Mandal
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

PUBLISHING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Publishing to PyPI
2+
3+
This project uses GitHub Actions with PyPI Trusted Publishing (OIDC) for secure, token-free releases.
4+
5+
## One-Time Setup on PyPI
6+
7+
1. Go to https://pypi.org/manage/account/publishing/
8+
2. Add a new pending publisher with these values:
9+
10+
| Field | Value |
11+
|-------|-------|
12+
| **PyPI Project Name** | `pgsql-mcp` |
13+
| **Owner** | `surajmandalcell` |
14+
| **Repository name** | `pgsql-mcp` |
15+
| **Workflow name** | `pypi-publish.yml` |
16+
| **Environment name** | `pypi` |
17+
18+
3. In your GitHub repository, create the environment:
19+
- Go to Settings → Environments → New environment
20+
- Name: `pypi`
21+
- Optionally add protection rules (required reviewers, etc.)
22+
23+
## Publishing a Release
24+
25+
### Option 1: GitHub Release (Recommended)
26+
27+
```bash
28+
# 1. Update version in pyproject.toml
29+
# 2. Commit and push
30+
git add pyproject.toml
31+
git commit -m "Bump version to X.Y.Z"
32+
git push
33+
34+
# 3. Create and push a tag
35+
git tag -a vX.Y.Z -m "Release vX.Y.Z"
36+
git push --tags
37+
38+
# 4. Create GitHub release (triggers the workflow)
39+
gh release create vX.Y.Z --title "pgsql-mcp vX.Y.Z" --notes "Release notes here"
40+
```
41+
42+
### Option 2: Manual Workflow Dispatch
43+
44+
1. Go to Actions → "Publish to PyPI" → Run workflow
45+
2. Click "Run workflow"
46+
47+
### Option 3: Local Build and Upload (Manual)
48+
49+
```bash
50+
# Build
51+
uv build
52+
53+
# Upload (requires PyPI API token)
54+
uv publish
55+
# or
56+
twine upload dist/*
57+
```

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Postgres MCP
1+
# pgsql-mcp
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4-
[![PyPI - Version](https://img.shields.io/pypi/v/postgres-mcp)](https://pypi.org/project/postgres-mcp/)
4+
[![PyPI - Version](https://img.shields.io/pypi/v/pgsql-mcp)](https://pypi.org/project/pgsql-mcp/)
55

66
A PostgreSQL MCP server with index tuning, explain plans, health checks, and safe SQL execution.
77

@@ -24,7 +24,7 @@ For Claude Code or cloud-based IDEs, add to your MCP configuration:
2424
"mcpServers": {
2525
"postgres": {
2626
"command": "uvx",
27-
"args": ["postgres-mcp", "--access-mode=unrestricted"],
27+
"args": ["pgsql-mcp", "--access-mode=unrestricted"],
2828
"env": {
2929
"DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
3030
}
@@ -41,7 +41,7 @@ For Claude Code or cloud-based IDEs, add to your MCP configuration:
4141
```bash
4242
docker run -p 8000:8000 \
4343
-e DATABASE_URI=postgresql://username:password@localhost:5432/dbname \
44-
crystaldba/postgres-mcp --access-mode=unrestricted --transport=sse
44+
pgsql-mcp --access-mode=unrestricted --transport=sse
4545
```
4646

4747
2. Add to your MCP config (`mcp.json` for Cursor, `mcp_config.json` for Windsurf):
@@ -69,7 +69,7 @@ docker run -p 8000:8000 \
6969
"args": [
7070
"run", "-i", "--rm",
7171
"-e", "DATABASE_URI",
72-
"crystaldba/postgres-mcp",
72+
"pgsql-mcp",
7373
"--access-mode=unrestricted"
7474
],
7575
"env": {
@@ -80,32 +80,32 @@ docker run -p 8000:8000 \
8080
}
8181
```
8282

83-
### Docker MCP Platform
83+
### Docker
8484

8585
```bash
86-
docker pull crystaldba/postgres-mcp
86+
docker pull pgsql-mcp
8787
```
8888

8989
Run with stdio:
9090
```bash
9191
docker run -i --rm \
9292
-e DATABASE_URI=postgresql://username:password@localhost:5432/dbname \
93-
crystaldba/postgres-mcp --access-mode=unrestricted
93+
pgsql-mcp --access-mode=unrestricted
9494
```
9595

9696
Run with SSE:
9797
```bash
9898
docker run -p 8000:8000 \
9999
-e DATABASE_URI=postgresql://username:password@localhost:5432/dbname \
100-
crystaldba/postgres-mcp --access-mode=unrestricted --transport=sse
100+
pgsql-mcp --access-mode=unrestricted --transport=sse
101101
```
102102

103103
### Python Installation
104104

105105
```bash
106-
pipx install postgres-mcp
106+
pipx install pgsql-mcp
107107
# or
108-
uv pip install postgres-mcp
108+
uv pip install pgsql-mcp
109109
```
110110

111111
## Access Modes

assets/postgres-mcp-pro.png

-22.9 KB
Binary file not shown.

devenv.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ in
6262

6363
enterShell = ''
6464
hello
65-
echo "Crystal DBA Agent Development Environment"
65+
echo "pgsql-mcp Development Environment"
6666
'';
6767

6868
# https://devenv.sh/tasks/

0 commit comments

Comments
 (0)