# PgSQL MCP Server
[](https://pypi.org/project/pgsql-mcp-server/)

[](https://qlty.sh/gh/twn39/projects/pgsql-mcp-server)
**A powerful tool server based on the Model Context Protocol (MCP), enabling interaction with PostgreSQL databases via MCP calls.**
---
## 🚀 Overview
This project is built on the `FastMCP` framework and leverages the `SQLAlchemy` and `asyncpg` libraries to deliver high-performance asynchronous database operations, ensuring efficiency and responsiveness when handling database requests.
## ✨ Key Features
- **Asynchronous & Efficient:** Fully asynchronous implementation based on `asyncio`, utilizing `asyncpg` for a high-performance asynchronous PostgreSQL driver.
- **Transactional Safety:** DDL, DML, and DCL operations are executed within transactions with error handling and rollback mechanisms.
- **Easy Deployment:** Start the server with a simple command line interface.
## 📦 Installation
Ensure you have Python 3.8+ installed. Installation via `uvx` is recommended:
```bash
uvx pgsql-mcp-server --dsn postgresql://user:password@localhost:5432/db
```
## 🔍 Preview and Debugging
You can use the official MCP Inspector tool to visually inspect the tools provided by this server, view their parameters and descriptions, and perform test calls directly.
```bash
npx @modelcontextprotocol/inspector uvx pgsql-mcp-server --dsn "postgresql://user:password@host:port/database"
```
This will start a local web service. Open the provided URL in your browser to begin debugging.
## 🤝 Contributing
Contributions are welcome! If you have suggestions for improvements, feature requests, or find any bugs, please feel free to:
1. Open an [Issue](https://github.com/twn39/pgsql-mcp-server/issues) to discuss.
2. Fork the repository and create your feature branch (`git checkout -b feature/AmazingFeature`).
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
4. Push to the branch (`git push origin feature/AmazingFeature`).
5. Open a [Pull Request](https://github.com/twn39/pgsql-mcp-server/pulls).
Raw data
{
"_id": null,
"home_page": null,
"name": "pgsql-mcp-server",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "curry tang <twn39@163.com>",
"keywords": "ai, mcp, mcp-server, pgsql, pgsql-mcp-server, postgresql",
"author": null,
"author_email": "curry tang <twn39@163.com>",
"download_url": "https://files.pythonhosted.org/packages/e9/1e/4d136377982164281b84d7ee2312128640c58c639d8c16510433a56febd9/pgsql_mcp_server-1.3.2.tar.gz",
"platform": null,
"description": "# PgSQL MCP Server\n\n[](https://pypi.org/project/pgsql-mcp-server/)\n\n[](https://qlty.sh/gh/twn39/projects/pgsql-mcp-server)\n\n**A powerful tool server based on the Model Context Protocol (MCP), enabling interaction with PostgreSQL databases via MCP calls.**\n\n---\n\n## \ud83d\ude80 Overview\n\nThis project is built on the `FastMCP` framework and leverages the `SQLAlchemy` and `asyncpg` libraries to deliver high-performance asynchronous database operations, ensuring efficiency and responsiveness when handling database requests.\n\n## \u2728 Key Features\n\n- **Asynchronous & Efficient:** Fully asynchronous implementation based on `asyncio`, utilizing `asyncpg` for a high-performance asynchronous PostgreSQL driver.\n- **Transactional Safety:** DDL, DML, and DCL operations are executed within transactions with error handling and rollback mechanisms.\n- **Easy Deployment:** Start the server with a simple command line interface.\n\n## \ud83d\udce6 Installation\n\nEnsure you have Python 3.8+ installed. Installation via `uvx` is recommended:\n\n```bash\nuvx pgsql-mcp-server --dsn postgresql://user:password@localhost:5432/db\n```\n\n## \ud83d\udd0d Preview and Debugging\n\nYou can use the official MCP Inspector tool to visually inspect the tools provided by this server, view their parameters and descriptions, and perform test calls directly.\n\n```bash\nnpx @modelcontextprotocol/inspector uvx pgsql-mcp-server --dsn \"postgresql://user:password@host:port/database\"\n```\n\nThis will start a local web service. Open the provided URL in your browser to begin debugging.\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! If you have suggestions for improvements, feature requests, or find any bugs, please feel free to:\n\n1. Open an [Issue](https://github.com/twn39/pgsql-mcp-server/issues) to discuss.\n2. Fork the repository and create your feature branch (`git checkout -b feature/AmazingFeature`).\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).\n4. Push to the branch (`git push origin feature/AmazingFeature`).\n5. Open a [Pull Request](https://github.com/twn39/pgsql-mcp-server/pulls).\n",
"bugtrack_url": null,
"license": null,
"summary": "PostgreSQL MCP Server",
"version": "1.3.2",
"project_urls": {
"Documentation": "https://github.com/twn39/pgsql-mcp-server",
"Homepage": "https://github.com/twn39/pgsql-mcp-server",
"Repository": "https://github.com/twn39/pgsql-mcp-server",
"Source Code": "https://github.com/twn39/pgsql-mcp-server"
},
"split_keywords": [
"ai",
" mcp",
" mcp-server",
" pgsql",
" pgsql-mcp-server",
" postgresql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c6843f7b8dedea4bbeb6f653210f8ef6b38cd53bb8f207c5d0c38924640eda50",
"md5": "f12b43c7e06c69250062221db735f506",
"sha256": "a078cb6e86dea558372fcb9e4479181065eb5c70423067553c5d100af4d4a624"
},
"downloads": -1,
"filename": "pgsql_mcp_server-1.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f12b43c7e06c69250062221db735f506",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 4926,
"upload_time": "2025-07-22T05:34:24",
"upload_time_iso_8601": "2025-07-22T05:34:24.475780Z",
"url": "https://files.pythonhosted.org/packages/c6/84/3f7b8dedea4bbeb6f653210f8ef6b38cd53bb8f207c5d0c38924640eda50/pgsql_mcp_server-1.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e91e4d136377982164281b84d7ee2312128640c58c639d8c16510433a56febd9",
"md5": "a34c87b776b5cb2ef8cb46009ca5a90c",
"sha256": "4d5acf9b8a2bb1d4db84b035ba1beefb381ba028be11bcdc029b9b0a462a7333"
},
"downloads": -1,
"filename": "pgsql_mcp_server-1.3.2.tar.gz",
"has_sig": false,
"md5_digest": "a34c87b776b5cb2ef8cb46009ca5a90c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 40080,
"upload_time": "2025-07-22T05:34:26",
"upload_time_iso_8601": "2025-07-22T05:34:26.081937Z",
"url": "https://files.pythonhosted.org/packages/e9/1e/4d136377982164281b84d7ee2312128640c58c639d8c16510433a56febd9/pgsql_mcp_server-1.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-22 05:34:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "twn39",
"github_project": "pgsql-mcp-server",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "annotated-types",
"specs": [
[
"==",
"0.7.0"
]
]
},
{
"name": "anyio",
"specs": [
[
"==",
"4.9.0"
]
]
},
{
"name": "async-timeout",
"specs": [
[
"==",
"5.0.1"
]
]
},
{
"name": "asyncpg",
"specs": [
[
"==",
"0.30.0"
]
]
},
{
"name": "attrs",
"specs": [
[
"==",
"25.3.0"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2025.7.14"
]
]
},
{
"name": "click",
"specs": [
[
"==",
"8.2.1"
]
]
},
{
"name": "exceptiongroup",
"specs": [
[
"==",
"1.3.0"
]
]
},
{
"name": "greenlet",
"specs": [
[
"==",
"3.2.3"
]
]
},
{
"name": "h11",
"specs": [
[
"==",
"0.16.0"
]
]
},
{
"name": "httpcore",
"specs": [
[
"==",
"1.0.9"
]
]
},
{
"name": "httpx",
"specs": [
[
"==",
"0.28.1"
]
]
},
{
"name": "httpx-sse",
"specs": [
[
"==",
"0.4.1"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.10"
]
]
},
{
"name": "jsonschema",
"specs": [
[
"==",
"4.25.0"
]
]
},
{
"name": "jsonschema-specifications",
"specs": [
[
"==",
"2025.4.1"
]
]
},
{
"name": "markdown-it-py",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "mcp",
"specs": [
[
"==",
"1.12.0"
]
]
},
{
"name": "mdurl",
"specs": [
[
"==",
"0.1.2"
]
]
},
{
"name": "pydantic",
"specs": [
[
"==",
"2.11.7"
]
]
},
{
"name": "pydantic-core",
"specs": [
[
"==",
"2.33.2"
]
]
},
{
"name": "pydantic-settings",
"specs": [
[
"==",
"2.10.1"
]
]
},
{
"name": "pygments",
"specs": [
[
"==",
"2.19.2"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
"==",
"1.1.1"
]
]
},
{
"name": "python-multipart",
"specs": [
[
"==",
"0.0.20"
]
]
},
{
"name": "referencing",
"specs": [
[
"==",
"0.36.2"
]
]
},
{
"name": "rich",
"specs": [
[
"==",
"14.0.0"
]
]
},
{
"name": "rpds-py",
"specs": [
[
"==",
"0.26.0"
]
]
},
{
"name": "shellingham",
"specs": [
[
"==",
"1.5.4"
]
]
},
{
"name": "sniffio",
"specs": [
[
"==",
"1.3.1"
]
]
},
{
"name": "sqlalchemy",
"specs": [
[
"==",
"2.0.41"
]
]
},
{
"name": "sqlmodel",
"specs": [
[
"==",
"0.0.24"
]
]
},
{
"name": "sse-starlette",
"specs": [
[
"==",
"2.4.1"
]
]
},
{
"name": "starlette",
"specs": [
[
"==",
"0.47.2"
]
]
},
{
"name": "tabulate",
"specs": [
[
"==",
"0.9.0"
]
]
},
{
"name": "typer",
"specs": [
[
"==",
"0.16.0"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
"==",
"4.14.1"
]
]
},
{
"name": "typing-inspection",
"specs": [
[
"==",
"0.4.1"
]
]
},
{
"name": "uvicorn",
"specs": [
[
"==",
"0.35.0"
]
]
}
],
"lcname": "pgsql-mcp-server"
}