Skip to content

Commit 584ac44

Browse files
- Doc improvements.
1 parent de168ba commit 584ac44

File tree

3 files changed

+70
-51
lines changed

3 files changed

+70
-51
lines changed

AGENTS.md

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
11
# Repository Guidelines
22

3-
These guidelines help contributors work effectively on the PostgreSQL MCP server in this repo.
3+
These guidelines help contributors work effectively on this repository. We gratefully acknowledge [mcp-postgres](https://github.com/gldc/mcp-postgres) as the chief inspiration for the MCP server function and this document.
4+
5+
We also encourage reading [`docs/developer_guide.md`](/docs/developer_guide.md) for further useful information.
6+
7+
8+
## Project Structure & Module Organization
9+
10+
- Entrypoint: [`stackql/main.go`](/stackql/main.go).
11+
- Ideally, foregin system semantics are dealt with in the `any-sdk` repository.
12+
- Loose adherence to popular idioms:
13+
- App internals in [`internal`](/internal).
14+
- Re-usable modules in [`pkg`](/pkg).
15+
— The MCP server function is built upon the golang MCP SDK.
16+
- CICD: please see [the github actions workflows](/.github/workflows).
17+
- Docs: `README.md`, this `AGENTS.md`.
18+
19+
## Build, Test, and Development Commands
20+
21+
- Create env: `python -m venv .venv && source .venv/bin/activate`
22+
- Install deps: `pip install -r requirements.txt`
23+
- Run server (no DB): `python postgres_server.py`
24+
- Run with DB: `POSTGRES_CONNECTION_STRING="postgresql://user:pass@host:5432/db" python postgres_server.py`
25+
- Docker build/run: `docker build -t mcp-postgres .` then `docker run -e POSTGRES_CONNECTION_STRING=... -p 8000:8000 mcp-postgres`
26+
27+
## Coding Style & Naming Conventions
28+
29+
- Publish and program to abstractions.
30+
31+
## Testing Guidelines
32+
33+
- Black box regression tests are effectively mandatory. The canaonical ones reside in [`test/robot/functional`](/test/robot/functional).
34+
35+
## Tools & Resources
36+
37+
- Please inspect using the API.
38+
39+
40+
## Commit & Pull Request Guidelines
41+
42+
- Fork and pull model for general public; we **strongly** welcome public contributions, comment and issues.
43+
44+
## Security & Configuration Tips
45+
46+
- WIP.
47+
48+
---
449

550
## StackQL Resource Key Encoding Quirk
651

@@ -34,53 +79,3 @@ This ensures the backend treats the parameter as a literal string, not a path.
3479
Many RESTful routing libraries (like gorilla/mux) treat slashes as path separators. Encoding slashes prevents misinterpretation and ensures correct resource access.
3580

3681
Refer to this section whenever you encounter issues with resource keys containing slashes or hierarchical identifiers.
37-
38-
39-
## Project Structure & Module Organization
40-
- Root module: `postgres_server.py` — FastMCP server exposing PostgreSQL tools.
41-
- Config: `.env` (optional), `smithery.yaml` (publishing metadata).
42-
- Packaging/infra: `requirements.txt`, `Dockerfile`.
43-
- Docs: `README.md`, this `AGENTS.md`.
44-
- No dedicated `src/` or `tests/` directories yet; keep server logic cohesive and small, or start a `src/` layout if adding modules.
45-
46-
## Build, Test, and Development Commands
47-
- Create env: `python -m venv .venv && source .venv/bin/activate`
48-
- Install deps: `pip install -r requirements.txt`
49-
- Run server (no DB): `python postgres_server.py`
50-
- Run with DB: `POSTGRES_CONNECTION_STRING="postgresql://user:pass@host:5432/db" python postgres_server.py`
51-
- Docker build/run: `docker build -t mcp-postgres .` then `docker run -e POSTGRES_CONNECTION_STRING=... -p 8000:8000 mcp-postgres`
52-
53-
## Coding Style & Naming Conventions
54-
- Python 3.10+, 4-space indentation, PEP 8.
55-
- Use type hints (as in current code) and concise docstrings.
56-
- Functions/variables: `snake_case`; classes: `PascalCase`; MCP tool names: short `snake_case`.
57-
- Logging: use the existing `logger` instance; prefer informative, non-PII messages.
58-
- Optional formatting/linting: `black` and `ruff` (not enforced in repo). Example: `pip install black ruff && ruff check . && black .`.
59-
60-
## Testing Guidelines
61-
- There is no test suite yet. Prefer adding `pytest` with tests under `tests/` named `test_*.py`.
62-
- For DB behaviors, use a disposable PostgreSQL instance or mock `psycopg2` connections.
63-
- Minimum smoke test: start server without DSN, verify each tool returns the friendly “connection string is not set” message.
64-
65-
## Typed Tools & Resources
66-
- Preferred tools: `run_query(QueryInput)` and `run_query_json(QueryJSONInput)` with validated inputs (via Pydantic) and `row_limit` safeguards.
67-
- Legacy tools `query_v2`/`query_json` remain for backward compatibility. These return a json object with a property for rows.
68-
- Note the `query_v2` requires input of the form `{ "tool": "query", "input": { "sql": "SELECT 1;", "row_limit": 1 } }`
69-
- Table resources: `table://{schema}/{table}` (best-effort registration), with fallback tools `list_table_resources` and `read_table_resource`.
70-
- Prompts available as MCP prompts and tools: `write_safe_select`, `explain_plan_tips`.
71-
72-
## Tests
73-
- Test deps: `dev-requirements.txt` (`pytest`, `pytest-cov`).
74-
- Layout: `tests/test_server_tools.py` includes no-DSN smoke tests and prompt checks.
75-
- Run: `pytest -q`. Ensure runtime deps installed from `requirements.txt`.
76-
77-
## Commit & Pull Request Guidelines
78-
- Commit style: conventional commits preferred (`feat:`, `fix:`, `chore:`, `docs:`). Keep subjects imperative and concise.
79-
- PRs should include: purpose & scope, before/after behavior, example commands/queries, and any config changes (`POSTGRES_CONNECTION_STRING`, Docker, `mcp.json`).
80-
- When adding tools, document them in `README.md` (name, args, example) and ensure safe output formatting.
81-
- Never commit secrets. `.env`, `.venv`, and credentials are ignored by `.gitignore`.
82-
83-
## Security & Configuration Tips
84-
- Pass DB credentials via `POSTGRES_CONNECTION_STRING` env var; avoid hardcoding.
85-
- Prefer least-privilege DB users and SSL options (e.g., add `?sslmode=require`).
86-
- The server runs without a DSN for inspection; database-backed tools should fail gracefully (maintain this behavior).

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ Forks of the following support our work:
250250
* [gorilla/mux](https://github.com/gorilla/mux)
251251
* [readline](https://github.com/chzyer/readline)
252252
* [psql-wire](https://github.com/jeroenrinzema/psql-wire)
253+
* [mcp-postgres](https://github.com/gldc/mcp-postgres)
254+
* [the `golang` MCP SDK](https://github.com/modelcontextprotocol/go-sdk)
255+
* ...and more. Please excuse us for any omissions.
253256

254257
We gratefully acknowledge these pieces of work.
255258

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 gldc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)