Skip to main content

PostgreSQL MCP处理器 - 提供数据库表查询、GDP数据获取等功能的MCP服务

Project description

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_namedata_typeis_nullablecolumn_defaultis_primary_keydescription 字段


get_distinct_values_list

获取指定表中某一列的所有不同值列表。

参数:

  • table_name (str): 表名
  • column_name (str): 列名
  • limit (int): 返回的最大不同值数量,默认 100

返回值: 不同值的列表,如果数量超过限制,只返回前 N 个


get_ordered_gdp

获取某一地区 GDP 数据,默认按统计日期降序排列。

参数:

  • district (str): 地区,默认为"宝安区"
  • value_type (int): 数值类型,默认为 1
  • limit (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

免责声明

个人测试使用,不建议在生产环境中使用。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pg_mcp_etop_test-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pg_mcp_etop_test-0.1.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file pg_mcp_etop_test-0.1.3.tar.gz.

File metadata

  • Download URL: pg_mcp_etop_test-0.1.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pg_mcp_etop_test-0.1.3.tar.gz
Algorithm Hash digest
SHA256 baca4d85a7ec647aa8d94269550257b9e3cdd7607ac2c90d9dc20a9aac4bc688
MD5 46e91af4ef1480ce1264551a80f63e42
BLAKE2b-256 16061f1034ba680e312642161d117b398099c2da97e36e05737c5b17d39065bd

See more details on using hashes here.

File details

Details for the file pg_mcp_etop_test-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pg_mcp_etop_test-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 334eae92e526cb9819fb906e7d594a68fc7ab90975edf6d86b05883e3daddef3
MD5 d2b648e94922bb45472ba3f3096b2132
BLAKE2b-256 4524c7541c351ed9978b50ab84050471dd9aff98b7f3989ddd7e49118026928b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page