Metadata-Version: 2.4
Name: pg-mcp-etop-test
Version: 0.1.3
Summary: PostgreSQL MCP处理器 - 提供数据库表查询、GDP数据获取等功能的MCP服务
Author-email: PG MCP Team <support@pg-mcp.com>
Maintainer-email: PG MCP Team <support@pg-mcp.com>
License: MIT
Keywords: postgresql,pg,database,mcp,fastmcp,gdp,data-analysis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: psycopg2-binary>=2.9.9
Requires-Dist: fastmcp>=0.5.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"

# pg-mcp

PostgreSQL MCP 处理器 - 基于 FastMCP 的数据库查询工具，提供数据库表查询、GDP 数据获取等功能。

## 环境变量

启动服务前需配置以下环境变量：

| 变量名 | 说明 | 默认值 |
|--------|------|--------|
| `PG_HOST` | 数据库主机地址 | localhost |
| `PG_DATABASE` | 数据库名称 | (必填) |
| `PG_USER` | 数据库用户名 | (必填) |
| `PG_PASSWORD` | 数据库密码 | (必填) |
| `PG_PORT` | 数据库端口 | 5432 |

## 安装

```bash
uv pip install -e .
```

## 运行

```bash
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：

```bash
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): 数值类型，默认为 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): 指标对应的地区名称，默认为"宝安区"

**返回值:** 包含查询结果的字典列表

## 示例

设置环境变量后启动服务：

```bash
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
```

## 免责声明

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