pg-mcp
PostgreSQL MCP 处理器 - 基于 FastMCP 的数据库查询工具,提供数据库表查询、GDP 数据获取等功能。
环境变量
启动服务前需配置以下环境变量:
| 变量名 | 说明 | 默认值 |
|---|---|---|
PG_HOST |
数据库主机地址 | localhost |
PG_DATABASE |
数据库名称 | (必填) |
PG_USER |
数据库用户名 | (必填) |
PG_PASSWORD |
数据库密码 | (必填) |
PG_PORT |
数据库端口 | 5432 |
安装
uv pip install -e .
运行
export PG_HOST=your_host_address
export PG_DATABASE=your_database_name
export PG_USER=your_username
export PG_PASSWORD=your_password
export PG_PORT=your_port
pg-mcp-etop-test
或使用 uv run:
uv run pg-mcp-etop-test
可用工具
get_tables
获取数据库中的所有表名。
返回值: 数据库中的表名列表
get_table_columns
获取指定表的列名、数据类型和描述信息。
参数:
table_name(str): 表名
返回值: 包含列信息的字典列表,每个字典包含 column_name、data_type、is_nullable、column_default、is_primary_key、description 字段
get_distinct_values_list
获取指定表中某一列的所有不同值列表。
参数:
table_name(str): 表名column_name(str): 列名limit(int): 返回的最大不同值数量,默认 100
返回值: 不同值的列表,如果数量超过限制,只返回前 N 个
get_ordered_gdp
获取某一地区 GDP 数据,默认按统计日期降序排列。
参数:
district(str): 地区,默认为"宝安区"value_type(int): 数值类型,默认为 1limit(int): 返回记录数量限制,默认不限制order_desc(bool): 是否按统计日期降序排列,默认 True
返回值: 包含查询结果的字典列表
get_gdp_structure
获取某一地区 GDP 结构数据,默认按统计日期降序排列。
参数:
district(str): 地区,默认为"宝安区"limit(int): 返回记录数量限制,默认不限制order_desc(bool): 是否按统计日期降序排列,默认 True
返回值: 包含查询结果的字典列表
get_gdp_basic_aspects
获取某一地区 GDP 季度基础指标数据,默认按统计日期降序排列。
参数:
district(str): 地区,默认为"宝安区"limit(int): 返回记录数量限制,默认不限制order_desc(bool): 是否按统计日期降序排列,默认 True
返回值: 包含查询结果的字典列表
get_gdp_of_each_district
获取各区 GDP 对比数据,默认按统计日期降序排列。
参数:
year(str): GDP 数据对应年份,如 "2025"month(str): GDP 数据对应月份,如 "12",前三季度为 "09"limit(int): 返回记录数量限制,默认不限制order_desc(bool): 是否按统计日期降序排列,默认 True
返回值: 包含查询结果的字典列表
get_accounting_by_years
获取 GDP 相关行业指标数据。
参数:
year(str): 指标数据对应年份,如 "2025"month(str): 指标数据对应月份,如 "12"district(str): 指标对应的地区名称,默认为"宝安区"
返回值: 包含查询结果的字典列表
示例
设置环境变量后启动服务:
export PG_HOST=your_host_address
export PG_DATABASE=your_database_name
export PG_USER=your_username
export PG_PASSWORD=your_password
export PG_PORT=your_port
pg-mcp-etop-test
免责声明
个人测试使用,不建议在生产环境中使用。
Metadata
Release files for pg-mcp-etop-test 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pg_mcp_etop_test-0.1.3.tar.gz | 6.2 kB | Without provenance | Details for pg_mcp_etop_test-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pg_mcp_etop_test-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for pg_mcp_etop_test-0.1.3-py3-none-any.whl |
Total release size: 14.1 kB
Release files / pg_mcp_etop_test-0.1.3.tar.gz
| Download URL | pg_mcp_etop_test-0.1.3.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
baca4d85a7ec647aa8d94269550257b9e3cdd7607ac2c90d9dc20a9aac4bc688
|
|
BLAKE2b-256 checksum How to use checksums |
16061f1034ba680e312642161d117b398099c2da97e36e05737c5b17d39065bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / pg_mcp_etop_test-0.1.3-py3-none-any.whl
| Download URL | pg_mcp_etop_test-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
334eae92e526cb9819fb906e7d594a68fc7ab90975edf6d86b05883e3daddef3
|
|
BLAKE2b-256 checksum How to use checksums |
4524c7541c351ed9978b50ab84050471dd9aff98b7f3989ddd7e49118026928b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for pg-mcp-etop-test 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.