Semantic Integration Engine CLI

浅海 智晴 Created: 2025-12-29

Semantic Integration Engineは、知識グラフとベクトル検索を統合した意味検索エンジンです。

これまで本シリーズでは、REST、ChatGPT、VSCode(MCP)といった複数のクライアントから SIE を利用する方法を紹介してきました。

本記事では、その中でも最もシンプルで汎用的なアプローチとして、CLI から SIE を利用する方法に焦点を当てます。

CLI は、人間が直接操作できるだけでなく、シェルスクリプトや生成AIからも呼び出せる「最小のクライアント」として機能します。

REST API を基盤とした CLI を通じて、SIE の意味検索機能がどのように利用できるのかを、実際のデモを交えて解説していきます。

ここまでの流れ

Semantic Integration Engineを使用するためのクライアントとして以下の方式について説明してきました。

RESTは一般的なアプリケーションへ機能を公開するインタフェースになります。

ChatGPT用にはChatGPTが使用するWebSocketインタフェースを提供しました。

一般的なMCPクライアントと異なり、ChatGPTではJSON-RPCから派生した独自プロトコルを使用して接続してくるので、そのための専用のインタフェースとなっています。

VSCodeのCodex機能に対してWebSocketによるMCPインタフェースを提供しました。

CLI

今回は、SEI機能をコンソールやシェルスクリプトから簡単に使えるようにするためにCLI用のコマンドを作成しました。

アーキテクチャ

SIEサーバーでは以下の3つのインタフェースを提供しています。

  • REST API

  • MCP WebSocket

  • ChatGPT WebSocket

ChatGPT WebSocketはChatGPTが独自プロトコル(JSON-RPC派生)で接続を行います。

MCP WebSocketはアプリケーションから直接MCPのプロトコルで接続できるのに加えて、標準入出力を使ったMCPプロトコルを提供するコマンドから呼ばれます。VSCodeはこのルートを使っている想定です。

REST APIは一般的なアプリケーションに対するインタフェースを提供します。

REST APIで提供されている機能をシェル上で実行したり、シェルスクリプトに組み込んだりできるコマンドをCLI(Command Line Interface)として使用できるようにしたのが、今回のテーマであるSIE CLIです。

Semantic Integration Engineアーキテクチャ
図 1. Semantic Integration Engineアーキテクチャ

セットアップ

デモの起動には docker compose を使用します。

以下の docker-compose.yml をコピーして作業ディレクトリを作成し、 そこに docker-compose.yml として保存します。

services:
  #######################################################################
  # FUSEKI — RDF / SPARQL server
  #######################################################################
  fuseki:
    image: ghcr.io/asami/preload-fuseki:latest
    container_name: sie-fuseki
    platform: linux/amd64
    ports:
      - "9030:3030"
    restart: unless-stopped
    networks:
      - sie-net
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3030/ds/query?query=SELECT%20*%20WHERE%20%7B%20?s%20?p%20?o%20%7D%20LIMIT%201"]
      interval: 5s
      timeout: 3s
      retries: 20
      start_period: 10s
  #######################################################################
  # SIE-EMBEDDING — Lightweight embedding service
  #######################################################################
  sie-embedding:
    image: ghcr.io/asami/sie-embedding:latest
    container_name: sie-embedding
    ports:
      - "8081:8081"
    restart: unless-stopped
    networks:
      - sie-net
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
      interval: 3s
      timeout: 2s
      retries: 20
  #######################################################################
  # SIE — Semantic Integration Engine (Demo)
  #
  # NOTE:
  # - This demo explicitly uses application.demo.conf.
  # - Do NOT rely on the image default ENTRYPOINT/CMD for demo behavior.
  # - This preserves the historical demo behavior from docker-compose.demo.yml.
  #######################################################################
  sie:
    image: ghcr.io/asami/sie:0.2.0
    container_name: sie
    volumes:
      - .:/workspace/vscode-mcp
    depends_on:
      fuseki:
        condition: service_healthy
      sie-embedding:
        condition: service_healthy
    ports:
      - "9050:9050"   # HTTP + MCP WebSocket API (/mcp)
    environment:
      SIE_MODE: demo
      # ---- Application server mode (required) ----
      SERVER_MODE: demo
      # ---- MCP / VS Code workspace ----
      SIE_WORKSPACE_DIR: /workspace/vscode-mcp
      # ---- SIE configuration ----
      FUSEKI_URL: http://sie-fuseki:3030/ds
      SIE_EMBEDDING_MODE: "oss"
      SIE_EMBEDDING_ENDPOINT: http://sie-embedding:8081/embed
    command:
      - java
      - -Dconfig.file=/app/conf/application.demo.conf
      - -jar
      - /app/semantic-integration-engine.jar
    restart: unless-stopped
    networks:
      - sie-net
  #######################################################################
  # SIE-MCP — MCP stdio client (transient, non-daemon)
  #######################################################################
  sie-mcp:
    image: ghcr.io/asami/sie:0.2.0
    container_name: sie-mcp
    entrypoint: ["/opt/sie/bin/mcp-client"]
    stdin_open: true
    tty: false
    depends_on:
      sie:
        condition: service_started
    environment:
      MCP_WS_URL: ws://sie:9050/mcp
    networks:
      - sie-net
networks:
  sie-net:

起動

作業ディレクトリに移動して、以下のように docker コマンドで起動します。

$ docker compose up -d

最終的に以下の表示が終われば起動完了です。

[+] Running 5/5
 ✔ Network workd_sie-net    Created                                        0.0s
 ✔ Container sie-fuseki     Healthy                                        6.2s
 ✔ Container sie-embedding  Healthy                                       22.2s
 ✔ Container sie            Started                                       21.8s
 ✔ Container sie-mcp        Started                                       21.8s

なお、SIE起動完了後も HTML 文書をベクトル DB に登録する作業がバックグラウンドで走っているので、 デモの実行までは数分間をおくとよいでしょう。

運用環境

SIEを起動すると作業ディレクトリ上に以下のファイルが作成されます。

  • .sie-workspace-initialized : ロックファイル

  • .vscode/settings.json : VSCode用MCP設定ファイル

  • bin/sie-mcp : SIE MCPコマンド

  • bin/sie-cli : SIE CLIコマンド

sie-workspace-initialized、.vscode/settings、bin/sie-mcp は前回と同じものです。

最後にある bin/sie-cli が SIE CLI です。

動作確認

Docker composeで展開された sie-cli を使って、SIE の提供する機能を使用します。

SIE CLI の query コマンドを使用します。

$ bin/sie-cli query "SimpleObject" | jq

リクエストの結果、リクエストした単語に関係する以下の情報が返ってきます。

  • concepts : コンセプト一覧

  • passages : 関連する記事一覧(説明文付き)

  • graph : 知識グラフ

graph(知識グラフ)は、nodes に知識グラフを構成するノード一覧、edges に知識のトリプル一覧を格納しています。

bin/sie-cli query "SimpleObject" | jq
{
  "concepts": [
    {
      "uri": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
      "label": "SimpleObject",
      "lang": "en"
    }
  ],
  "passages": [
    {
      "id": "https://www.simplemodeling.org/en/glossary/domain-modeling/simpleobject.html#chunk-0",
      "text": "SimpleObject ASAMI, Tomoharu Term SimpleObject Aliases - Definition SimpleObject is an abstract object defined in the SimpleModeling Reference Profile that specifies common attributes for domain objects. It delegates generic attribute groups—such as NameAttributes and LifecycleAttributes—as value objects, making it reusable as a base class for both entity objects and value objects. SimpleEntity inherits from SimpleObject and adds attributes such as the identifier (id) required for persistence, forming the foundation of entity objects. Category Domain Modeling SimpleModeling Reference Profile Related Terms SimpleEntity Value Object Domain Object Attribute Group Related Articles SimpleObject",
      "score": 0.7675370573997498
    },
    {
      "id": "https://www.simplemodeling.org/en/glossary/domain-modeling/simpleentity.html#chunk-0",
      "text": "SimpleEntity ASAMI, Tomoharu Term SimpleEntity Aliases - Definition SimpleObject is an abstract object defined in the SimpleModeling Reference Profile that specifies common attributes for domain objects. SimpleEntity provides a comprehensive set of attributes commonly needed by entity objects, allowing designers to define entity objects by simply adding domain-specific attributes. Category Domain Modeling SimpleModeling Reference Profile Related Terms SimpleObject Value Object Domain Object Attribute Group Related Articles SimpleObject",
      "score": 0.7702887058258057
    },
    {
      "id": "https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-0",
      "text": "SimpleObject ASAMI, Tomoharu Created: 2025-09-15 Updated: 2025-12-15 In the SimpleModeling Reference Profile (SMRP), the abstract class SimpleEntity is defined as the base class for all entity objects. Except for special cases, all entity objects are expected to derive from SimpleEntity. SimpleEntity provides a comprehensive set of attributes commonly needed by entity objects, allowing designers to define entity objects by simply adding domain-specific attributes. SimpleObject is defined as the base class of SimpleEntity. SimpleObject is an abstract object in SimpleModeling that defines the common attributes of domain objects. Value objects can optionally use SimpleObject as their base class. SimpleObject is composed by delegating various generic attribute groups, each of which can also be",
      "score": 0.7750577330589294
    },
    {
      "id": "https://www.simplemodeling.org/en/blog/sm-mcp-chatgpt.html#chunk-19",
      "text": "  },\n      {\n        \"id\": \"https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-0\",\n        \"text\": \"SimpleObject ASAMI, Tomoharu Created: 2025-09-15 In the SimpleModeling Reference Profile, the abstract class SimpleEntity is defined as the base class for all entity objects. Except for special cases, all entity objects are expected to derive from SimpleEntity. SimpleEntity provides a comprehensive set of attributes commonly needed by entity objects, allowing designers to define entity objects by simply adding domain-specific attributes. SimpleObject is defined as the base class of SimpleEntity. SimpleObject is an abstract object in SimpleModeling that defines the common attributes of domain objects. Value objects can optionally use SimpleObject as their base class. S",
      "score": 0.8564751744270325
    },
    {
      "id": "https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-3",
      "text": "defines an id attribute required for persistence, which makes it unsuitable for non-persistent objects like value objects. To accommodate use with value objects, a separate class named SimpleObject was defined to hold only common attributes, and SimpleEntity was made a subclass of SimpleObject. Internationalization In this article, the file simpleobject.cml is prepared in both Japanese and English versions, but in actual operation, it is also possible to include both Japanese and English descriptions side by side as shown below. Tools can extract and utilize the respective Japanese and English descriptions as needed. References Glossary SimpleEntity SimpleObject is an abstract object defined in the SimpleModeling Reference Profile that specifies common attributes for domain objects. Simple",
      "score": 0.8827045559883118
    }
  ],
  "graph": {
    "nodes": [
      {
        "id": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
        "label": "SimpleObject",
        "kind": "concept"
      },
      {
        "id": "https://www.simplemodeling.org/en/glossary/domain-modeling/simpleobject.html#chunk-0",
        "label": "SimpleObject ASAMI, Tomoharu Term SimpleObject Aliases - Definition SimpleObject",
        "kind": "passage"
      },
      {
        "id": "https://www.simplemodeling.org/en/glossary/domain-modeling/simpleentity.html#chunk-0",
        "label": "SimpleEntity ASAMI, Tomoharu Term SimpleEntity Aliases - Definition SimpleObject",
        "kind": "passage"
      },
      {
        "id": "https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-0",
        "label": "SimpleObject ASAMI, Tomoharu Created: 2025-09-15 Updated: 2025-12-15 In the Simp",
        "kind": "passage"
      },
      {
        "id": "https://www.simplemodeling.org/en/blog/sm-mcp-chatgpt.html#chunk-19",
        "label": "  },\n      {\n        \"id\": \"https://www.simplemodeling.org/en/domain-modeling/si",
        "kind": "passage"
      },
      {
        "id": "https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-3",
        "label": "defines an id attribute required for persistence, which makes it unsuitable for ",
        "kind": "passage"
      }
    ],
    "edges": [
      {
        "source": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
        "target": "https://www.simplemodeling.org/en/glossary/domain-modeling/simpleobject.html#chunk-0",
        "relation": "related"
      },
      {
        "source": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
        "target": "https://www.simplemodeling.org/en/glossary/domain-modeling/simpleentity.html#chunk-0",
        "relation": "related"
      },
      {
        "source": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
        "target": "https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-0",
        "relation": "related"
      },
      {
        "source": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
        "target": "https://www.simplemodeling.org/en/blog/sm-mcp-chatgpt.html#chunk-19",
        "relation": "related"
      },
      {
        "source": "https://www.simplemodeling.org/glossary/domain-modeling/simpleobject",
        "target": "https://www.simplemodeling.org/en/domain-modeling/simple-object.html#chunk-3",
        "relation": "related"
      }
    ]
  }
}

コマンドを使って SIE の機能を使うことができました。

VSCode

前回MCPではうまくいかなかったVSCode連携ですが、CLIを使ってチャレンジしてみました。

VSCodeのCodexは外部コマンドを実行する機能を持っているので、これを利用します。

ちょっと無理矢理ですがCodexに対するプロンプト (Prompt)でCLIの実行を直接指示してみました。

bin/sie-cli query "SimpleObject" を使ってSimpleObjectの情報を取得して、情報をまとめて下さい。

その結果、以下のように SIE CLI を実行して得られたコンセプト、パッセージ、知識グラフ情報から、以下のような出力が行われました。SIE から得られた情報を適切に解釈していることが分かります。

SimpleObject の情報まとめ(./bin/sie-cli query "SimpleObject" より):
SimpleObject は SimpleModeling Reference Profile の抽象オブジェクトで、ドメインオブジェクトの共通属性を定義する基底クラス。
NameAttributes や LifecycleAttributes などの汎用属性グループを値オブジェクトとして委譲し、再利用しやすい構成。
SimpleEntity は SimpleObject を継承し、永続化に必要な id などを追加してエンティティの基盤となる。
Value Object は必要に応じて SimpleObject を基底クラスとして利用可能。
関連用語: SimpleEntity、Value Object、Domain Object、Attribute Group。

MCPプロトコルでは initialize や get_manifest から得られた MCP サーバーが提供する機能を、生成AIが判断して使っていきます。

CLIを使う場合でも、RULE.mdなどのルールファイルを用意したり、プロンプトで機能情報を提供するなどして、生成AIが外部知識を取得する手段として活用してもらえるのではないかと思います。

まとめ

本記事では、Semantic Integration Engine の REST API を利用した CLI の構成と動作を紹介しました。

CLI を用いることで、SIE の query 機能をコンソールやシェルスクリプトから直接呼び出せるようになり、さらに生成AIに対して「外部知識を取得する手段」として提示できることを確認しました。

REST を基盤とした CLI は、MCP や ChatGPT 連携といった高度な統合の前段としても、また単独のツールとしても有用な、SIE の重要な利用形態の一つです。

今後は、CLI と MCP、生成AIを組み合わせた、より自然な知識取得フローについても検討していく予定です。

参照

用語集

Semantic Integration Engine (SIE)

BoK(Body of Knowledge)から生成された構造化知識(RDF)および文書知識(SmartDox)を統合し、AIが直接利用できる形に変換・検索するための統合エンジン。

知識グラフ (knowledge graph)

現実の概念・事物・出来事をノードとし、その関係をエッジとして表す意味的グラフ構造の知識ベース。

プロンプト (Prompt)

RAGによって取得された知識を、AIモデルの推論プロセスに橋渡しするための構造化指示または文脈表現。 BoKに格納された構造化知識を、モデルが理解し行動・内化できる物語的/命令的形式に変換する。