NM

nicogis/mcp-server-arcgis-pro-addin

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

53 stars 16 forks 质量 64 趋势 17MIT

配备ArcGIS Pro插件的MCP服务器

概览

本仓库演示如何将 a 与 集成。目标是将 ArcGIS Pro 功能作为 MCP 工具开放,使 GitHub Copilot(代理模式)或任何 MCP 客户端都能与你的 GIS 环境交互。 - (C# with ArcGIS Pro SDK):在 ArcGIS Pro 中运行,并通过本地 IPC 通道(命名管道)暴露 GIS 操作。- (.NET 8 控制台应用):定义 MCP 工具,通过命名管道与插件通信,并在 Visual Studio 中配置为 MCP 服务器,通过 .mcp.json。 这可以让 Copilot(代理模式)直接在 ArcGIS Pro 中查询地图、列出图层、计数特征、缩放图层等功能。 - Visual Studio 2022(支持 MCP 代理模式)- ArcGIS Pro SDK for .NET - ArcGIS Pro 安装(同一台机器)- .NET 8 SDK 该插件启动了 ArcGIS Pro 上的启动。它处理的操作包括:- pro.getActiveMapName - pro.listLayers - pro.countFeatures - pro.zoomToLayer MCP 服务器使用官方的 ModelContextProtocol NuGet 包。 1.

概述(AI 翻译)

本仓库演示如何将模型上下文协议(MCP)服务器与ArcGIS Pro插件集成。目标是将ArcGIS Pro功能作为MCP工具展示,使GitHub Copilot(代理模式)或任何MCP客户端都能与您的GIS环境交互。


概述

  • ArcGIS Pro 插件(C# 搭配 ArcGIS Pro SDK):运行中,使用 ArcGIS Pro 并通过本地 IPC 通道(命名管道)暴露 GIS 操作。
  • MCP 服务器(.NET 8 控制台应用):定义 MCP 工具,通过命名管道与插件通信,并通过 .mcp.json 在 Visual Studio 中配置为 MCP 服务器。

这可以让 Copilot(代理模式)直接在 ArcGIS Pro 中查询地图、列出图层、计数特征、缩放图层等功能。


先修条件

  • Visual Studio 2022 17.14 或更高版本(支持 MCP 代理模式)
  • .NET 版 ArcGIS Pro SDK
  • 安装了ArcGIS Pro(同一台机器)
  • .NET 8 SDK

解答结构


ArcGIS Pro 插件

该插件在ArcGIS Pro启动时启动一个命名管道服务器。它处理以下操作:

  • pro.getActiveMapName
  • pro.listLayers
  • pro.countFeatures
  • pro.zoomToLayer

示例:“模块。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Server with ArcGIS Pro Add-In (C# .NET 8)

This repository demonstrates how to integrate a Model Context Protocol (MCP) server with an ArcGIS Pro Add-In. The goal is to expose ArcGIS Pro functionality as MCP tools so that GitHub Copilot (in Agent mode) or any MCP client can interact with your GIS environment.


Overview

  • ArcGIS Pro Add-In (C# with ArcGIS Pro SDK): runs in-process with ArcGIS Pro and exposes GIS operations through a local IPC channel (Named Pipes).
  • MCP Server (.NET 8 console app): defines MCP tools, communicates with the Add-In via Named Pipes, and is configured as an MCP server in Visual Studio through .mcp.json.

This can allow Copilot (Agent Mode) to query maps, list layers, count features, zoom to layers, and more — directly in ArcGIS Pro.


Prerequisites

  • Visual Studio 2022 17.14 or later (for MCP Agent Mode support)
  • ArcGIS Pro SDK for .NET
  • ArcGIS Pro installed (same machine)
  • .NET 8 SDK

Solution Structure

ArcGisProMcpSample/
+- ArcGisProBridgeAddIn/           # ArcGIS Pro Add-In project (in-process)
¦  +- Config.daml
¦  +- Module.cs
¦  +- ProBridgeService.cs          # Named Pipe server + command handler
¦  +- IpcModels.cs                 # IPC request/response DTOs
+- ArcGisMcpServer/                # MCP server project (.NET 8)
¦  +- Program.cs
¦  +- Tools/ProTools.cs            # MCP tool definitions (bridge client)
¦  +- Ipc/BridgeClient.cs          # Named Pipe client
¦  +- Ipc/IpcModels.cs             # Shared IPC DTOs
+- .mcp.json                       # MCP server manifest for VS Copilot

ArcGIS Pro Add-In

The Add-In starts a Named Pipe server on ArcGIS Pro launch. It handles operations like:

  • pro.getActiveMapName
  • pro.listLayers
  • pro.countFeatures
  • pro.zoomToLayer

Example: Module.cs (in sample is in a button)

protected override bool Initialize()
{
    _service = new ProBridgeService("ArcGisProBridgePipe");
    _service.Start();
    return true; // initialization successful
}

protected override bool CanUnload()
{
    _service?.Dispose();
    return true;
}

Example: ProBridgeService handler

case "pro.countFeatures":
{
    if (req.Args == null ||
        !req.Args.TryGetValue("layer", out string? layerName) ||
        string.IsNullOrWhiteSpace(layerName))
        return new(false, "arg 'layer' required", null);

    int count = await QueuedTask.Run(() =>
    {
        var fl = MapView.Active?.Map?.Layers
            .OfType()
            .FirstOrDefault(l => l.Name.Equals(layerName, StringComparison.OrdinalIgnoreCase));
        if (fl == null) return 0;
        using var fc = fl.GetFeatureClass();
        return (int)fc.GetCount();
    });

    return new(true, null, new { count });
}

MCP Server (.NET 8)

The MCP server uses the official ModelContextProtocol NuGet package.

Program.cs

await Host.CreateDefaultBuilder(args)
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →