GeoServer MCP 服务器

0.4.0(Alpha)版本正在积极开发中,即将发布。我们欢迎开发者贡献代码,共同构建这个项目。
🎥 演示
Related MCP server: MCP Google Map Server
📋 目录
🚀 功能
📋 先决条件
🛠️ 安装
选择最适合您需要的安装方法:
🛠️ 安装(Docker)
Docker 安装是运行 GeoServer MCP 服务器最快捷、最独立的安装方式。它非常适合:
快速测试和评估
生产部署
想要避免 Python 依赖的环境
跨不同系统的一致部署
运行 geoserver-mcp:
docker pull mahdin75/geoserver-mcp
docker run -d mahdin75/geoserver-mcp
配置客户端:
如果您使用的是 Claude Desktop,请编辑claude_desktop_config.json如果您使用的是 Cursor,请创建.cursor/mcp.json
{
"mcpServers": {
"geoserver-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GEOSERVER_URL=http://localhost:8080/geoserver",
"-e",
"GEOSERVER_USER=admin",
"-e",
"GEOSERVER_PASSWORD=geoserver",
"-p",
"8080:8080",
"mahdin75/geoserver-mcp"
]
}
}
}
🛠️ 安装(pip)
对于大多数希望直接在系统上运行服务器的用户,建议使用 pip 安装。此方法最适合:
想要在本地运行服务器的普通用户
安装了 Python 3.10+ 的系统
想要自定义服务器配置的用户
开发和测试目的
安装 uv 包管理器。
创建虚拟环境(Python 3.10+):
Linux/Mac:
Windows PowerShell:
使用 pip 安装包:
uv pip install geoserver-mcp
配置GeoServer连接:
Linux/Mac:
export GEOSERVER_URL="http://localhost:8080/geoserver"
export GEOSERVER_USER="admin"
export GEOSERVER_PASSWORD="geoserver"
Windows PowerShell:
$env:GEOSERVER_URL="http://localhost:8080/geoserver"
$env:GEOSERVER_USER="admin"
$env:GEOSERVER_PASSWORD="geoserver"
启动服务器:
如果您要使用 Claude 桌面,则无需执行此步骤。对于游标或您自己的自定义客户端,您应该运行以下代码。
Linux:
source .venv/bin/activate
geoserver-mcp
或者
source .venv/bin/activate
geoserver-mcp --url http://localhost:8080/geoserver --user admin --password geoserver --debug
Windows PowerShell:
.\.venv\Scripts\activate
geoserver-mcp
或者
.\.venv\Scripts\activate
geoserver-mcp --url http://localhost:8080/geoserver --user admin --password geoserver --debug
配置客户端:
如果您使用的是 Claude Desktop,请编辑claude_desktop_config.json如果您使用的是 Cursor,请创建.cursor/mcp.json
视窗:
{
"mcpServers": {
"geoserver-mcp": {
"command": "C:\\path\\to\\geoserver-mcp\\.venv\\Scripts\\geoserver-mcp",
"args": [
"--url",
"http://localhost:8080/geoserver",
"--user",
"admin",
"--password",
"geoserver"
]
}
}
}
Linux:
{
"mcpServers": {
"geoserver-mcp": {
"command": "/path/to/geoserver-mcp/.venv/bin/geoserver-mcp",
"args": [
"--url",
"http://localhost:8080/geoserver",
"--user",
"admin",
"--password",
"geoserver"
]
}
}
}
🛠️ 开发安装
开发安装是为想要修改代码库的贡献者和开发者设计的。此方法适用于:
为项目做出贡献的开发人员
需要修改源代码的用户
测试新功能
调试和开发目的
安装 uv 包管理器。
创建虚拟环境(Python 3.10+):
使用 pip 安装包:
配置GeoServer连接:
Linux/Mac:
export GEOSERVER_URL="http://localhost:8080/geoserver"
export GEOSERVER_USER="admin"
export GEOSERVER_PASSWORD="geoserver"
Windows PowerShell:
$env:GEOSERVER_URL="http://localhost:8080/geoserver"
$env:GEOSERVER_USER="admin"
$env:GEOSERVER_PASSWORD="geoserver"
启动服务器:
如果您要使用 Claude 桌面,则无需执行此步骤。对于游标或您自己的自定义客户端,您应该运行以下代码。
Linux:
source .venv/bin/activate
geoserver-mcp
或者
source .venv/bin/activate
geoserver-mcp --url http://localhost:8080/geoserver --user admin --password geoserver --debug
Windows PowerShell:
.\.venv\Scripts\activate
geoserver-mcp
或者
.\.venv\Scripts\activate
geoserver-mcp --url http://localhost:8080/geoserver --user admin --password geoserver --debug
配置客户端:
如果您使用的是 Claude Desktop,请编辑claude_desktop_config.json如果您使用的是 Cursor,请创建.cursor/mcp.json
视窗:
{
"mcpServers": {
"geoserver-mcp": {
"command": "C:\\path\\to\\geoserver-mcp\\.venv\\Scripts\\geoserver-mcp",
"args": [
"--url",
"http://localhost:8080/geoserver",
"--user",
"admin",
"--password",
"geoserver"
]
}
}
}
Linux:
{
"mcpServers": {
"geoserver-mcp": {
"command": "/path/to/geoserver-mcp/.venv/bin/geoserver-mcp",
"args": [
"--url",
"http://localhost:8080/geoserver",
"--user",
"admin",
"--password",
"geoserver"
]
}
}
}
🛠️ 可用工具
🛠️ 工作区和图层管理
工具 | 描述 |
list_workspaces
| 获取可用的工作空间 |
create_workspace
| 创建新工作区 |
get_layer_info
| 获取详细的图层元数据 |
list_layers
| 列出工作空间中的图层 |
create_layer
| 创建新图层 |
delete_resource
| 删除资源 |
🛠️ 数据操作
工具 | 描述 |
query_features
| 对矢量数据执行 CQL 查询 |
update_features
| 修改要素属性 |
delete_features
| 根据条件删除特征 |
🛠️ 可视化
工具 | 描述 |
generate_map
| 创建样式化的地图图像 |
create_style
| 定义新的 SLD 样式 |
apply_style
| 将现有样式应用于图层 |
🛠️ 客户端开发
如果您计划开发自己的客户端来与 GeoServer MCP 服务器交互,可以从examples/client.py的示例客户端实现中找到灵感。此示例演示了:
如何与 MCP 服务器建立连接
如何发送请求和处理响应
基本错误处理和连接管理
各种工具和操作的使用示例
示例客户端是理解协议和实现您自己的客户端应用程序的良好起点。
另外,这里是使用示例:
列出工作区
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"
}
🔮 计划功能
[ ] 覆盖范围和栅格数据管理
[ ] 安全和访问控制
[ ] 高级造型功能
[ ] WPS处理操作
[ ] GeoWebCache 集成
🤝 贡献
欢迎您贡献力量!您可以通过以下方式提供帮助:
分叉存储库
创建功能分支( git checkout -b feature/AmazingFeature )
提交您的更改( git commit -m 'Add some AmazingFeature' )
推送到分支( git push origin feature/AmazingFeature )
打开拉取请求
请确保您的 PR 描述清晰地描述了问题和解决方案。如适用,请包含相关的问题编号。
📄 许可证
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
🔗 相关项目
📞 支持
如需支持,请打开一个问题
🏆 徽章