Token导航 LogoToken导航TokenDH.com
Geo Post MCP logo
数据服务stdio官方级别未说明来源级核验

Geo Post MCP

MCP Server

一个为PostgreSQL数据库提供AI助手接口的服务,支持PostGIS地理空间查询,允许LLM执行SQL查询、发现数据库模式并读取列描述。

工具数

4

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude数据分析Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

deltorro2

提供方

deltorro2

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -e .

详细介绍

地理邮政mcp

MCP服务器,为PostgreSQL数据库提供人工智能辅助接口,支持PostGIS。使LLM能够执行SQL SELECT查询、运行地理空间查询、发现数据库模式和读取列描述——所有这些都可以通过 模型上下文协议.

特性

  • sql查询 --执行任何SELECT查询(JOIN、CTE、聚合、子查询)。非SELECT语句被拒绝。
  • 地理空间查询 --完全支持PostGIS。几何列返回为GeoJSON。
  • 架构发现 --列出表,用类型、可空性、默认值和空间元数据(几何类型、SRID)描述列。
  • 字段含义 --从数据库模式中读取列注释,以了解每个字段代表什么。
  • 访问控制 --可配置的允许表列表限制了可以查询哪些表。
  • 结构化日志记录 --通过structlog为每次工具调用生成JSON格式的日志。

MCP工具

工具说明
query执行SQL SELECT查询。返回列、行和行数。
list_tables列出所有允许的表,并估计行数。
describe_table描述表的列(类型、可空性、空间元数据)。
fieldmeaning获取表的列注释/描述。

先决条件

工具版本目的
Python3.11+运行时
PostgreSQL14+数据库
PostGIS3.0+PostgreSQL的地理空间扩展
pip最新Python包管理器

自动设置

提供安装脚本来安装所有先决条件和Python依赖项。

macOS/Linux:

chmod +x install.sh
./install.sh

Windows(PowerShell作为管理员):

.\install.ps1

手动安装

  1. Python 3.11+ — https://www.python.org/downloads/
  2. PostgreSQL 14+ — https://www.postgresql.org/download/
  3. PostGIS 3.0+ — https://postgis.net/documentation/getting_started/#installing-邮政地理信息系统
  4. 启用PostGIS 在您的数据库中:
   CREATE EXTENSION IF NOT EXISTS postgis;
  1. 安装Python依赖项:
   pip install -e .

对于测试依赖关系:

   pip install -e ".[test]"

配置

1.设置文件

创建 geo-post-mcp-settings.json 在项目根目录中:

{
  "host": "127.0.0.1",
  "port": 5432,
  "user": "postgres",
  "dbname": "my_database",
  "schema": "public",
  "allowed_tables": ["parcels", "buildings", "roads"]
}
字段类型描述
hoststring数据库主机
portinteger数据库端口
userstring数据库用户
dbnamestring数据库名称
schemastring要查询的架构(默认值: public)
allowed_tablesstring\[\]允许服务器访问的表

2.数据库密码

通过环境变量设置密码(从不存储在设置文件中):

export POSTGISMCPPASS="your_password"

如果未设置,则默认为空字符串(用于无密码本地连接)。

运行服务器

使用 --sett 指定设置文件的路径。如果省略,服务器将查找 geo-post-mcp-settings.json 在当前工作目录中。

流式HTTP(用于远程访问)

fastmcp run src/server.py --transport streamable-http --host 0.0.0.0 --port 8000 -- --sett /path/to/geo-post-mcp-settings.json

stdio(适用于Claude Desktop和本地客户端)

fastmcp run src/server.py -- --sett /path/to/geo-post-mcp-settings.json

没有 --sett (在当前目录中查找):

fastmcp run src/server.py

连接到克劳德桌面

添加到您的Claude Desktop配置文件中:

macOS: /Users/michael/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "geo-post-mcp": {
      "command": "/path/to/bin/fastmcp",
      "args": [
        "run",
        "/absolute/path/to/geo-post-mcp/src/server.py",
        "--",
        "--sett",
        "/absolute/path/to/geo-post-mcp/geo-post-mcp-settings.json"
      ],
      "env": {
        "POSTGISMCPPASS": "your_password"
      }
    }
  }
}

用实际位置替换路径。使用完整路径 fastmcp (找到它 which fastmcp).编辑后重新启动Claude Desktop。

连接到MCP检查器

本地

fastmcp dev src/server.py

这将在浏览器中打开MCP检查器 http://localhost:6274。您可以交互式地测试所有工具。

远程

在远程计算机上使用HTTP传输启动服务器:

POSTGISMCPPASS="your_password" fastmcp run src/server.py \
  --transport streamable-http --host 0.0.0.0 --port 8000

然后将MCP检查器连接到 http://:8000/mcp/.

运行测试

单元测试(无需数据库)

pytest -m unit

功能测试(需要数据库)

pytest -m functional

所有测试

pytest

如果数据库不可用,功能测试会自动跳过并显示一条明确的消息。

项目结构

src/
├── config/
│   ├── settings.py          # Settings loader (JSON + env var)
│   └── logging.py           # Structured logging setup
├── models/
│   ├── fieldmeaning.py      # Pydantic models for fieldmeaning tool
│   └── query.py             # QueryResult model
├── services/
│   ├── database.py          # Async database connection
│   ├── sql_validator.py     # SELECT-only enforcement
│   ├── access_control.py    # Allowed tables check
│   ├── fieldmeaning.py      # Column metadata queries
│   ├── schema.py            # Schema discovery queries
│   └── query.py             # Query execution
├── tools/
│   ├── query.py             # query MCP tool
│   ├── schema.py            # list_tables, describe_table MCP tools
│   └── fieldmeaning.py      # fieldmeaning MCP tool
└── server.py                # FastMCP server entrypoint

tests/
├── unit/                    # 48 tests, no DB required
└── functional/              # 22 tests, requires PostgreSQL+PostGIS

许可证

麻省理工学院

目录标签

目录标签

PythonClaude数据分析PostgreSQL助手本地部署地理空间查询数据库AI接口SQL执行模式发现

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP