Back to MCP directory
publicPublicdnsLocal runtime

Geoserver MCP Server

GeoServer MCP Server是一个实现模型上下文协议(MCP)的服务端,连接大型语言模型(LLMs)与GeoServer REST API,使AI助手能够交互地理空间数据和服务。

article

README

🚀 GeoServer MCP 服务器

GeoServer MCP 服务器是一个基于 Model Context Protocol (MCP) 的开源工具,可与 GeoServer REST API 进行交互。借助该项目,您能便捷地操作矢量数据、样式、工作区和图层。


🚀 快速开始

1. 安装依赖

pip install geoserver-mcp requests

2. 示例用法

以下是一个简单的客户端示例:

from geoserver_mcp.client import MCPClient

client = MCPClient(base_url="http://localhost:8080/geoserver/rest", username="admin", password="geoserver")

# 获取工作区列表
print(client.list_workspaces())

# 创建新工作区
client.create_workspace("my_new_workspace")

# 删除资源
client.delete_resource(workspace="topp", layer="states")

✨ 主要特性

工具类别

工作区和图层管理

| 工具 | 描述 | |--------------------|----------------------| | list_workspaces | 获取可用的工作区 | | create_workspace | 创建新的工作区 | | delete_resource | 删除资源 |

数据操作

| 工具 | 描述 | |-------------------|---------------------------| | query_features | 执行矢量数据上的 CQL 查询 | | update_features | 修改特征属性 | | delete_features | 根据条件删除特征 |

可视化

| 工具 | 描述 | |---------------|--------------------------| | generate_map | 创建带样式的地图图像 | | create_style | 定义新的 SLD 样式 | | apply_style | 将现有样式应用到图层 |

示例用法

列出工作区

Tool: list_workspaces
Parameters: {}
Response: ["default", "demo", "topp", "tiger", "sf"]

获取图层信息

Tool: get_layer_info
Parameters: {
  "workspace": "topp",
  "layer": "states"
}

查询特征

Tool: query_features
Parameters: {
  "workspace": "topp",
  "layer": "states",
  "filter": "PERSONS > 10000000",
  "properties": ["STATE_NAME", "PERSONS"]
}

生成地图

Tool: generate_map
Parameters: {
  "layers": ["topp:states"],
  "styles": ["population"],
  "bbox": [-124.73, 24.96, -66.97, 49.37],
  "width": 800,
  "height": 600,
  "format": "png"
}

📚 详细文档

客户端开发

如果您计划开发自己的客户端来与 GeoServer MCP 服务器交互,可以参考示例客户端实现 examples/client.py。该示例展示了:

  • 如何与 MCP 服务器建立连接
  • 如何发送请求并处理响应
  • 如何使用不同工具进行操作

📄 许可证

本项目遵循 MIT 许可证,具体内容请参阅 LICENSE 文件。


支持

如果您觉得这个项目对您有帮助,请通过以下方式支持:

感谢您对 GeoServer MCP 项目的关注与支持!

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client