npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ic-connector-mcp-server

v0.1.1

Published

MCP server for Information Connector

Readme

IC Connector MCP Server

一个可直接在 VS Code 中使用的 MCP 服务,提供 connector、data source 与 data source tags 的查询、创建、删除工具。

结构

当前仓库同时支持两种接入方式:

  • stdio:由 VS Code 直接拉起本地进程

  • http:由 MCP client 通过 HTTP URL 访问 MCP 服务

  • server.jssrc/:MCP server 主体与工具逻辑

  • .vscode/mcp.http-template.json:VS Code 工作区的 MCP server http 接入方式配置

  • .vscode/mcp.stdio-template.json:VS Code 工作区的 MCP server stdio 接入方式配置 - 本地开发推荐这种方式修改文件名为 mcp.json 直接拉起服务

  • Dockerfile:容器镜像构建文件

常用命令:

npm install
npm run start:http

功能

  • 同时支持 MCP stdiostreamable HTTP 传输。
  • 访问接口:
    • deployables 列表:/common-configurator/api/connector-configurator/odi/connector/deployables
    • adapters 列表:/common-configurator/api/ioit-core/data-service/DataService/Adapters
    • entitytypes 列表:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/entitytypes
    • root asset:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/assets/root
    • 创建 entity:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/entities
    • 修改 entity:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/entities/{entityAnchor}
    • 删除 entity:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/entities/{entityAnchor}
    • 批量新增 entity attribute:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/bulk?_atomic=false&_uniqueDisplayName=true
    • attribute 列表:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/attributes
    • attribute 历史值:/common-configurator/api/ioit-core/data-service/DataService/Data
    • attribute 数据统计:/common-configurator/api/ioit-core/data-service/DataService/Data/{id}/Count
    • dataDestination 列表:/common-configurator/api/ioit-core/data-service/DataService/DataDestination
    • entity 列表:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/treeitems
    • entity 详情:/common-configurator/api/ioit-core/data-service/DataService/anchor-ex/v1/treeitems/{entityAnchor}/entity
    • 已创建 connector 列表:/common-configurator/api/connector-configurator/connector-info/schema-files
    • connector 新增:/common-configurator/api/connector-configurator/odi/connector
    • connector 删除:/common-configurator/api/connector-configurator/odi/connector?connectorId=...
    • connector 发布:/common-configurator/api/connector-configurator/runtime/deployRequest
    • data source 新增:/common-configurator/api/connector-configurator/api/insert-ds
    • data source 编辑:/common-configurator/api/connector-configurator/api/edit-ds
    • connector-level restore:/common-configurator/api/connector-configurator/api/connector-level-restore
    • data source tag 新增:/common-configurator/api/connector-configurator/api/insert-tag
    • data source 列表:/common-configurator/api/connector-configurator/api/all-datasources
    • data source/tag 统计:/common-configurator/api/connector-configurator/api/tag-count
    • data source tags 列表:/common-configurator/api/connector-configurator/api/filtered-tags
    • data source tags 删除:/common-configurator/api/connector-configurator/api/delete-selected-tag
    • data source 删除:/common-configurator/api/connector-configurator/api/delete-selected-ds
  • 仅支持静默 Session 登录:先调用登录接口拿 Cookie/Token,再访问业务接口。
  • HTTP MCP 服务本身不做认证,客户端可直接访问 MCP URL。
  • 可选支持通过请求 header 传递 MCP token 做校验:默认读取 Authorization: Bearer <token>,可通过 MCP_AUTH_HEADERMCP_AUTH_SCHEMEMCP_AUTH_TOKENMCP_AUTH_REQUIRED 调整。
  • MCP 访问后端业务系统时使用启动服务时配置的账号密码。
  • 支持可选过滤:component_typeconnection_type
  • 会话请求优先使用 Cookie,失败时自动回退 Bearer Token。
  • 会话模式支持静默登录与缓存:
    • 调用前若本地无会话,自动登录
    • 若返回未登录状态(如 401/403),自动重新登录并重试一次

MCP 工具

  • list_deployables_images
    • 查询可用 deployables(可按 component_typeconnection_type 过滤)
  • list_entity_types
    • 查询 entitytypes 列表(调用 entitytypes 接口)
    • 参数:offsettakerecursiveinclude_baseconcepts(均可选)
    • 默认参数:offset=0take=100recursive=falseinclude_base=trueconcepts=asset
  • list_adapters
    • 查询 Adapters 列表(调用 DataService/Adapters 接口)
    • 无参数
  • list_adapter_tags
    • 查询指定 adapter 下的 tags(调用 DataService/Adapters/{adapterId}/browse
    • 参数:adapter_idadapter_name(二选一,优先使用 adapter_id
    • 当只传 adapter_name 时,会先调用 list_adapters,按名称精确匹配,精确匹配不到时退化为忽略大小写的包含匹配;若匹配到多个 adapter 会直接报错,避免误取
  • find_entity_types_by_name
    • 按名称查询 entitytypes 列表(调用 entitytypes 接口并追加 namefilter
    • 参数:entity_type_name(必填,例如 anchor.asset-base)、offsettakerecursiveinclude_baseconcepts(其余均可选)
    • 会自动把 entity_type_name 映射为 namefilter=*<entity_type_name>*
  • get_root_asset
    • 获取 root asset(调用 assets/root 接口)
    • 无参数
  • create_entity
    • 创建 entity(调用 entities 接口)
    • 会自动解析 _parent:优先使用传入的 parent_anchor,否则调用 get_root_asset 取 root asset 的 $anchor
    • 会自动解析 $type:优先使用传入的 type_anchor,否则使用 entity_type_name 查询 entitytypes;默认 entity_type_name=anchor.asset-base
    • 参数:entity_nameconceptdisplayname_jsonparent_anchortype_anchorentity_type_nameconceptsinclude_pathauto_attributesauto_aggregated_entities
    • 默认值:entity_name=enity-<UUID前8位>concept=assetinclude_path=trueauto_attributes=Allauto_aggregated_entities=All
  • edit_entity
    • 修改 entity(调用 entities/{entityAnchor} PATCH 接口)
    • 优先使用 entity_anchor;如果未传,可通过 current_entity_name 结合 view_point 解析 entity
    • 未传入的新字段会保留当前 entity 详情中的现有值
    • 参数:entity_anchorcurrent_entity_nameview_pointentity_namedisplayname_jsonconcepttype_anchorentity_type_nameconceptsinclude_pathauto_attributes
    • 默认值:include_path=trueauto_attributes=all
  • delete_entity
    • 删除 entity(调用 entities/{entityAnchor} DELETE 接口)
    • 优先使用 entity_anchor;如果未传,可通过 entity_name 结合 view_point 解析 entity
    • 参数:entity_anchorentity_nameview_pointrecursive
    • 默认值:recursive=true
    • 删除成功以返回状态码 204 为准
  • list_entities
    • 获取 entity 列表(调用 treeitems 接口)
    • 会自动解析 _viewPoint:优先使用传入的 view_point,否则调用 get_root_asset 取 root asset 的 $anchor
    • 参数:view_pointoffsettakeinclude_has_children
    • 默认值:offset=0take=300include_has_children=true
  • find_entities_by_name
    • 按名称过滤 entity 列表(调用 treeitems 接口并追加 namefilter
    • 会自动解析 _viewPoint:优先使用传入的 view_point,否则调用 get_root_asset 取 root asset 的 $anchor
    • 参数:entity_nameview_pointoffsettakeinclude_has_children
    • 默认值:offset=0take=100include_has_children=true
    • 会自动把 entity_name 映射为 namefilter=*<entity_name>*
  • find_attributes_by_name
    • 按名称过滤指定 entity 下的 attributes(调用 attributes 接口并追加 namefilter
    • 参数:attribute_nameowner_anchoroffsettakeinclude_state
    • 默认值:offset=0take=100include_state=true
    • 会自动把 attribute_name 映射为 namefilter=*<attribute_name>*
    • owner_anchor 会映射到查询参数 _owner
  • get_attribute_values
    • 查询一个或多个 attribute 在指定时间区间内的所有值(调用 DataService/Data 接口)
    • 参数:attribute_anchorattribute_anchorsfromtoorder
    • attribute_anchorattribute_anchors 至少传一个,最终都会映射到查询参数 variableIds
    • 默认值:order=Descending
    • fromto 都未传时,默认查询最近一个小时的数据
    • 当只传 from 时,to 默认取当前时间;当只传 to 时,from 默认取 to 之前一个小时
  • count_attribute_data
    • 统计单个 attribute 在指定时间区间内的数据量(调用 DataService/Data/{id}/Count 接口)
    • 参数:attribute_idattribute_nameowner_anchorfromto
    • 优先使用 attribute_id;如果只传 attribute_name,会先调用 attributes 接口解析 id
    • 名称解析规则:优先按名称大小写不敏感的精确匹配,匹配不到时退化为包含匹配;若匹配到多个 attribute 会直接报错,避免误统计
    • owner_anchor 仅在按 attribute_name 解析时用于缩小范围,映射到查询参数 _owner
    • fromto 都未传时,默认查询最近一个小时的数据
    • 当只传 from 时,to 默认取当前时间;当只传 to 时,from 默认取 to 之前一个小时
  • list_data_destinations
    • 查询 DataDestination 列表(调用 DataService/DataDestination 接口)
    • 参数:nametypeactiveconnected(均可选)
    • nametype 使用忽略大小写的包含匹配;activeconnected 使用布尔精确匹配
  • create_data_destination
    • 创建 genericmqtt 类型的 DataDestination(调用 DataService/DataDestination POST 接口)
    • 参数:mqtt_hostmqtt_portmqtt_usernamemqtt_password(必填),name(可选)
    • 默认值:name=mqtt_<UUID前8位>type=genericmqttactive=true
    • 固定配置:mqttProtocol=tcpqos=1mqttMaxPackageSend=100mqttMaxPackageSize=256authSelector=user_pwadvancedSettings=false
    • 工具结果中的 requestPayload.config.mqttPassword 会被脱敏显示
  • delete_data_destination
    • 删除 DataDestination(调用 DataService/DataDestination/{id} DELETE 接口)
    • 参数:data_destination_id(推荐)或 name(可选)
    • 当只传 name 时,会先调用 list_data_destinations 解析 ID;优先精确匹配名称,匹配不到时退化为忽略大小写的包含匹配
    • 若按名称匹配到多个结果,会直接报错并要求显式传 data_destination_id
  • get_entity_by_anchor
    • 按 anchor 获取单个 entity 详情(调用 treeitems/{entityAnchor}/entity 接口)
    • 参数:entity_anchor(必填)
  • add_tags_to_entity_attributes
    • 先解析 entity,再解析 adapter,并通过 Adapters/{adapterId}/browse 查询 tags,最后调用 anchor-ex/v1/bulk 将选中的 tags 批量加到 entity 的 attributes 下
    • entity 解析规则:优先使用 entity_anchor;如果只传 entity_name,会按名称查找 entity 并取其 $anchor
    • adapter 解析规则:优先使用 adapter_id;如果只传 adapter_name,会先调用 list_adapters 解析 adapter
    • tag 解析规则:通过 browse 接口返回的 tags 数组按 tagName 精确匹配,忽略大小写;若有重名或找不到会报错,避免误加
    • $datatype 会根据 browse tag 的 dataType 自动映射:Bool -> boolUInt8 -> uint8Int8 -> int8UInt16 -> uint16Int16 -> int16UInt32 -> uint32Int32 -> int32UInt64 -> uint64Int64 -> int64Float -> float32Double -> float64String -> string
    • $_bulkIndex$_bulkId 会按匹配到的 tag 顺序从 0 递增
    • $name 使用随机生成格式 generated_name-<32位十六进制UUID>$displayname["xx-XX"] 使用 browse tag 的 tagName
    • 参数:entity_anchorentity_nameview_pointadapter_idadapter_nametag_nametag_namesatomicunique_display_namepreview_only
    • 默认值:atomic=falseunique_display_name=truepreview_only=false
  • list_connector_instances
    • 查询已创建 connector 列表(来自 schema-files 接口)
    • 参数:include_errored_schemas(可选,默认 false
  • create_connector
    • 先读取 list_deployables_images 的结果,自动选择可用 connectorImage 并创建
    • 参数:
      • deployable_name(可选)
      • component_type(可选,例如 connectormiddleware
      • connection_type(可选)
      • connector_image(可选,list_deployables_images 返回项中的 image 精确值)
      • connector_name(可选,不传则自动生成有意义的名称)
  • delete_connector
    • 删除 connector
    • 参数:
      • connector_id(推荐)
      • connector_name(可选,不传 connector_id 时用于自动解析)
  • deploy_connector
    • 发布 connector(调用 runtime/deployRequest
    • 参数:
      • connector_id(推荐)
      • connector_name(可选,不传 connector_id 时用于自动解析)
      • is_cs_driver(可选,默认 false
      • is_empty_data_source_deploy(可选,默认 false
      • deploy_targets(可选,默认 ["ONE_DI_DEPLOY"]
  • create_data_source
    • 创建 data source(调用 insert-ds
    • 参数:
      • connector_id(可选,推荐)
      • connector_name(可选,不传 connector_id 时用于通过 list_connector_instances 自动解析)
      • ds_name(可选,不传则自动生成 plc_<UUID前8位>
      • ds_info(可选,JSON 对象;用于直接传入 connector-specific 的 dsInfo 字段)
      • ds_info_json(可选,JSON 对象字符串;用途同上)
      • 兼容字段(可选):remote_urlusernamepasswordplc_typeupload_typesecurity_modesecurity_policysecurity_certsecurity_keyident_certident_keydeviceaddressportrackslotconnecttimeoutsendtimeoutrecvtimeout
      • dsInfo 会根据 connector schema 中 datasourceProps.parameters.childrenProps[].id 动态生成,不再按 OPC UA/S7 driver 固定分支生成
      • dsInfo.plcType 固定自动填充为 connector 详情中命中的 plcDetails[].plcType
      • dsInfo.uploadType 固定为 manual
      • 对于 schema 中 required=true 的字段:必须提供值
      • 对于 schema 中非必填字段:若未提供值且存在 default(或 checked)则自动使用默认值,否则按字段类型补空值(例如字符串为空串、数组为空数组)
      • name 仍会自动与 ds_name 保持一致
      • is_edit 可选,默认 false
  • edit_data_source
    • 编辑已有 data source(调用 edit-ds
    • 参数:
      • ds_id(必填)
      • connector_id(可选,推荐)
      • connector_name(可选,不传 connector_id 时用于通过 list_connector_instances 自动解析)
      • ds_name(可选,不传时优先尝试通过 list_data_sourcesds_id 自动解析)
      • OPC UA 类型可选字段:remote_urlusernamepasswordplc_typeupload_typesecurity_modesecurity_policysecurity_certsecurity_keyident_certident_key
      • S7 driver 类型可选字段:deviceaddressportrackslotconnecttimeoutsendtimeoutrecvtimeout,同时也支持 plc_typeupload_type
      • 未显式传入的字段会优先保留现有 data source 的 dsInfo 值,不再按 OPC UA 固定字段覆盖其他 connector 类型配置
      • isEdit 固定为 true
  • restore_connector_level
    • 执行 connector-level restore(调用 connector-level-restore
    • 参数:
      • connector_id(可选,推荐)
      • connector_name(可选,不传 connector_id 时用于自动解析)
      • schema_uri(可选,不传时自动从 connector detail 中的 plcId/plcDetails 解析)
      • file_path(可选,本地文件路径,stdio 模式推荐)
      • file_base64(可选,base64 文件内容,HTTP MCP 客户端推荐)
      • file_name(可选,上传文件名;当使用 file_base64 时必填)
      • export_version(可选,默认不传值)
    • 固定请求字段:useConfigConverter=falseisMultipleConnectors=false
    • 上传方式建议:
      • MCP stdio:优先传 file_path,MCP 进程直接读取本机文件
      • MCP http:优先传 file_base64 + file_name,避免客户端与服务端文件系统不一致
  • list_data_sources
    • 查询所有 data source(调用 all-datasources
    • 参数:connector_idconnector_nameds_nameselected_only(均可选)
  • get_tag_count
    • 统计所有 data source 下的 tag 数量及 data source 数量(调用 tag-count
    • 无参数
    • 返回中 tagCount 为各个 data source 的 tag 数量,totalCount 为全部 tag 总数
    • 返回中 dscount 为各个 data source 统计项,totalDatasource 为全部 data source 总数
  • create_data_source_tag
    • 在指定 Data Source 下新增 tag(调用 insert-tag
    • 参数:
      • connector_id(必填)
      • ds_id(必填)
      • name(必填,同时会作为 tag_name
      • data_type(必填,仅支持固定枚举值)
      • address_string(必填)
      • array_dimensions(可选,默认 []
      • access_mode(可选,默认 r
      • acquisition_cycle(可选,默认 1000
  • delete_data_source
    • 删除一个或多个 data source(调用 delete-selected-ds
    • 参数:
      • ds_ids(可选,数组,推荐)
      • ds_id(可选,单个 ID)
      • ds_name(可选,不传 ds_ids/ds_id 时用于自动解析)
      • connector_idconnector_name(可选,按名称解析时用于缩小范围)
  • list_data_source_tags
    • 查询 Data Source 的 tags 列表(调用 filtered-tags
    • 参数:
      • connector_id(必填)
      • datasource_id(必填)
      • start(可选,默认 0
      • end(可选,默认 3000
      • filters_json(可选,JSON 数组字符串;不传使用默认过滤字段)
      • ds_info_json(可选,JSON 对象字符串;不传使用 {\"<datasource_id>\":0}
  • delete_data_source_tags
    • 删除 Data Source 下的一个或多个 tags(调用 delete-selected-tag
    • 参数:
      • connector_id(必填)
      • datasource_id(必填)
      • tag_ids(可选,数组,推荐)
      • tag_id(可选,单个 tag ID)
  • delete_data_source_tags_by_filter
    • 先查询 Data Source 的 tags,再按名称或过滤条件匹配后删除
    • 参数:
      • connector_id(必填)
      • datasource_id(必填)
      • tag_name(可选,按 tag 名精确匹配,忽略大小写)
      • tag_names(可选,按多个 tag 名精确匹配,忽略大小写)
      • name_contains(可选,按 tag 名模糊匹配,忽略大小写)
      • match_json(可选,JSON 对象字符串;对 namedata_typearray_dimensionsaddress_stringaccess_modeacquisition_cycle 等字段做本地匹配,其中字符串值按忽略大小写包含匹配)
      • filters_jsonds_info_jsonstartend(可选,先透传给 filtered-tags 接口缩小返回范围)
      • delete_all_listed(可选,若为 true,删除当前查询结果中解析出的全部 tags)
      • preview_only(可选,若为 true,仅返回匹配结果,不执行删除)

安装

npm install

在 VS Code 中使用

已提供工作区配置:.vscode/mcp.json

HTTP 模式:

  1. 用环境变量或启动参数启动 HTTP 服务。 如需启用 MCP token 校验,可额外设置:MCP_AUTH_REQUIRED=trueMCP_AUTH_TOKEN=<your-token>。 默认从 Authorization: Bearer <your-token> 读取;也可改成自定义 header,例如 MCP_AUTH_HEADER=x-mcp-token
  2. 在 VS Code 打开当前工作区。
  3. 确认 .vscode/mcp.json 中的 url 已填写正确。
  4. 如需在 HTTP 模式下为每个 MCP client 单独指定业务系统账号/地址,可在 .vscode/mcp.json 的 server headers 中传入:
{
  "servers": {
    "ic-mcp": {
      "type": "http",
      "url": "http://192.168.255.195:3000/mcp",
      "headers": {
        "X-Base-Url": "https://your-target-api.com",
        "X-App-Username": "your_username",
        "X-App-Password": "your_password"
      }
    }
  }
}

headers 中这 3 个字段均为可选;传了就覆盖环境变量中的同名配置,不传则继续使用服务启动时的环境变量/启动参数。

  1. 打开命令面板执行 MCP: List Servers,连接 ic-connector-configurator

stdio 模式:

  1. .vscode/mcp.json 改回 stdio 配置。
  2. env 中填写 BASE_URLAPI_USERNAMEAPI_PASSWORD
  3. 打开命令面板执行 MCP: List Servers,由 VS Code 直接拉起本地进程。

连接成功后,在 Chat 中可直接调用工具,例如:

调用 list_deployables_images,查询所有可用 connector 镜像。

或者带过滤参数:

调用 list_deployables_images,参数 component_type=connector, connection_type=opc-ua

环境变量

HTTP MCP 服务参数

  • MCP_TRANSPORT:传输模式,stdiohttp(默认 stdio
  • MCP_HTTP_HOST:HTTP 监听地址(默认 127.0.0.1
  • MCP_HTTP_PORT:HTTP 监听端口(默认 3000
  • MCP_HTTP_PATH:HTTP MCP 路径(默认 /mcp

HTTP 请求头覆盖(仅 HTTP 模式)

可在 MCP client(如 VS Code 的 .vscode/mcp.json)里通过以下 header 覆盖业务系统配置:

  • X-Base-Url:覆盖 BASE_URL
  • X-App-Username:覆盖 API_USERNAME
  • X-App-Password:覆盖 API_PASSWORD

优先级说明:

  • 当请求头中存在上述字段且值非空时,优先使用请求头值。
  • 未传的字段继续使用服务进程中的环境变量或启动参数值。
  • 该覆盖只影响当前 MCP HTTP 会话,不影响其他会话。

业务系统访问参数

最小必填参数:

  • BASE_URL

  • API_USERNAME

  • API_PASSWORD

  • ENV_TYPE(可选,默认 k8s,支持 k8s/ied,大小写不敏感)

  • BASE_URL:基础地址(默认 https://192.168.10.130:9877

  • CONNECTOR_DEPLOYABLES_API_PATH:deployables 接口 path

  • CONNECTOR_SCHEMA_FILES_PATH:已创建 connector 列表接口 path

  • CONNECTOR_CREATE_PATH:connector 创建接口 path

  • CONNECTOR_DELETE_PATH:connector 删除接口 path

  • CONNECTOR_DEPLOY_REQUEST_PATH:connector 发布接口 path

  • CONNECTOR_INSERT_DS_PATH:data source 创建接口(insert-ds)path

  • CONNECTOR_EDIT_DS_PATH:data source 编辑接口(edit-ds)path

  • CONNECTOR_LEVEL_RESTORE_PATH:connector-level restore 接口 path

  • CONNECTOR_INSERT_TAG_PATH:data source tag 创建接口(insert-tag)path

  • CONNECTOR_ALL_DATASOURCES_PATH:data source 列表接口(all-datasources)path

  • CONNECTOR_TAG_COUNT_PATH:data source/tag 统计接口(tag-count)path

  • CONNECTOR_FILTERED_TAGS_PATH:data source tags 列表接口(filtered-tags)path

  • CONNECTOR_DELETE_SELECTED_TAG_PATH:data source tags 删除接口(delete-selected-tag)path

  • CONNECTOR_DELETE_SELECTED_DS_PATH:data source 删除接口(delete-selected-ds)path

  • ENTITY_TYPES_PATH:entitytypes 列表接口 path

  • ADAPTERS_PATH:Adapters 列表接口 path

  • ROOT_ASSET_PATH:root asset 接口 path

  • CREATE_ENTITY_PATH:创建 entity 接口 path

  • EDIT_ENTITY_PATH:修改 entity 接口 path

  • DELETE_ENTITY_PATH:删除 entity 接口 path

  • ENTITY_BULK_PATH:批量新增 entity attribute 接口 path

  • ATTRIBUTES_PATH:attribute 列表接口 path

  • ATTRIBUTE_DATA_PATH:attribute 历史值接口 path

  • TREE_ITEMS_PATH:entity 列表接口 path

  • TREE_ITEM_ENTITY_SUFFIX:entity 详情接口后缀,默认 /entity

  • LOGIN_PATH:登录接口 path(默认 /users/api/login

  • CONNECTOR_API_URL:完整 deployables URL(可选,优先级高于 BASE_URL + CONNECTOR_DEPLOYABLES_API_PATH

  • CONNECTOR_SCHEMA_FILES_URL:完整 schema-files URL(可选)

  • CONNECTOR_CREATE_URL:完整创建 connector URL(可选)

  • CONNECTOR_DELETE_URL:完整删除 connector URL(可选)

  • CONNECTOR_DEPLOY_REQUEST_URL:完整发布 connector URL(可选)

  • CONNECTOR_INSERT_DS_URL:完整创建 data source URL(可选)

  • CONNECTOR_EDIT_DS_URL:完整编辑 data source URL(可选)

  • CONNECTOR_LEVEL_RESTORE_URL:完整 connector-level restore URL(可选)

  • CONNECTOR_INSERT_TAG_URL:完整创建 data source tag URL(可选)

  • CONNECTOR_ALL_DATASOURCES_URL:完整 data source 列表 URL(可选)

  • CONNECTOR_TAG_COUNT_URL:完整 data source/tag 统计 URL(可选)

  • CONNECTOR_FILTERED_TAGS_URL:完整 data source tags 列表 URL(可选)

  • CONNECTOR_DELETE_SELECTED_TAG_URL:完整 data source tags 删除 URL(可选)

  • CONNECTOR_DELETE_SELECTED_DS_URL:完整 data source 删除 URL(可选)

  • ENTITY_TYPES_URL:完整 entitytypes 列表 URL(可选)

  • ADAPTERS_URL:完整 Adapters 列表 URL(可选)

  • ROOT_ASSET_URL:完整 root asset URL(可选)

  • CREATE_ENTITY_URL:完整创建 entity URL(可选)

  • EDIT_ENTITY_URL:完整修改 entity URL(可选)

  • DELETE_ENTITY_URL:完整删除 entity URL(可选)

  • ENTITY_BULK_URL:完整批量新增 entity attribute URL(可选)

  • ATTRIBUTES_URL:完整 attribute 列表 URL(可选)

  • ATTRIBUTE_DATA_URL:完整 attribute 历史值 URL(可选)

  • TREE_ITEMS_URL:完整 entity 列表 URL(可选)

  • API_USERNAME:用户名(默认 admin

  • API_PASSWORD:密码(默认 admin

  • ENV_TYPE:环境类型(默认 k8s

    • k8s:保持现有认证逻辑(登录 URL 为 CONNECTOR_LOGIN_URLBASE_URL + LOGIN_PATH,请求优先 Cookie,失败回退 Bearer)
    • ied:登录 URL 固定为 BASE_URL + /device/edge/api/v2/login/direct,登录 body 使用 API_USERNAME/API_PASSWORD 映射到 username/password;后续 API 认证统一使用请求头 Cookie: authToken=<accessToken>
  • CONNECTOR_LOGIN_URL:完整登录 URL(可选,优先级高于 BASE_URL + LOGIN_PATH

  • LOGIN_USERNAME_FIELD:登录接口用户名字段名(默认 username

  • LOGIN_PASSWORD_FIELD:登录接口密码字段名(默认 password

  • LOGIN_TOKEN_FIELD:登录返回体里的 token 字段名(默认 Access

  • ALLOW_INSECURE_TLS:是否忽略 HTTPS 证书校验(默认 true,内网自签名证书常见)

  • HTTP_TIMEOUT_MS:请求超时时间,毫秒(默认 30000

如果 MCP HTTP 服务是跑在 Docker 里,而工具调用时报类似 timeout of 10000ms exceeded 或超时错误,这通常不是 mcp.json 的问题,而是 MCP 服务访问后端业务接口超时。优先检查:

  • 容器内的 BASE_URLAPI_USERNAMEAPI_PASSWORD 是否配置正确
  • 容器网络是否能访问后端地址和端口
  • 后端接口本身是否响应较慢;必要时提高 HTTP_TIMEOUT_MS

使用方式:

  1. stdio 模式下,先修改环境变量 BASE_URLAPI_USERNAMEAPI_PASSWORD,按需设置 ENV_TYPE
  2. http 模式下,可在启动服务时通过环境变量或命令行参数传入 BASE_URLAPI_USERNAMEAPI_PASSWORD(全局默认值)。
  3. http 模式下,也可在 MCP client 的 mcp.json 里通过 headersX-Base-UrlX-App-UsernameX-App-Password(按会话覆盖默认值)。

启动参数示例:

node server.js --mcp-transport=http --env-type=ied --base-url=https://your-base-url:9877 --api-username=your-username --api-password=your-password

或者:

MCP_TRANSPORT=http ENV_TYPE=ied BASE_URL=https://your-base-url:9877 API_USERNAME=your-username API_PASSWORD=your-password node server.js

批量将 browse 出来的 tags 添加到 entity attribute 的调用示例:

调用 add_tags_to_entity_attributes,参数 entity_name=opcua-nats, adapter_name=opcua, tag_name=lam_int8

如果要一次添加多个 tag:

调用 add_tags_to_entity_attributes,参数 entity_name=opcua-nats, adapter_name=opcua, tag_names=["tg1","tg2"]

本地运行(非 VS Code)

npm start

如果你要以 HTTP 方式运行:

npm run start:http

如果你希望在启动命令里直接传后端账号密码,可以这样运行:

npm run start:http:example

默认监听地址:http://127.0.0.1:3000/mcp

Docker 运行

构建镜像:

docker build -t ic-connector-mcp-server .

启动容器:

# Run temporarily
docker run --rm -p 3000:3000 \
  -e BASE_URL=https://192.168.10.130:9877 \
  -e API_USERNAME=admin \
  -e API_PASSWORD=admin \
  -e ENV_TYPE=k8s \
  ic-connector-mcp-server

# Background daemon
docker run --name ic-mcp -p 3000:3000 \
  -e BASE_URL=https://hmi-playground.cn1-int.edge.cloud-siemens.cn \
  -e API_USERNAME=admin \
  -e API_PASSWORD=admin \
  -e ENV_TYPE=k8s \
  -d ic-connector-mcp-server

docker run --name ic-mcp -p 3000:3000 \
  -e BASE_URL=https://10.8.4.19 \
  -e API_USERNAME=admin \
  -e API_PASSWORD=admin \
  -e ENV_TYPE=ied \
  -d ic-connector-mcp-server

启动后,MCP HTTP 地址为:http://127.0.0.1:3000/mcp