Skip to main content
Glama
GeoServer MCP Server

GeoServer MCP Server

by mahdin75

GeoServer MCP 服务器

阿尔法

0.4.0(Alpha)版本正在积极开发中,即将发布。我们欢迎开发者贡献代码,共同构建这个项目。

🎥 演示

Related MCP server: QGISMCP

📋 目录

🚀 功能

  • 🔍 查询和操作 GeoServer 工作区、图层和样式

  • 🗺️ 对矢量数据执行空间查询

  • 🎨 生成地图可视化

  • 🌐 访问符合 OGC 标准的 Web 服务(WMS、WFS)

  • 🛠️ 轻松与 MCP 兼容客户端集成

📋 先决条件

  • Python 3.10 或更高版本

  • 运行启用 REST API 的 GeoServer 实例

  • MCP 兼容客户端(如 Claude Desktop 或 Cursor)

  • 用于软件包安装的互联网连接

🛠️ 安装

选择最适合您需要的安装方法:

🛠️ 安装(Docker)

Docker 安装是运行 GeoServer MCP 服务器最快捷、最独立的安装方式。它非常适合:

  • 快速测试和评估

  • 生产部署

  • 想要避免 Python 依赖的环境

  • 跨不同系统的一致部署

  1. 运行 geoserver-mcp:

docker pull mahdin75/geoserver-mcp
docker run -d mahdin75/geoserver-mcp
  1. 配置客户端:

如果您使用的是 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+ 的系统

  • 想要自定义服务器配置的用户

  • 开发和测试目的

  1. 安装 uv 包管理器。

pip install uv
  1. 创建虚拟环境(Python 3.10+):

Linux/Mac:

uv venv --python=3.10

Windows PowerShell:

uv venv --python=3.10
  1. 使用 pip 安装包:

uv pip install geoserver-mcp
  1. 配置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"
  1. 启动服务器:

如果您要使用 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
  1. 配置客户端:

如果您使用的是 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"
      ]
    }
  }
}

🛠️ 开发安装

开发安装是为想要修改代码库的贡献者和开发者设计的。此方法适用于:

  • 为项目做出贡献的开发人员

  • 需要修改源代码的用户

  • 测试新功能

  • 调试和开发目的

  1. 安装 uv 包管理器。

pip install uv
  1. 创建虚拟环境(Python 3.10+):

uv venv --python=3.10
  1. 使用 pip 安装包:

uv pip install -e .
  1. 配置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"
  1. 启动服务器:

如果您要使用 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
  1. 配置客户端:

如果您使用的是 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 集成

🤝 贡献

欢迎您贡献力量!您可以通过以下方式提供帮助:

  1. 分叉存储库

  2. 创建功能分支( git checkout -b feature/AmazingFeature )

  3. 提交您的更改( git commit -m 'Add some AmazingFeature' )

  4. 推送到分支( git push origin feature/AmazingFeature )

  5. 打开拉取请求

请确保您的 PR 描述清晰地描述了问题和解决方案。如适用,请包含相关的问题编号。

📄 许可证

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

🔗 相关项目

📞 支持

如需支持,请打开一个问题

🏆 徽章

Available Tools

9 tools
create_layerC

Create a new layer in GeoServer.

Args:
    workspace: The workspace for the new layer
    layer: The name of the layer to create
    data_store: The data store to use
    source: The source data (file, table name, etc.)

Returns:
    Dict with status and layer information

Inputs: data_store (required), layer (required), source (required), workspace (required).

create_styleB

Create a new SLD style in GeoServer.

Args:
    name: Name for the style
    sld: SLD XML content
    workspace: Optional workspace for the style

Returns:
    Dict with status and style information

Inputs: name (required), sld (required), workspace.

create_workspaceC

Create a new workspace in GeoServer.

Args:
    workspace: Name of the workspace to create

Returns:
    Dict with status and result information

Inputs: workspace (required).

delete_resourceC

Delete a resource from GeoServer.

Args:
    resource_type: Type of resource to delete (workspace, layer, style, etc.)
    workspace: The workspace containing the resource
    name: The name of the resource

Returns:
    Dict with status and result information

Inputs: name (required), resource_type (required), workspace (required).

generate_mapB

Generate a map image using WMS GetMap.

Args:
    layers: List of layers to include (format: workspace:layer)
    styles: Optional styles to apply (one per layer)
    bbox: Bounding box [minx, miny, maxx, maxy]
    width: Image width in pixels
    height: Image height in pixels
    format: Image format (png, jpeg, etc.)

Returns:
    Dict with map information and URL

Inputs: layers (required), bbox, format, height, +2 more.

get_layer_infoC

Get detailed information about a layer.

Args:
    workspace: The workspace containing the layer
    layer: The name of the layer

Returns:
    Dict with layer metadata

Inputs: layer (required), workspace (required).

list_layersB

List layers in GeoServer, optionally filtered by workspace.

Args:
    workspace: Optional workspace to filter layers

Returns:
    List of layer information dictionaries

Inputs: workspace.

list_workspacesB

List available workspaces in GeoServer.

Inputs: no named parameters.

query_featuresB

Query features from a vector layer using CQL filter.

Args:
    workspace: The workspace containing the layer
    layer: The layer to query
    filter: Optional CQL filter expression
    properties: Optional list of properties to return
    max_features: Maximum number of features to return

Returns:
    GeoJSON FeatureCollection with query results

Inputs: layer (required), workspace (required), filter, max_features, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no ambiguity. The tools cover different operations like creation (create_layer, create_style, create_workspace), deletion (delete_resource), retrieval (get_layer_info, list_layers, list_workspaces), querying (query_features), and visualization (generate_map). There is no overlap in functionality.

    Naming Consistency5/5

    Tool names follow a consistent verb_noun pattern throughout, using snake_case. All tools start with a clear action verb (create, delete, generate, get, list, query) followed by a specific noun, making them predictable and readable.

    Tool Count5/5

    With 9 tools, this server is well-scoped for managing a GeoServer instance. It covers essential operations for workspaces, layers, styles, and maps without being overly complex or too sparse, making it efficient for agents to handle geospatial data tasks.

    Completeness4/5

    The tool set provides comprehensive coverage for core GeoServer operations, including CRUD for layers, styles, and workspaces, along with querying and map generation. A minor gap exists in updating resources (e.g., update_layer or update_style), but agents can work around this by deleting and recreating.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      A server that enables Large Language Models to discover and interact with REST APIs defined by OpenAPI specifications through the Model Context Protocol.
      12,706 npm
      302
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that connects Claude AI to QGIS, enabling direct interaction with the GIS software for project creation, layer manipulation, code execution, and processing algorithms through natural language prompts.
      15
      10
      Creative Commons Zero v1.0 Universal
    • A
      license
      C
      quality
      D
      maintenance
      A Model Context Protocol server that connects LLMs to GIS operations, enabling AI assistants to perform accurate geospatial analysis including geometric operations, coordinate transformations, and spatial measurements.
      87
      208
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A server application that provides PostGIS database connection using Model Context Protocol (MCP), enabling spatial database functionality through natural language interactions.
      22
      21
      ISC